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

Public Member Functions

 CLPInterface (MPSolver *solver)
 Constructor that takes a name for the underlying CLP solver.
 
 ~CLPInterface () override
 
void SetOptimizationDirection (bool maximize) override
 Sets the optimization direction (min/max).
 
MPSolver::ResultStatus Solve (const MPSolverParameters &param) override
 Extracts model and solve the LP/MIP. Returns the status of the search.
 
void Reset () override
 
void SetVariableBounds (int var_index, double lb, double ub) override
 Modify bounds.
 
void SetVariableInteger (int var_index, bool integer) override
 Ignore as CLP does not solve models with integer variables.
 
void SetConstraintBounds (int row_index, double lb, double ub) override
 Modify bounds of an extracted variable.
 
void AddRowConstraint (MPConstraint *ct) override
 Add constraint incrementally.
 
void AddVariable (MPVariable *var) override
 Add variable incrementally.
 
void SetCoefficient (MPConstraint *constraint, const MPVariable *variable, double new_value, double old_value) override
 Change a coefficient in a constraint.
 
void ClearConstraint (MPConstraint *constraint) override
 Clear a constraint from all its terms.
 
void SetObjectiveCoefficient (const MPVariable *variable, double coefficient) override
 Change a coefficient in the linear objective.
 
void SetObjectiveOffset (double offset) override
 Change the constant term in the linear objective.
 
void ClearObjective () override
 Clear the objective from all its terms.
 
int64_t iterations () const override
 ---— Query statistics on the solution and the solve ---—
 
int64_t nodes () const override
 Number of branch-and-bound nodes. Only available for discrete problems.
 
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 column.
 
bool IsContinuous () const override
 
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.
 
void ExtractNewVariables () override
 Define new variables and add them to existing constraints.
 
void ExtractNewConstraints () override
 Define new constraints on old and new variables.
 
void ExtractObjective () override
 Extracts the objective.
 
std::string SolverVersion () const override
 Returns a string describing the underlying solver and its version.
 
void * underlying_solver () override
 Returns the underlying solver.
 
- Public Member Functions inherited from operations_research::MPSolverInterface
 MPSolverInterface (MPSolver *solver)
 
virtual ~MPSolverInterface ()
 
virtual bool SupportsDirectlySolveProto (std::atomic< bool > *) const
 
virtual MPSolutionResponse DirectlySolveProto (LazyMutableCopy< MPModelRequest >, std::atomic< bool > *)
 
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 void SetStartingLpBasis (const std::vector< MPSolver::BasisStatus > &, const std::vector< MPSolver::BasisStatus > &)
 See MPSolver::SetStartingLpBasis().
 
virtual double infinity ()
 
virtual bool InterruptSolve ()
 
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.
 
virtual bool SetSolverSpecificParametersAsString (const std::string &parameters)
 
- 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 42 of file clp_interface.cc.

Constructor & Destructor Documentation

◆ CLPInterface()

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

Constructor that takes a name for the underlying CLP solver.

--— Solver --—

Creates a LP/MIP instance with the specified name and minimization objective.

Definition at line 138 of file clp_interface.cc.

◆ ~CLPInterface()

operations_research::CLPInterface::~CLPInterface ( )
override

Definition at line 144 of file clp_interface.cc.

Member Function Documentation

◆ AddRowConstraint()

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

Add constraint incrementally.

Implements operations_research::MPSolverInterface.

Definition at line 262 of file clp_interface.cc.

◆ AddVariable()

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

Add variable incrementally.

Implements operations_research::MPSolverInterface.

Definition at line 266 of file clp_interface.cc.

◆ ClearConstraint()

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

Clear a constraint from all its terms.

Not cached.

Constraint may not have been extracted yet.

Implements operations_research::MPSolverInterface.

Definition at line 212 of file clp_interface.cc.

◆ ClearObjective()

void operations_research::CLPInterface::ClearObjective ( )
overridevirtual

Clear the objective from all its terms.

Clear objective of all its terms.

Clear linear terms

Variable may have not been extracted yet.

Clear constant term.

Implements operations_research::MPSolverInterface.

Definition at line 245 of file clp_interface.cc.

◆ column_status()

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

Returns the basis status of a column.

Implements operations_research::MPSolverInterface.

Definition at line 552 of file clp_interface.cc.

◆ ExtractNewConstraints()

void operations_research::CLPInterface::ExtractNewConstraints ( )
overridevirtual

Define new constraints on old and new variables.

Find the length of the longest row.

Make space for dummy variable.

Add each new constraint.

Add dummy variable to be able to build the constraint.

Add and name the rows.

Implements operations_research::MPSolverInterface.

Definition at line 337 of file clp_interface.cc.

◆ ExtractNewVariables()

void operations_research::CLPInterface::ExtractNewVariables ( )
overridevirtual

Define new variables and add them to existing constraints.

Define new variables

Faster extraction when nothing has been extracted yet.

Todo
(user): This could perhaps be made slightly faster by iterating through old constraints, constructing by hand the column-major representation of the addition to them and call clp_->addColumns. But this is good enough for now. Create new variables.

The true objective coefficient will be set later in ExtractObjective.

Add new variables to existing constraints.

Implements operations_research::MPSolverInterface.

Definition at line 281 of file clp_interface.cc.

◆ ExtractObjective()

void operations_research::CLPInterface::ExtractObjective ( )
overridevirtual

Extracts the objective.

Linear objective: set objective coefficients for all variables (some might have been modified)

Constant term. Use -offset instead of +offset because CLP does not follow conventions.

Implements operations_research::MPSolverInterface.

Definition at line 388 of file clp_interface.cc.

◆ IsContinuous()

bool operations_research::CLPInterface::IsContinuous ( ) const
inlineoverridevirtual

--— Misc --— Query problem type.

Implements operations_research::MPSolverInterface.

Definition at line 95 of file clp_interface.cc.

◆ IsLP()

bool operations_research::CLPInterface::IsLP ( ) const
inlineoverridevirtual

Returns true if the problem is continuous and linear.

Implements operations_research::MPSolverInterface.

Definition at line 96 of file clp_interface.cc.

◆ IsMIP()

bool operations_research::CLPInterface::IsMIP ( ) const
inlineoverridevirtual

Returns true if the problem is discrete and linear.

Implements operations_research::MPSolverInterface.

Definition at line 97 of file clp_interface.cc.

◆ iterations()

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

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

---— Query statistics on the solution and the solve ---— Number of simplex iterations

Implements operations_research::MPSolverInterface.

Definition at line 534 of file clp_interface.cc.

◆ nodes()

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

Number of branch-and-bound nodes. Only available for discrete problems.

Implements operations_research::MPSolverInterface.

Definition at line 539 of file clp_interface.cc.

◆ Reset()

void operations_research::CLPInterface::Reset ( )
overridevirtual

--— Model modifications and extraction --— Resets extracted model

Implements operations_research::MPSolverInterface.

Definition at line 146 of file clp_interface.cc.

◆ row_status()

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

Returns the basis status of a row.

Implements operations_research::MPSolverInterface.

Definition at line 544 of file clp_interface.cc.

◆ SetCoefficient()

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

Change a coefficient in a constraint.

The modification of the coefficient for an extracted row and variable is not cached.

The modification of an unextracted row or variable is cached and handled in ExtractModel.

Implements operations_research::MPSolverInterface.

Definition at line 191 of file clp_interface.cc.

◆ SetConstraintBounds()

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

Modify bounds of an extracted variable.

Not cached if the row has been extracted

Implements operations_research::MPSolverInterface.

Definition at line 180 of file clp_interface.cc.

◆ SetObjectiveCoefficient()

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

Change a coefficient in the linear objective.

Cached.

Implements operations_research::MPSolverInterface.

Definition at line 225 of file clp_interface.cc.

◆ SetObjectiveOffset()

void operations_research::CLPInterface::SetObjectiveOffset ( double offset)
overridevirtual

Change the constant term in the linear objective.

Cached.

Constant term. Use -offset instead of +offset because CLP does not follow conventions.

Implements operations_research::MPSolverInterface.

Definition at line 237 of file clp_interface.cc.

◆ SetOptimizationDirection()

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

Sets the optimization direction (min/max).

Not cached.

Implements operations_research::MPSolverInterface.

Definition at line 161 of file clp_interface.cc.

◆ SetVariableBounds()

void operations_research::CLPInterface::SetVariableBounds ( int var_index,
double lb,
double ub )
overridevirtual

Modify bounds.

Not cached if the variable has been extracted

Implements operations_research::MPSolverInterface.

Definition at line 166 of file clp_interface.cc.

◆ SetVariableInteger()

void operations_research::CLPInterface::SetVariableInteger ( int var_index,
bool integer )
overridevirtual

Ignore as CLP does not solve models with integer variables.

Implements operations_research::MPSolverInterface.

Definition at line 178 of file clp_interface.cc.

◆ Solve()

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

Extracts model and solve the LP/MIP. Returns the status of the search.

--— Solve --— Solve the problem using the parameter values specified.

Set log level.

Special case if the model is empty since CLP is not able to handle this special case by itself.

Time limit.

Start from a fresh set of default parameters and set them to specified values.

Solve

Check the status: optimal, infeasible, etc.

Get the results

Implements operations_research::MPSolverInterface.

Definition at line 402 of file clp_interface.cc.

◆ SolverVersion()

std::string operations_research::CLPInterface::SolverVersion ( ) const
inlineoverridevirtual

Returns a string describing the underlying solver and its version.

Implements operations_research::MPSolverInterface.

Definition at line 103 of file clp_interface.cc.

◆ underlying_solver()

void * operations_research::CLPInterface::underlying_solver ( )
inlineoverridevirtual

Returns the underlying solver.

Implements operations_research::MPSolverInterface.

Definition at line 105 of file clp_interface.cc.


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