Submitted arrays of different types in JuMP Heuristic Callbacks

Even though the variable are Bin, you need to pass the Float64 values 0.0 or 1.0. The solver doesn’t use true and false internally.

I don’t have your full code, so I couldn’t test to check this works, but you probably want something like:

function call_back_benders_heuristic(cb_data)
    vars_x = JuMP.VariableRef[]
    solution_x = Bool[]
    for i in V
        for j in i+1:n
            push!(vars_x, x[i,j])
            push!(solution_x, x_improve_two_opt[i,j])
        end
    end
    status = MOI.submit(
        m, 
        MOI.HeuristicSolution(cb_data), 
        vcat(vars_x, y, offset, λ),
        vcat(
            convert(Vector{Float64}, solution_x),
            convert(Vector{Float64}, y_improve_two_opt),
            bar_offset_improve_two_opt,
            λ_improve_two_opt,
        )
    println("Submitted a heuristic solution with status $status")
end
1 Like