I build a mixed-integer model with JuMP and Gurobi. I want to set certain constraints as lazy. With JuMP 0.18 I was using the solution described here: Lazy constraints at root node? · Issue #1226 · jump-dev/JuMP.jl · GitHub
Now I am using JuMP 0.19 and I cannot find information on how to achieve the same thing. Is it currently possible? If not, what would it take?
Thank you. This seems to be about adding lazy cuts from a callback. I was referring to adding lazy constraints when creating a model, which is a different (although similar) concept, and which does not rely on the concept of callback.
Edit for clarity: by that I mean that lazy constraints do not require to write an additional callback, Gurobi handles them. Ideally, adding Lazy=true when creating a constraint could tell Gurobi that this constraint is lazy.
odow
May 27, 2019, 8:06pm
4
Since you know that you’re using Gurobi, you should use JuMP in direct-mode. The new syntax would be:
model = JuMP.direct_model(Gurobi.Optimizer())
@variable(model, x >= 0)
@constraint(model, c, 2x >= 1)
grb = JuMP.backend(model)
row = grb[JuMP.index(c)]
Gurobi.set_intattrelement!(grb.inner, "Lazy", row, 3)
If you use this a lot, it’d be a nice contribution to add this as a MOI attribute, similar to the in-progress IIS: Compute IIS by dourouc05 · Pull Request #208 · jump-dev/Gurobi.jl · GitHub
Then the syntax would be
model = Modle(with_optimizer(Gurobi.Optimizer))
@variable(model, x >= 0)
@constraint(model, c, 2x >= 1)
MOI.set(model, Gurobi.Lazy(), c, 3)
or even
model = Modle(with_optimizer(Gurobi.Optimizer))
@variable(model, x >= 0)
@constraint(model, c, 2x >= 1)
MOI.set(model, Gurobi.ConstraintAttribute("lazy"), c, 3)
Let me know, and we can point you in the right direction.
Thank you, this works!
I would like to add this as a MOI attribute, where do I start?
odow
May 28, 2019, 1:35pm
6
What are the equivalent steps for the Lazy constraints generation that is described in the “Lazy Constraints” section of Solver Callbacks — JuMP -- Julia for Mathematical Optimization 0.18 documentation ?
odow
July 27, 2019, 7:15pm
8
We’re still in the process of re-introducing callbacks into JuMP 0.19. For now, if you need callbacks, stick with JuMP 0.18.