Convex.jl/Mosek/SCS setting callback

Hello all,

I am new to Julia so I apologize if this is trivial.

I am calling Mosek and SCS through Convex.jl and want to track how quickly these solvers are converging (for plotting purposes). Is it possible to pass a callback to Mosek/SCS through Julia that saves some information about each iterate?

Here is a MWE if that helps!

using LinearAlgebra
using Convex, SCS, MosekTools
using MathOptInterface
const MOI = MathOptInterface

function test()
    # problem copied from https://jump.dev/Convex.jl/stable/quick_tutorial/
    m = 4;  n = 5
    A = randn(m, n); b = randn(m, 1)
    x = Variable(n)
    problem = minimize(sumsquares(A * x - b), [x >= 0])

    values = []
    norms = []
    times = []

    # ==== made up code, how do I do this?
    function callback(iterate)
        push!(values, value(iterate))
        push!(norms, norm(iterate))
        push!(times, time(iterate))
    end
    problem.add_callback!(callback)
    # ==== end of made up code

    solve!(problem, SCS.Optimizer; silent_solver=true)

    # solve!(problem, Mosek.Optimizer; silent_solver=true)

    println(values)
    println(norms)
    println(times)
end

test()

Best,
Alex

No, it is not possible.

The only way I know how to do this would be to capture the solver’s output (to stdout) and parse it to extract the values you want to plot.

Got it. Unfortunately, capturing solver output doesn’t work for me as I want to plot other metrics.

Thanks for looking anyways!