I think you should use vcat() for that. For instance, something like
vars = vcat( [model[:u][i,j] for i in 1:gmax for j in 1:hmax] )
vals = vcat( u_vals[i,j] for i in 1:gmax for j in 1:hmax] )
status = MOI.submit( model, MOI.HeuristicSolution(cb_data), vars, vals )
println("$status")
but I am not sure. Probably also reshaping helps (see here ). Regarding the objective function value: I always computed it manually with the current variable values.
Thanks @mike_k, indeed the only issue was the that u_vars must be of type “sub::AbstractSubmittable”
so with the syntiax you suggested, and not the simple way i used before, the following code works fine:
u_vars = [MyMod[:u][i,h] for i in 1:gmax for h in 1:hmax]
u_vals = [u_vals[i,h] for i in 1:gmax for h in 1:hmax]
status = MOI.submit(MyMod, MOI.HeuristicSolution(cb), u_vars, u_vals)
moreover it must be a Vector{VariableRef} if you pass a Matrix{VariableRef} again you get an error.
Again i did not find an equivalent for getting the Obj value in the callback with MOI, i do need it since i want to run the heur callback only until the solver (gurobi) did non find a primal solution
You could try to use a Gurobi-specific callback as given in the example of Gurobi.jl, and use the callback codes you need.
I neither found a MOI function for that.