GRBCallback.AddLazy()

Add a lazy constraint to the MIP model from within a callback function. Note that this method can only be invoked when the where member variable is GRB.Callback.MIPNODE or GRB.Callback.MIPSOL (see the Callback Codes section for more information).

Lazy constraints are typically used when the full set of constraints for a MIP model is too large to represent explicitly. By only including the constraints that are actually violated by solutions found during the branch-and-cut search, it is sometimes possible to find a proven optimal solution while only adding a fraction of the full set of constraints.

You would typically add a lazy constraint by first querying the current node solution (by calling GetSolution from a GRB.Callback.MIPSOL callback, or GetNodeRel from a GRB.Callback.MIPNODE callback), and then calling AddLazy() to add a constraint that cuts off the solution. Gurobi guarantees that you will have the opportunity to cut off any solutions that would otherwise be considered feasible.

Note that you must disable dual reductions (using the DualReductions parameter) if you want to use lazy constraints.

void AddLazy ( GRBLinExpr lhsExpr,
    char sense,
    double rhsVal )

void AddConstr ( GRBTempConstr tempConstr )