This is a Julia package that makes it easy to do live tracking of the convergence of your algorithm. All the plotting is done using PyPlot.jl.
To install ConvergencePlots.jl, run the following Julia code.
using Pkg
pkg"add https://github.com/mohamed82008/ConvergencePlots.jl"First create an empty plot:
plot = ConvergencePlot()This will create an empty convergence plot that plots up to 100000 history points. Older points are overwritten. To specify how many history points to plot, use the constructor:
plot = ConvergencePlot(n)where n is the number of points.
The keyword arguments you can pass to the ConvergencePlot constructor are:
names: aVector{String}that has all the names of the convergence metrics to be plotted. The default value ofnamesis["Residual"].options: a dictionary mapping each name innamesto aNamedTuple. Each named tuple has the plotting options to pass toPyPlot, e.g.(label = "KKT residual", ls = "--", marker = "+"). Iflabelis not passed, it defaults to the corresponding name innames. You can also pass a singleNamedTupleof options without thelabeloption, and it will be used for all the names.show: iftruethe empty figure will be displayed. This isfalseby default.
After creating an empty plot, you can add points to it as follows:
addpoint!(plot, Dict("Residual" => 1.0))where the second argument can contain one value for each name in names. If only a single name exists, you can also use:
addpoint!(plot, 1.0)Adding a point will display the plot by default. To stop the plot from displaying, set the show keyword argument to false.
To close the plot, call:
closeplot!(plot)using ConvergencePlots
plot = ConvergencePlot(
names = ["KKT residual", "|Δx|", "|Δf|"],
options = Dict(
"KKT residual" => (color = "red",),
"|Δx|" => (color = "blue",),
"|Δf|" => (color = "black",),
),
)
kkt = 1 ./ (1:50)
Δx = 0.1 .* sqrt.(kkt)
Δf = 10 .* kkt .^ 2
for i in 1:50
sleep(1e-4)
addpoint!(
plot,
Dict(
"KKT residual" => kkt[i],
"|Δx|" => Δx[i],
"|Δf|" => Δf[i],
),
)
end