Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::XpressMPCallbackContext Class Reference
Inheritance diagram for operations_research::XpressMPCallbackContext:
operations_research::MPCallbackContext

Public Member Functions

 XpressMPCallbackContext (XPRSprob *xprsprob, MPCallbackEvent event, int num_nodes)
 
MPCallbackEvent Event () override
 Implementation of the interface.
 
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
 
bool UpdateFromXpressState (XPRSprob cbprob)
 
- Public Member Functions inherited from operations_research::MPCallbackContext
virtual ~MPCallbackContext ()
 

Friends

class XpressInterface
 

Detailed Description

Definition at line 221 of file xpress_interface.cc.

Constructor & Destructor Documentation

◆ XpressMPCallbackContext()

operations_research::XpressMPCallbackContext::XpressMPCallbackContext ( XPRSprob * xprsprob,
MPCallbackEvent event,
int num_nodes )
inline

Definition at line 225 of file xpress_interface.cc.

Member Function Documentation

◆ AddCut()

void operations_research::XpressMPCallbackContext::AddCut ( const LinearRange & cutting_plane)
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 236 of file xpress_interface.cc.

◆ AddLazyConstraint()

void operations_research::XpressMPCallbackContext::AddLazyConstraint ( const LinearRange & lazy_constraint)
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 239 of file xpress_interface.cc.

◆ CanQueryVariableValues()

bool operations_research::XpressMPCallbackContext::CanQueryVariableValues ( )
overridevirtual

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 2245 of file xpress_interface.cc.

◆ Event()

MPCallbackEvent operations_research::XpressMPCallbackContext::Event ( )
inlineoverridevirtual

Implementation of the interface.

Implements operations_research::MPCallbackContext.

Definition at line 233 of file xpress_interface.cc.

◆ NumExploredNodes()

int64_t operations_research::XpressMPCallbackContext::NumExploredNodes ( )
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.

Implements operations_research::MPCallbackContext.

Definition at line 245 of file xpress_interface.cc.

◆ SuggestSolution()

double operations_research::XpressMPCallbackContext::SuggestSolution ( const absl::flat_hash_map< const MPVariable *, double > & solution)
overridevirtual

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.

Currently the XPRESS API does not handle clearing out previous hints

hint is empty, do nothing

Currently, XPRESS does not handle adding a new MIP solution inside the "cbintsol" callback (cb for new MIP solutions that is used here) So we have to prevent the user from adding a solution

Todo
: remove this workaround when it is handled in XPRESS

XPRESS doesn't guarantee if nor when it will test the suggested solution. So we return NaN because we can't know the actual objective value.

Implements operations_research::MPCallbackContext.

Definition at line 2258 of file xpress_interface.cc.

◆ UpdateFromXpressState()

bool operations_research::XpressMPCallbackContext::UpdateFromXpressState ( XPRSprob cbprob)

Call this method to update the internal state of the callback context before passing it to MPCallback::RunCallback(). Returns true if the internal state has changed.

◆ VariableValue()

double operations_research::XpressMPCallbackContext::VariableValue ( const MPVariable * variable)
overridevirtual

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 2249 of file xpress_interface.cc.

Friends And Related Symbol Documentation

◆ XpressInterface

friend class XpressInterface
friend

Definition at line 222 of file xpress_interface.cc.


The documentation for this class was generated from the following file: