Plotting and Saving of all values on each iteration


(Alex) #1

Hello Everyone,

I am using a Matlab-based modeling system for convex optimization, the CVX solver. I’d like to know how I can get all values on each iteration, such as the objective function value, or variable values. So long what I get is only the final value of the variables and the final value of the objective function after some iterations. I’d like to get those values for each iteration, saving them anywhere, but preferably on a .txt file or displaying them on the screen to be able to see the optimal value at each iteration by plotting them in one figure.

Thank you so much in advance for the help…


(Mark L. Stone) #2

CVX will never tell you the intermediate value of the CVX variables at the iterations of the solver,

Other than that, you can see whatever per iteration output is produced by the solver, but it might pertain to a transformed problem, not necessarily the problem as you specified it to CVX.

The only way around this that I know if is to use cvx_solver-settings to set maximum number of iterations for the solver. Run CVX with max iterations set to 1 and record the “final” output: Then re-run CVX with max iterations set to 2, record that final output, etc. Of course, CVX was not designed with the intention of supporting “circus tricks” such as this,


(Erling D.Andersen) #3

Please note optimizers are not the simple creatures discussed in text book but they do a lot presolving, scaling and reformulation before solving. So it is not feasible convert algorithmic iterates to something meaningful for the user in general.

Note postsolve may only work properly on (near) optimal solutions and therefore what Mark suggests may not produce something useful. So be careful.

The optimizer has to be designed for get intermediate iterate out of the algorithm.