You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a MWE of the issue. I hope it is pretty straightforward.
using JuMP
using Gurobi
m =Model(Gurobi.Optimizer)
@variable(m, x >=1)
@objective(m, Min, x)
optimize!(m)
Running just the above code, if I check m.moi_backend.optimizer.model.generic_callback, I see that there is already a callback there, even though I didn't add it myself:
Gurobi._CallbackUserData( sense : minimize
number of variables =1
number of linear constraints =0
number of quadratic constraints =0
number of sos constraints =0
number of non-zero coeffs =0
number of non-zero qp objective terms =0
number of non-zero qp constraint terms =0...
For some reason, running optimize! seems to just add a generic callback.
This is problematic, because if I try to add a callback as following:
functioncb_fn(cb_data)
val = JuMP.callback_value(x)
con =@build_constraint(x >=2)
MOI.submit(m, MOI.LazyConstraint(cb_data), con)
end
MOI.set(m, MOI.LazyConstraintCallback(), cb_fn)
optimize!(m)
It throws the following error, since it thinks that I have both a Gurobi.CallbackFunction and an MOI one:
ERROR: Cannot use Gurobi.CallbackFunction as well as MOI.AbstractCallbackFunction
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] _check_moi_callback_validity at C:\Users\berko\.julia\packages\Gurobi\Lci9Q\src\MOI_wrapper.jl:2372 [inlined]
[3] optimize!(::Gurobi.Optimizer) at C:\Users\berko\.julia\packages\Gurobi\Lci9Q\src\MOI_wrapper.jl:2386
[4] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer}) at C:\Users\iai\builds\InterpretableAI\SystemImage\SysImgBuilder\.julia\packages\MathOptInterface\ZJFKw\src\Bridges\bridge_optimizer.jl:264
[5] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at C:\Users\iai\builds\InterpretableAI\SystemImage\SysImgBuilder\.julia\packages\MathOptInterface\ZJFKw\src\Utilities\cachingoptimizer.jl:215
[6] optimize!(::Model, ::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\iai\builds\InterpretableAI\SystemImage\SysImgBuilder\.julia\packages\JuMP\qhoVb\src\optimizer_interface.jl:130
[7] optimize! at C:\Users\iai\builds\InterpretableAI\SystemImage\SysImgBuilder\.julia\packages\JuMP\qhoVb\src\optimizer_interface.jl:106 [inlined] (repeats 2 times)
[8] top-level scope at REPL[61]:1
Furthermore, if I try to add the callback without the first optimize! to resolve the issue, it doesn't give the right solution, and returns 1 instead of 2! Please help. I'm using Gurobi 0.9.7 and JuMP 0.21.5.
The text was updated successfully, but these errors were encountered:
Here's a MWE of the issue. I hope it is pretty straightforward.
Running just the above code, if I check
m.moi_backend.optimizer.model.generic_callback
, I see that there is already a callback there, even though I didn't add it myself:For some reason, running
optimize!
seems to just add a generic callback.This is problematic, because if I try to add a callback as following:
It throws the following error, since it thinks that I have both a Gurobi.CallbackFunction and an MOI one:
Furthermore, if I try to add the callback without the first
optimize!
to resolve the issue, it doesn't give the right solution, and returns 1 instead of 2! Please help. I'm using Gurobi 0.9.7 and JuMP 0.21.5.The text was updated successfully, but these errors were encountered: