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

Public Member Functions

 GLOPInterface (MPSolver *solver)
 
 ~GLOPInterface () override
 
MPSolver::ResultStatus Solve (const MPSolverParameters &param) override
 --— Solve --—
 
bool InterruptSolve () override
 
bool SupportsDirectlySolveProto (std::atomic< bool > *interrupt) const override
 --— Directly solve proto is supported —
 
MPSolutionResponse DirectlySolveProto (LazyMutableCopy< MPModelRequest > request, std::atomic< bool > *interrupt) override
 
void Reset () override
 --— Model modifications and extraction --—
 
void SetOptimizationDirection (bool maximize) override
 Sets the optimization direction (min/max).
 
void SetVariableBounds (int index, double lb, double ub) override
 Modifies bounds of an extracted variable.
 
void SetVariableInteger (int index, bool integer) override
 Modifies integrality of an extracted variable.
 
void SetConstraintBounds (int index, double lb, double ub) override
 Modify bounds of an extracted variable.
 
void AddRowConstraint (MPConstraint *ct) override
 Adds a linear constraint.
 
void AddVariable (MPVariable *var) override
 Add a variable.
 
void SetCoefficient (MPConstraint *constraint, const MPVariable *variable, double new_value, double old_value) override
 Changes a coefficient in a constraint.
 
void ClearConstraint (MPConstraint *constraint) override
 Clears a constraint from all its terms.
 
void SetObjectiveCoefficient (const MPVariable *variable, double coefficient) override
 Changes a coefficient in the linear objective.
 
void SetObjectiveOffset (double value) override
 Changes the constant term in the linear objective.
 
void ClearObjective () override
 Clears the objective from all its terms.
 
int64_t iterations () const override
 ---— Query statistics on the solution and the solve ---—
 
int64_t nodes () const override
 
MPSolver::BasisStatus row_status (int constraint_index) const override
 Returns the basis status of a row.
 
MPSolver::BasisStatus column_status (int variable_index) const override
 Returns the basis status of a constraint.
 
bool IsContinuous () const override
 --— Misc --—
 
bool IsLP () const override
 Returns true if the problem is continuous and linear.
 
bool IsMIP () const override
 Returns true if the problem is discrete and linear.
 
std::string SolverVersion () const override
 Returns a string describing the underlying solver and its version.
 
void * underlying_solver () override
 Returns the underlying solver.
 
void ExtractNewVariables () override
 Extracts the variables that have not been extracted yet.
 
void ExtractNewConstraints () override
 Extracts the constraints that have not been extracted yet.
 
void ExtractObjective () override
 Extracts the objective.
 
void SetStartingLpBasis (const std::vector< MPSolver::BasisStatus > &variable_statuses, const std::vector< MPSolver::BasisStatus > &constraint_statuses) override
 See MPSolver::SetStartingLpBasis().
 
void SetParameters (const MPSolverParameters &param) override
 Sets all parameters in the underlying solver.
 
void SetRelativeMipGap (double value) override
 Sets each parameter in the underlying solver.
 
void SetPrimalTolerance (double value) override
 
void SetDualTolerance (double value) override
 
void SetPresolveMode (int value) override
 
void SetScalingMode (int value) override
 Sets the scaling mode.
 
void SetLpAlgorithm (int value) override
 
bool SetSolverSpecificParametersAsString (const std::string &parameters) override
 
- Public Member Functions inherited from operations_research::MPSolverInterface
 MPSolverInterface (MPSolver *solver)
 
virtual ~MPSolverInterface ()
 
virtual void Write (const std::string &filename)
 
virtual bool AddIndicatorConstraint (MPConstraint *const)
 
virtual void BranchingPriorityChangedForVariable (int)
 
double best_objective_bound () const
 
double objective_value () const
 Returns the objective value of the best solution found so far.
 
bool CheckSolutionIsSynchronized () const
 
virtual bool CheckSolutionExists () const
 
bool CheckSolutionIsSynchronizedAndExists () const
 Handy shortcut to do both checks above (it is often used).
 
int last_variable_index () const
 Returns the index of the last variable extracted.
 
bool variable_is_extracted (int var_index) const
 
void set_variable_as_extracted (int var_index, bool extracted)
 
bool constraint_is_extracted (int ct_index) const
 
void set_constraint_as_extracted (int ct_index, bool extracted)
 
bool quiet () const
 Returns the boolean indicating the verbosity of the solver output.
 
void set_quiet (bool quiet_value)
 Sets the boolean indicating the verbosity of the solver output.
 
MPSolver::ResultStatus result_status () const
 Returns the result status of the last solve.
 
virtual double ComputeExactConditionNumber () const
 
virtual double infinity ()
 
virtual bool NextSolution ()
 See MPSolver::NextSolution() for contract.
 
virtual void SetCallback (MPCallback *)
 See MPSolver::SetCallback() for details.
 
virtual bool SupportsCallbacks () const
 

Additional Inherited Members

- Public Types inherited from operations_research::MPSolverInterface
enum  SynchronizationStatus { MUST_RELOAD , MODEL_SYNCHRONIZED , SOLUTION_SYNCHRONIZED }
 
- Static Public Attributes inherited from operations_research::MPSolverInterface
static constexpr int64_t kUnknownNumberOfIterations = -1
 
static constexpr int64_t kUnknownNumberOfNodes = -1
 
- Protected Member Functions inherited from operations_research::MPSolverInterface
void ExtractModel ()
 Extracts model stored in MPSolver.
 
void ResetExtractionInformation ()
 Resets the extraction information.
 
void InvalidateSolutionSynchronization ()
 
void SetCommonParameters (const MPSolverParameters &param)
 Sets parameters common to LP and MIP in the underlying solver.
 
void SetMIPParameters (const MPSolverParameters &param)
 Sets MIP specific parameters in the underlying solver.
 
void SetUnsupportedDoubleParam (MPSolverParameters::DoubleParam param)
 Sets an unsupported double parameter.
 
virtual void SetUnsupportedIntegerParam (MPSolverParameters::IntegerParam param)
 Sets an unsupported integer parameter.
 
void SetDoubleParamToUnsupportedValue (MPSolverParameters::DoubleParam param, double value)
 Sets a supported double parameter to an unsupported value.
 
virtual void SetIntegerParamToUnsupportedValue (MPSolverParameters::IntegerParam param, int value)
 Sets a supported integer parameter to an unsupported value.
 
virtual absl::Status SetNumThreads (int num_threads)
 Sets the number of threads to be used by the solver.
 
- Protected Attributes inherited from operations_research::MPSolverInterface
MPSolver *const solver_
 
SynchronizationStatus sync_status_
 Indicates whether the model and the solution are synchronized.
 
MPSolver::ResultStatus result_status_
 
bool maximize_
 Optimization direction.
 
int last_constraint_index_
 Index in MPSolver::variables_ of last constraint extracted.
 
int last_variable_index_
 Index in MPSolver::constraints_ of last variable extracted.
 
double objective_value_
 The value of the objective function.
 
double best_objective_bound_
 The value of the best objective bound. Used only for MIP solvers.
 
bool quiet_
 Boolean indicator for the verbosity of the solver output.
 
- Static Protected Attributes inherited from operations_research::MPSolverInterface
static const int kDummyVariableIndex = 0
 -------— MPSolverInterface -------—
 

Detailed Description

Definition at line 40 of file glop_interface.cc.

Constructor & Destructor Documentation

◆ GLOPInterface()

operations_research::GLOPInterface::GLOPInterface ( MPSolver * solver)
explicit

Definition at line 117 of file glop_interface.cc.

◆ ~GLOPInterface()

operations_research::GLOPInterface::~GLOPInterface ( )
override

Definition at line 126 of file glop_interface.cc.

Member Function Documentation

◆ AddRowConstraint()

void operations_research::GLOPInterface::AddRowConstraint ( MPConstraint * ct)
overridevirtual

Adds a linear constraint.

Implements operations_research::MPSolverInterface.

Definition at line 225 of file glop_interface.cc.

◆ AddVariable()

void operations_research::GLOPInterface::AddVariable ( MPVariable * var)
overridevirtual

Add a variable.

Implements operations_research::MPSolverInterface.

Definition at line 229 of file glop_interface.cc.

◆ ClearConstraint()

void operations_research::GLOPInterface::ClearConstraint ( MPConstraint * constraint)
overridevirtual

Clears a constraint from all its terms.

Implements operations_research::MPSolverInterface.

Definition at line 239 of file glop_interface.cc.

◆ ClearObjective()

void operations_research::GLOPInterface::ClearObjective ( )
overridevirtual

Clears the objective from all its terms.

Implements operations_research::MPSolverInterface.

Definition at line 250 of file glop_interface.cc.

◆ column_status()

MPSolver::BasisStatus operations_research::GLOPInterface::column_status ( int variable_index) const
overridevirtual

Returns the basis status of a constraint.

Implements operations_research::MPSolverInterface.

Definition at line 265 of file glop_interface.cc.

◆ DirectlySolveProto()

MPSolutionResponse operations_research::GLOPInterface::DirectlySolveProto ( LazyMutableCopy< MPModelRequest > request,
std::atomic< bool > * interrupt )
inlineoverridevirtual

Reimplemented from operations_research::MPSolverInterface.

Definition at line 53 of file glop_interface.cc.

◆ ExtractNewConstraints()

void operations_research::GLOPInterface::ExtractNewConstraints ( )
overridevirtual

Extracts the constraints that have not been extracted yet.

Implements operations_research::MPSolverInterface.

Definition at line 295 of file glop_interface.cc.

◆ ExtractNewVariables()

void operations_research::GLOPInterface::ExtractNewVariables ( )
overridevirtual

Extracts the variables that have not been extracted yet.

Implements operations_research::MPSolverInterface.

Definition at line 281 of file glop_interface.cc.

◆ ExtractObjective()

void operations_research::GLOPInterface::ExtractObjective ( )
overridevirtual

Extracts the objective.

Implements operations_research::MPSolverInterface.

Definition at line 319 of file glop_interface.cc.

◆ InterruptSolve()

bool operations_research::GLOPInterface::InterruptSolve ( )
overridevirtual

Reimplemented from operations_research::MPSolverInterface.

Definition at line 198 of file glop_interface.cc.

◆ IsContinuous()

bool operations_research::GLOPInterface::IsContinuous ( ) const
overridevirtual

--— Misc --—

Implements operations_research::MPSolverInterface.

Definition at line 269 of file glop_interface.cc.

◆ IsLP()

bool operations_research::GLOPInterface::IsLP ( ) const
overridevirtual

Returns true if the problem is continuous and linear.

Implements operations_research::MPSolverInterface.

Definition at line 271 of file glop_interface.cc.

◆ IsMIP()

bool operations_research::GLOPInterface::IsMIP ( ) const
overridevirtual

Returns true if the problem is discrete and linear.

Implements operations_research::MPSolverInterface.

Definition at line 273 of file glop_interface.cc.

◆ iterations()

int64_t operations_research::GLOPInterface::iterations ( ) const
overridevirtual

---— Query statistics on the solution and the solve ---—

Implements operations_research::MPSolverInterface.

Definition at line 252 of file glop_interface.cc.

◆ nodes()

int64_t operations_research::GLOPInterface::nodes ( ) const
overridevirtual

Returns the number of branch-and-bound nodes. The problem must be discrete, otherwise it crashes, or returns kUnknownNumberOfNodes in NDEBUG mode.

Implements operations_research::MPSolverInterface.

Definition at line 256 of file glop_interface.cc.

◆ Reset()

void operations_research::GLOPInterface::Reset ( )
overridevirtual

--— Model modifications and extraction --—

Ignore any incremental info for the next solve. Note that the parameters will not be reset as we re-read them on each Solve().

Implements operations_research::MPSolverInterface.

Definition at line 203 of file glop_interface.cc.

◆ row_status()

MPSolver::BasisStatus operations_research::GLOPInterface::row_status ( int constraint_index) const
overridevirtual

Returns the basis status of a row.

Implements operations_research::MPSolverInterface.

Definition at line 261 of file glop_interface.cc.

◆ SetCoefficient()

void operations_research::GLOPInterface::SetCoefficient ( MPConstraint * constraint,
const MPVariable * variable,
double new_value,
double old_value )
overridevirtual

Changes a coefficient in a constraint.

Implements operations_research::MPSolverInterface.

Definition at line 233 of file glop_interface.cc.

◆ SetConstraintBounds()

void operations_research::GLOPInterface::SetConstraintBounds ( int index,
double lb,
double ub )
overridevirtual

Modify bounds of an extracted variable.

Implements operations_research::MPSolverInterface.

Definition at line 221 of file glop_interface.cc.

◆ SetDualTolerance()

void operations_research::GLOPInterface::SetDualTolerance ( double value)
overridevirtual
Todo
(user): Modify parameters_ with the correct value. The problem is that this is set by default by the wrapper to 1e-7 and for now we want to use higher default tolerances in Glop.

Implements operations_research::MPSolverInterface.

Definition at line 367 of file glop_interface.cc.

◆ SetLpAlgorithm()

void operations_research::GLOPInterface::SetLpAlgorithm ( int value)
overridevirtual

Implements operations_research::MPSolverInterface.

Definition at line 406 of file glop_interface.cc.

◆ SetObjectiveCoefficient()

void operations_research::GLOPInterface::SetObjectiveCoefficient ( const MPVariable * variable,
double coefficient )
overridevirtual

Changes a coefficient in the linear objective.

Implements operations_research::MPSolverInterface.

Definition at line 243 of file glop_interface.cc.

◆ SetObjectiveOffset()

void operations_research::GLOPInterface::SetObjectiveOffset ( double value)
overridevirtual

Changes the constant term in the linear objective.

Implements operations_research::MPSolverInterface.

Definition at line 248 of file glop_interface.cc.

◆ SetOptimizationDirection()

void operations_research::GLOPInterface::SetOptimizationDirection ( bool maximize)
overridevirtual

Sets the optimization direction (min/max).

Implements operations_research::MPSolverInterface.

Definition at line 209 of file glop_interface.cc.

◆ SetParameters()

void operations_research::GLOPInterface::SetParameters ( const MPSolverParameters & param)
overridevirtual

Sets all parameters in the underlying solver.

Implements operations_research::MPSolverInterface.

Definition at line 343 of file glop_interface.cc.

◆ SetPresolveMode()

void operations_research::GLOPInterface::SetPresolveMode ( int value)
overridevirtual

Implements operations_research::MPSolverInterface.

Definition at line 376 of file glop_interface.cc.

◆ SetPrimalTolerance()

void operations_research::GLOPInterface::SetPrimalTolerance ( double value)
overridevirtual
Todo
(user): Modify parameters_ with the correct value. The problem is that this is set by default by the wrapper to 1e-7 and for now we want to use higher default tolerances in Glop.

Implements operations_research::MPSolverInterface.

Definition at line 357 of file glop_interface.cc.

◆ SetRelativeMipGap()

void operations_research::GLOPInterface::SetRelativeMipGap ( double value)
overridevirtual

Sets each parameter in the underlying solver.

Implements operations_research::MPSolverInterface.

Definition at line 350 of file glop_interface.cc.

◆ SetScalingMode()

void operations_research::GLOPInterface::SetScalingMode ( int value)
overridevirtual

Sets the scaling mode.

Implements operations_research::MPSolverInterface.

Definition at line 391 of file glop_interface.cc.

◆ SetSolverSpecificParametersAsString()

bool operations_research::GLOPInterface::SetSolverSpecificParametersAsString ( const std::string & parameters)
overridevirtual

Pass solver specific parameters in text format. The format is solver-specific and is the same as the corresponding solver configuration file format. Returns true if the operation was successful.

Default implementation returns true if the input is empty. It returns false and logs a WARNING if the input is not empty.

NOTE(user): Android build uses protocol buffers in lite mode, and parsing data from text format is not supported there. To allow solver specific parameters from string on Android, we first need to switch to non-lite version of protocol buffers.

Reimplemented from operations_research::MPSolverInterface.

Definition at line 422 of file glop_interface.cc.

◆ SetStartingLpBasis()

void operations_research::GLOPInterface::SetStartingLpBasis ( const std::vector< MPSolver::BasisStatus > & ,
const std::vector< MPSolver::BasisStatus > &  )
overridevirtual

◆ SetVariableBounds()

void operations_research::GLOPInterface::SetVariableBounds ( int index,
double lb,
double ub )
overridevirtual

Modifies bounds of an extracted variable.

Implements operations_research::MPSolverInterface.

Definition at line 213 of file glop_interface.cc.

◆ SetVariableInteger()

void operations_research::GLOPInterface::SetVariableInteger ( int index,
bool integer )
overridevirtual

Modifies integrality of an extracted variable.

Implements operations_research::MPSolverInterface.

Definition at line 217 of file glop_interface.cc.

◆ Solve()

MPSolver::ResultStatus operations_research::GLOPInterface::Solve ( const MPSolverParameters & param)
overridevirtual

--— Solve --—

Re-extract the problem from scratch. We don't support modifying the LinearProgram in sync with changes done in the MPSolver.

Time limit.

The solution must be marked as synchronized even when no solution exists.

Implements operations_research::MPSolverInterface.

Definition at line 128 of file glop_interface.cc.

◆ SolverVersion()

std::string operations_research::GLOPInterface::SolverVersion ( ) const
overridevirtual

Returns a string describing the underlying solver and its version.

Implements operations_research::MPSolverInterface.

Definition at line 275 of file glop_interface.cc.

◆ SupportsDirectlySolveProto()

bool operations_research::GLOPInterface::SupportsDirectlySolveProto ( std::atomic< bool > * interrupt) const
inlineoverridevirtual

--— Directly solve proto is supported —

Reimplemented from operations_research::MPSolverInterface.

Definition at line 50 of file glop_interface.cc.

◆ underlying_solver()

void * operations_research::GLOPInterface::underlying_solver ( )
overridevirtual

Returns the underlying solver.

Implements operations_research::MPSolverInterface.

Definition at line 279 of file glop_interface.cc.


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