Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::CallbackResult Struct Reference

The value returned by the Callback function. More...

#include <callback.h>

Classes

struct  GeneratedLinearConstraint

Public Member Functions

void AddUserCut (BoundedLinearExpression linear_constraint)
void AddLazyConstraint (BoundedLinearExpression linear_constraint)
absl::Status CheckModelStorage (ModelStorageCPtr expected_storage) const
CallbackResultProto Proto () const

Public Attributes

bool terminate = false
std::vector< GeneratedLinearConstraintnew_constraints
std::vector< VariableMap< double > > suggested_solutions
 A solution or partially defined solution to give to the solver.

Detailed Description

The value returned by the Callback function.

Definition at line 225 of file callback.h.

Member Function Documentation

◆ AddLazyConstraint()

void operations_research::math_opt::CallbackResult::AddLazyConstraint ( BoundedLinearExpression linear_constraint)
inline

Adds a "lazy constraint," a linear constraint that excludes integer points. Use only for CallbackEvent::kMipNode and CallbackEvent::kMipSolution.

Definition at line 246 of file callback.h.

◆ AddUserCut()

void operations_research::math_opt::CallbackResult::AddUserCut ( BoundedLinearExpression linear_constraint)
inline

Adds a "user cut," a linear constraint that excludes the current LP solution but does not cut off any integer points. Use only for CallbackEvent::kMipNode.

Definition at line 240 of file callback.h.

◆ CheckModelStorage()

absl::Status operations_research::math_opt::CallbackResult::CheckModelStorage ( ModelStorageCPtr expected_storage) const

Returns a failure if the referenced variables don't belong to the input expected_storage (which must not be nullptr).

Definition at line 115 of file callback.cc.

◆ Proto()

CallbackResultProto operations_research::math_opt::CallbackResult::Proto ( ) const

Returns the proto equivalent of this object.

The caller should use CheckModelStorage() as this function does not check internal consistency of the referenced variables.

Definition at line 133 of file callback.cc.

Member Data Documentation

◆ new_constraints

std::vector<GeneratedLinearConstraint> operations_research::math_opt::CallbackResult::new_constraints

The user cuts and lazy constraints added. Prefer AddUserCut() and AddLazyConstraint() to modifying this directly.

Definition at line 275 of file callback.h.

◆ suggested_solutions

std::vector<VariableMap<double> > operations_research::math_opt::CallbackResult::suggested_solutions

A solution or partially defined solution to give to the solver.

Definition at line 278 of file callback.h.

◆ terminate

bool operations_research::math_opt::CallbackResult::terminate = false

When true it tells the solver to interrupt the solve as soon as possible.

It can be set from any event. This is equivalent to using a SolveInterrupter and triggering it from the callback.

Some solvers don't support interruption, in that case this is simply ignored and the solve terminates as usual. On top of that solvers may not immediately stop the solve. Thus the user should expect the callback to still be called after they set terminate to true in a previous call. Returning with terminate false after having previously returned true won't cancel the interruption.

Definition at line 271 of file callback.h.


The documentation for this struct was generated from the following files: