Warm-starting (set_start_value function) does not work in JuMP

Dear All,

I am trying to solve the following SDP with warm starting. The code is as follows

using JuMP, COSMO
    
# data
m = 5
n = 10
using Random: bitrand
c = randn(n)
x0 = bitrand(n)
A = randn(m, n)
b = A * x0 
x_prev = ones(n+1)
X_prev = x_prev*x_prev'

# JuMP model
    
sdp_model = JuMP.Model(COSMO.Optimizer)

@variables(sdp_model,
    begin
    X_tl[1 : n + 1, 1 : n + 1], PSD
end)

JuMP.set_start_value(X_tl, X_prev) 
# this line produces the following error:
# ERROR: MethodError: no method matching 
# set_start_value(::Symmetric{VariableRef,Array{VariableRef,2}}, ::Array{Float64,2})

obj = c' * X_tl[2:n + 1,1]

@objective(sdp_model, Min, obj)

@constraints(sdp_model, begin
    con_sdp_equality_1, A * X_tl[2:n + 1,1] .== b
    con_bound_1[i=1:n + 1, j=1:n + 1], X_tl[i,j] <= 1
    con_bound_2[i=1:n + 1, j=1:n + 1], X_tl[i,j] >= 0
end
    )

set_silent(sdp_model)

JuMP.optimize!(sdp_model)

obj_val = JuMP.objective_value(sdp_model)

X_sol = JuMP.value.(X_tl)

If I run the code I get the error

ERROR: MethodError: no method matching 
set_start_value(::Symmetric{VariableRef,Array{VariableRef,2}}, ::Array{Float64,2})

If I comment the line JuMP.set_start_value(...,...) , then the code runs without any problem. I have tried the code with other solvers such as Mosek etc, but it is the same error.

Any help or suggestions will be much appreciated!

Best Regards,
Shuvo

Try broadcasting it with JuMP.set_start_value.(X_tl, X_prev) (note the added . at the end of the function name to broadcast the call to every element).

2 Likes

Yes, that solved it, thank you so much!

2 Likes