I am using Java, Gurobi and I would like to implement some constraints as lazy. As written in the FAQ in the website "There are two ways to implement lazy constraints for a MIP model. If the constraints can be enumerated up front, simply set the Lazy attribute on the constraints that should be treated as lazy. If the constraints must be generated during the MIP search, you need to write a callback function."
1) I have tried both methods. using the first method I get this error "Error code: 20001. null" which means "Tried to use a constraint or variable that is not in the model, either because it was removed or because it has not yet been added." I have also made sure that I have set LazyConstraints to 1. (model.getEnv().set(GRB.IntParam.LazyConstraints,1);).
How can I fix this error? aren't lazy constraints supposed to come late?
one example:
I define expr and expr2 and then:
GRBConstr lazy = model.addConstr(expr,GRB.LESS_EQUAL,expr2);
lazy.set(GRB.IntAttr.Lazy, 2);
2) Using the second method (callback), only one set of the lazy constraints (the first one) is read and the rest of them are ignore. Why is it like that? do I need to change any option to make the rest of the lazy constraints readable?
Thanks in advance!
Fa