I’m trying to implement integer programming callbacks using JuMP. Basically, my heuristic callback is defined like this:
function my_heuristic_callback(cb_data)
x_val = [callback_value(cb_data, x_i) for x_i in x]
x_sol = [v < 0.5 ? 0 : 1 for v in x_val]
status = MOI.submit(
m, MOI.HeuristicSolution(cb_data), x, x_sol
)
println("I submitted a heuristic solution, and the status was: ", status)
endm = Model(CPLEX.Optimizer)
@variable(m, x[1:n], Bin)
@objective(m, Max, sum(x))
MOI.set(m, MOI.LazyConstraintCallback(), my_lazy_callback)
MOI.set(m, MOI.UserCutCallback(), my_user_callback)
MOI.set(m, MOI.HeuristicCallback(), my_heuristic_callback)
optimize!(m)
The following error appeared:
ERROR: LoadError: MethodError: no method matching submit(::Model, ::MathOptInterface.HeuristicSolution{CPLEX.CallbackContext}, ::Array{VariableRef,1}, ::Array{Int64,1})
Closest candidates are:
submit(::MathOptInterface.Utilities.MockOptimizer, ::MathOptInterface.AbstractSubmittable, ::Any...) at /Users/user/.julia/packages/MathOptInterface/bygN7/src/Utilities/mockoptimizer.jl:529
submit(::MathOptInterface.Utilities.CachingOptimizer, ::MathOptInterface.AbstractSubmittable, ::Any...) at /Users/user/.julia/packages/MathOptInterface/bygN7/src/Utilities/cachingoptimizer.jl:727
submit(::MathOptInterface.Bridges.AbstractBridgeOptimizer, ::MathOptInterface.AbstractSubmittable, ::Any...) at /Users/user/.julia/packages/MathOptInterface/bygN7/src/Bridges/bridge_optimizer.jl:1195
It seems that parameters type are wrong, but the code is a copy-paste from the documentation of JuMP v0.21.3. I don’t know what can possibly be wrong.