Explicit support for Lazy constraints

181 views
Skip to first unread message

Thomas Chabot

unread,
Nov 26, 2014, 1:09:55 PM11/26/14
to gur...@googlegroups.com
Hello all!

I'm a new user of Gurobi and i'm looking for a hand with the new feature of "Explicit support for Lazy constraints" with Gurobi6.0.

So, i have a set of constraints that i would like to use as "lazy" in my model from a vehicles routing problem. They take this form :
 (VB.NET)
1.            For j As Integer = 1 To J
2.                 For k As Integer = 1 To K
3.                    For r As Integer = 1 To R
4.                        Dim C1 As GRBConstr = Model.AddConstr(u(j, k, r) - u(j, k, 0), GRB.LESS_EQUAL, 480, "C1") 
5.                        C1.Set(GRB.IntAttr.Lazy, 3)
6.                    Next
7.                Next
8.            Next

But when i get to line 5, i'm stuck with Gurobi.GRBException. No more explanation... Is there some additionals parameters i need to set in the model?

I just keep searching, thank you to helping a noob!

T.C.

Sonja Mars

unread,
Dec 4, 2014, 4:22:50 AM12/4/14
to gur...@googlegroups.com
Hi,

To modify an attribute of a constraint, the constraint has to be added to the model first. You will have to call Model.Update() before setting the Lazy attribute. However, you should not call Update() too often, so I suggest, you add all constraints first, call update once and then modify the constraints you want to mark as lazy.

Best regards,
Sonja

-----------------------------------------------------------------
Dr. Sonja Mars
Gurobi Optimization

Gleb Belov

unread,
Oct 10, 2016, 10:16:35 PM10/10/16
to Gurobi Optimization
Hi,

I am looking at the lazy constraints issue in order to express anti-symmetry constraints. Which degree of the laziness, 1-3, would you recommend for them? Is it true that degree 3 is similar to the "user cut" category? Well obviously only checked after feasibility.

Then, I still need help setting the lazy attribute in C. Should I notice the constraint numbers for the "lazy" ones, call GRBupdateModel() and GRBsetattrlist() for those numbers? Then, do the numbers start from 0 so I can use a simple counter? (Because I cannot read the number of constraints until update...)

Or maybe use the new update mode (what's the parameter) where the model is updated instantly and I can modify the attribute right after creation?

Thank you

Daniel Espinoza

unread,
Oct 11, 2016, 7:44:02 AM10/11/16
to Gurobi Optimization
Hi Gleb,

you will see that for laziness level 1 or 2, the inequalities will only be added to the model when they are found to cut off a potential integer solution.
Only if laziness level is set to 3, the inequality will be tested at the root node relaxation and added if it cuts off the solution of that relaxation.

Now, the index of the constraint (in C) will be exactly in the order you added them (starting from zero).

Finally, I'm not sure if treating these constraints as lazy would be better than having them in the model up-front. I would suggest doing the experiment.

Best
Daniel
Reply all
Reply to author
Forward
0 new messages