Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
ScipMPCallbackContext (const ScipConstraintHandlerContext *scip_context, bool at_integer_solution) | |
MPCallbackEvent | Event () override |
bool | CanQueryVariableValues () override |
double | VariableValue (const MPVariable *variable) override |
void | AddCut (const LinearRange &cutting_plane) override |
void | AddLazyConstraint (const LinearRange &lazy_constraint) override |
double | SuggestSolution (const absl::flat_hash_map< const MPVariable *, double > &solution) override |
int64_t | NumExploredNodes () override |
const std::vector< CallbackRangeConstraint > & | constraints_added () |
Public Member Functions inherited from operations_research::MPCallbackContext | |
virtual | ~MPCallbackContext () |
Definition at line 1056 of file scip_interface.cc.
|
inline |
Definition at line 1058 of file scip_interface.cc.
|
inlineoverridevirtual |
Adds a constraint to the model that strengths the LP relaxation.
Call only when the event is kMipNode.
Requires that MPCallback::might_add_cuts() is true.
This constraint must not cut off integer solutions, it should only strengthen the LP (behavior is undefined otherwise). Use MPCallbackContext::AddLazyConstraint() if you are cutting off integer solutions.
Implements operations_research::MPCallbackContext.
Definition at line 1079 of file scip_interface.cc.
|
inlineoverridevirtual |
Adds a constraint to the model that cuts off an undesired integer solution.
Call only when the event is kMipSolution or kMipNode.
Requires that MPCallback::might_add_lazy_constraints() is true.
Use this to avoid adding a large number of constraints to the model where most are expected to not be needed.
Given an integral solution, AddLazyConstraint() MUST be able to detect if there is a violated constraint, and it is guaranteed that every integer solution will be checked by AddLazyConstraint().
Warning(rander): in some solvers, e.g. Gurobi, an integer solution may not respect a previously added lazy constraint, so you may need to add a constraint more than once (e.g. due to threading issues).
Implements operations_research::MPCallbackContext.
Definition at line 1087 of file scip_interface.cc.
|
inlineoverridevirtual |
Always false if event is not kMipSolution or kMipNode, otherwise behavior may be solver dependent.
For Gurobi, under kMipNode, may be false if the node was not solved to optimality, see MIPNODE_REL here for details: http://www.gurobi.com/documentation/8.0/refman/callback_codes.html
Implements operations_research::MPCallbackContext.
Definition at line 1070 of file scip_interface.cc.
|
inline |
Definition at line 1111 of file scip_interface.cc.
|
inlineoverridevirtual |
What the solver is currently doing. How you can interact with the solver from the callback depends on this value.
Implements operations_research::MPCallbackContext.
Definition at line 1063 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns the number of nodes explored so far in the branch and bound tree, which 0 at the root node and > 0 otherwise.
Call only when the event is kMipSolution or kMipNode.
scip_context_->NumNodesProcessed() returns: 0 before the root node is solved, e.g. if a heuristic finds a solution. 1 at the root node
1 after the root node. The NumExploredNodes spec requires that we return 0 at the root node, (this is consistent with gurobi). Below is a bandaid to try and make the behavior consistent, although some information is lost.
Implements operations_research::MPCallbackContext.
Definition at line 1100 of file scip_interface.cc.
|
inlineoverridevirtual |
Suggests a (potentially partial) variable assignment to the solver, to be used as a feasible solution (or part of one). If the assignment is partial, certain solvers (e.g. Gurobi) will try to compute a feasible solution from the partial assignment. Returns the objective value of the solution if the solver supports it.
Call only when the event is kMipNode.
Implements operations_research::MPCallbackContext.
Definition at line 1095 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns the value of variable from the solver's current state.
Call only when CanQueryVariableValues() is true.
At kMipSolution, the solution is integer feasible, while at kMipNode, the solution solves the current node's LP relaxation (so integer variables may be fractional).
Implements operations_research::MPCallbackContext.
Definition at line 1074 of file scip_interface.cc.