I am transferring some codes from old package versions (Julia 0.64, JuMP 0.18, Gurobi 8.5) to current environment. But I got some problems with one using lazyconstraints.
In the old environment, the problem was solved with 22 lazyconstraints added in about one and half hours. Currently, I am using Julia 1.2, JuMP 0.21, Gurboi 9.0. More than 15 thousand lazyconstraints were added in two hours and the problem was unsolved.
I didn’t find too much about callbacks in JuMP documents and examples. So I was wondering if there is anything changed in the newest version of JuMP, like when the callback functions are called, and if there is any parameters to control the callback functions. Below is a simple example showing how I use callback functions.
Thanks for your attention.
using JuMP,Gurobi env = Gurobi.Env() model = Model(optimizer_with_attributes(() -> Gurobi.Optimizer(env), "OutputFlag" => 0, "LazyConstraints" => 1)) @variable(model, x <= 10, Int) @objective(model, Max, x) function my_callback_function(cb_data) x_val = callback_value(cb_data, x) if x_val > 2 + 1e-6 con = @build_constraint(x <= 2) MOI.submit(model, MOI.LazyConstraint(cb_data), con) end end MOI.set(model, MOI.LazyConstraintCallback(), my_callback_function) optimize!(model)