GRBCallback.addCut()


GRBCallback.addCut()

Add a cutting plane to the MIP model from within a callback function. Note that this method can only be invoked when thewheremember variable is equal toGRB.CB_MIPNODE(see theCallback Codessection in the Reference Manual for more information).

Cutting planes can be added at any node of the branch-and-cut tree. However, they 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, you should first callgetNodeRel.

When adding your own cuts, you must set parameterPreCrushto value 1. This setting shuts off a few presolve reductions that sometimes prevent cuts on the original model from being applied to the presolved model.

Note that cutting planes added through this method must truly be cutting planes -- they can cut off continuous solutions, but they may not cut off integer solutions that respect the original constraints of the model. Ignoring this restriction will lead to incorrect solutions.

void addCut( GRBLinExpr lhsExpr,
char sense,
double rhs )
    Arguments:

    lhsExpr:左边为新c表达式utting plane.

    sense: Sense for new cutting plane (GRB.LESS_EQUAL,GRB.EQUAL, orGRB.GREATER_EQUAL).

    rhs: Right-hand side value for new cutting plane.