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;
  }

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization