Saving the solution during the algorithm

At times, it can be useful to save the current iterate in the algorithm every now and then. For this, the SaveSettings struct can be used. It can be provided to solvesdp using the save_settings keyword. This allows to save the solution of the algorithm

  • every k'th iteration, when iter_interval = k,
  • every s seconds, when time_interval = s. The solution is then saved at the end of an iteration of the algorithm after at least s seconds have passed, so the total time interval between two saves is at most s plus the time needed for 1 iteration.

You can choose whether only the last solution is kept (only_last = true, default), or all intermediate solutions (only_last = false). In the first case, the solution is saved as [save_name].jls. In the second case, save_name should contain a #, which is used as placeholder for the solution number.

The solutions can be retrieved using deserialize of Serialization.jl:

using Serialization
dualsol, primalsol = deserialize('solution.jl')
ClusteredLowRankSolver.SaveSettingsType
SaveSettings(;iter_interval=nothing, time_interval=nothing, only_last=true, save_name="solution", callback=nothing)

Settings for saving iterates during the solving process. - iterinterval : if an integer, save every 'iterinterval'-th iteration. - timeinterval : if a Float64, save every 'timeinterval' seconds. The solution is only saved at the end of an iteration. - onlylast : if true, delete previous saves after saving a new iterate. - savename : the name of the saved solution. A .jls extension is added. If only_last=false, a # is required in the name, which is used as placeholder for the save number. - callback : A way to customize saving. If this is a function, it uses the function to determine whether to save or not in this iteration. The function should have as input: the iteration number k, the time since the start of the algorithm t, the number of iterations since last save, and the time since last save. The function should have as output a Bool where true means that the solution should be saved.

source