Try our new documentation site (beta).
GRBcbcut
int | GRBcbcut ( | void | *cbdata, |
int | cutlen, | ||
const int | *cutind, | ||
const double | *cutval, | ||
char | cutsense, | ||
double | cutrhs ) |
Add a new cutting plane to the MIP model from within a user callback
routine. Note that this routine can only be called when the
where
value on the callback routine is
GRB_CB_MIPNODE
(see the
Callback Codes section for
more information).
Cutting planes can be added at any node of the branch-and-cut tree. Note that cuts should be added sparingly, since they increase the size of the relaxation model that is solved at each node and can significantly degrade node processing speed.
Cutting planes are typically used to cut off the current relaxation
solution. To retrieve the relaxation solution at the current node,
call GRBcbget with
what = GRB_CB_MIPNODE_REL
.
You should consider setting parameter PreCrush to value 1 when adding your own cuts. This setting shuts off a few presolve reductions that can sometimes prevent your cut from being applied to the presolved model (which would result in your cut being silently ignored).
One very important note: you should only add cuts that are implied by the constraints in your model. If you cut off an integer solution that is feasible according to the original model constraints, you are likely to obtain an incorrect solution to your MIP problem.
Return value:
A non-zero return value indicates that a problem occurred while adding the cut. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.
Arguments:
cbdata: The cbdata argument that was passed into the user callback by the Gurobi Optimizer. This argument must be passed unmodified from the user callback to GRBcbcut().
cutlen: The number of non-zero coefficients in the new cutting plane.
cutind: Variable indices for non-zero values in the new cutting plane.
cutval: Numerical values for non-zero values in the new cutting plane.
cutsense: Sense for the new cutting plane. Options are GRB_LESS_EQUAL, GRB_EQUAL, or GRB_GREATER_EQUAL.
cutrhs: Right-hand side value for the new cutting plane.
Example usage:
if (where == GRB_CB_MIPNODE) { int cutind[] = {0, 1}; double cutval[] = {1.0, 1.0}; error = GRBcbcut(cbdata, 2, cutind, cutval, GRB_LESS_EQUAL, 1.0); if (error) return 0; }