Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ linear_solver/

operations_research::MPSolverInterface Class Reference

This class wraps the actual mathematical programming solvers. More...

#include <linear_solver.h>

List of all members.

Public Types

enum  SynchronizationStatus { MUST_RELOAD, MODEL_SYNCHRONIZED, SOLUTION_SYNCHRONIZED }

Public Member Functions

 MPSolverInterface (MPSolver *const solver)
 Constructor.
virtual ~MPSolverInterface ()
virtual MPSolver::ResultStatus Solve (const MPSolverParameters &param)=0
 Solve Solves problem with specified parameter values.
virtual void Reset ()=0
 Model modifications and extraction Resets extracted model.
virtual void SetOptimizationDirection (bool maximize)=0
 Sets the optimization direction (min/max).
virtual void SetVariableBounds (int index, double lb, double ub)=0
 Modifies bounds of an extracted variable.
virtual void SetVariableInteger (int index, bool integer)=0
 Modifies integrality of an extracted variable.
virtual void SetConstraintBounds (int index, double lb, double ub)=0
 Modify bounds of an extracted variable.
virtual void AddRowConstraint (MPConstraint *const ct)=0
 Adds a linear constraint.
virtual void AddVariable (MPVariable *const var)=0
 Add a variable.
virtual void SetCoefficient (MPConstraint *const constraint, const MPVariable *const variable, double new_value, double old_value)=0
 Changes a coefficient in a constraint.
virtual void ClearConstraint (MPConstraint *const constraint)=0
 Clears a constraint from all its terms.
virtual void SetObjectiveCoefficient (const MPVariable *const variable, double coefficient)=0
 Changes a coefficient in the linear objective.
virtual void SetObjectiveOffset (double value)=0
 Changes the constant term in the linear objective.
virtual void ClearObjective ()=0
 Clears the objective from all its terms.
virtual int64 iterations () const =0
 Query statistics on the solution and the solve Returns the number of simplex iterations.
virtual int64 nodes () const =0
 Returns the number of branch-and-bound nodes.
virtual double best_objective_bound () const =0
 Returns the best objective bound. Only available for discrete problems.
double objective_value () const
 Returns the objective value of the best solution found so far.
virtual MPSolver::BasisStatus row_status (int constraint_index) const =0
 Returns the basis status of a row.
virtual MPSolver::BasisStatus column_status (int variable_index) const =0
 Returns the basis status of a constraint.
void CheckSolutionIsSynchronized () const
 Checks whether the solution is synchronized with the model, i.e.
virtual void CheckSolutionExists () const
 Checks whether a feasible solution exists.
void CheckSolutionIsSynchronizedAndExists () const
 Handy shortcut to do both checks above (it is often used).
virtual void CheckBestObjectiveBoundExists () const
 Checks whether information on the best objective bound exists.
virtual void WriteModel (const string &filename)=0
 Misc Writes model to a file.
virtual bool IsContinuous () const =0
 Queries problem type.
virtual bool IsLP () const =0
 Returns true if the problem is continuous and linear.
virtual bool IsMIP () const =0
 Returns true if the problem is discrete and linear.
int last_variable_index () const
 Returns the index of the last variable 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 string SolverVersion () const =0
 Returns a string describing the underlying solver and its version.
virtual void * underlying_solver ()=0
 Returns the underlying solver.
virtual double ComputeExactConditionNumber () const =0
 Computes exact condition number.

Static Public Attributes

static const int64 kUnknownNumberOfIterations = -1
 When the underlying solver does not provide the number of simplex iterations.
static const int64 kUnknownNumberOfNodes = -1
 When the underlying solver does not provide the number of branch-and-bound nodes.
static const int kNoIndex = -1
 When the index of a variable or constraint has not been assigned yet.

Protected Member Functions

void WriteModelToPredefinedFiles ()
 Writes out the model to a file specified by the --solver_write_model command line argument or MPSolver::set_write_model_filename.
void ExtractModel ()
 Extracts model stored in MPSolver.
virtual void ExtractNewVariables ()=0
 Extracts the variables that have not been extracted yet.
virtual void ExtractNewConstraints ()=0
 Extracts the constraints that have not been extracted yet.
virtual void ExtractObjective ()=0
 Extracts the objective.
void ResetExtractionInformation ()
 Resets the extraction information.
void InvalidateSolutionSynchronization ()
 Change synchronization status from SOLUTION_SYNCHRONIZED to MODEL_SYNCHRONIZED.
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.
virtual void SetParameters (const MPSolverParameters &param)=0
 Sets all parameters in the underlying solver.
void SetUnsupportedDoubleParam (MPSolverParameters::DoubleParam param) const
 Sets an unsupported double parameter.
void SetUnsupportedIntegerParam (MPSolverParameters::IntegerParam param) const
 Sets an unsupported integer parameter.
void SetDoubleParamToUnsupportedValue (MPSolverParameters::DoubleParam param, int value) const
 Sets a supported double parameter to an unsupported value.
void SetIntegerParamToUnsupportedValue (MPSolverParameters::IntegerParam param, double value) const
 Sets a supported integer parameter to an unsupported value.
virtual void SetRelativeMipGap (double value)=0
 Sets each parameter in the underlying solver.
virtual void SetPrimalTolerance (double value)=0
virtual void SetDualTolerance (double value)=0
virtual void SetPresolveMode (int value)=0
virtual void SetLpAlgorithm (int value)=0

Protected Attributes

MPSolver *const solver_
SynchronizationStatus sync_status_
 Indicates whether the model and the solution are synchronized.
MPSolver::ResultStatus result_status_
 Indicates whether the solve has reached optimality, infeasibility, a limit, etc.
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.
bool quiet_
 Boolean indicator for the verbosity of the solver output.

Static Protected Attributes

static const int kDummyVariableIndex = 0
 Index of dummy variable created for empty constraints or the objective offset.

Friends

class MPSolver
class MPObjective
 To access the maximize_ bool.


Detailed Description

This class wraps the actual mathematical programming solvers.

Each solver (CLP, CBC, GLPK, SCIP) has its own interface class that derives from this abstract class. This class is never directly accessed by the user.

See also:
cbc_interface.cc

clp_interface.cc

glpk_interface.cc

scip_interface.cc

Definition at line 859 of file linear_solver.h.


Member Enumeration Documentation

Enumerator:
MUST_RELOAD  The underlying solver (CLP, GLPK, .

..) and MPSolver are not in sync for the model nor for the solution.

MODEL_SYNCHRONIZED  The underlying solver and MPSolver are in sync for the model but not for the solution: the model has changed since the solution was computed last.

SOLUTION_SYNCHRONIZED  The underlying solver and MPSolver are in sync for the model and the solution.

Definition at line 861 of file linear_solver.h.


Constructor & Destructor Documentation

operations_research::MPSolverInterface::MPSolverInterface ( MPSolver *const   solver  )  [explicit]

Constructor.

The user will access the MPSolverInterface through the MPSolver passed as argument.

Definition at line 785 of file linear_solver.cc.

operations_research::MPSolverInterface::~MPSolverInterface (  )  [virtual]

Definition at line 791 of file linear_solver.cc.


Member Function Documentation

virtual MPSolver::ResultStatus operations_research::MPSolverInterface::Solve ( const MPSolverParameters param  )  [pure virtual]

Solve Solves problem with specified parameter values.

Returns true if the solution is optimal. Calls WriteModelToPredefinedFiles to allow the user to write the model to a file.

virtual void operations_research::MPSolverInterface::Reset (  )  [pure virtual]

Model modifications and extraction Resets extracted model.

virtual void operations_research::MPSolverInterface::SetOptimizationDirection ( bool  maximize  )  [pure virtual]

Sets the optimization direction (min/max).

virtual void operations_research::MPSolverInterface::SetVariableBounds ( int  index,
double  lb,
double  ub 
) [pure virtual]

Modifies bounds of an extracted variable.

virtual void operations_research::MPSolverInterface::SetVariableInteger ( int  index,
bool  integer 
) [pure virtual]

Modifies integrality of an extracted variable.

virtual void operations_research::MPSolverInterface::SetConstraintBounds ( int  index,
double  lb,
double  ub 
) [pure virtual]

Modify bounds of an extracted variable.

virtual void operations_research::MPSolverInterface::AddRowConstraint ( MPConstraint *const   ct  )  [pure virtual]

Adds a linear constraint.

virtual void operations_research::MPSolverInterface::AddVariable ( MPVariable *const   var  )  [pure virtual]

Add a variable.

virtual void operations_research::MPSolverInterface::SetCoefficient ( MPConstraint *const   constraint,
const MPVariable *const   variable,
double  new_value,
double  old_value 
) [pure virtual]

Changes a coefficient in a constraint.

virtual void operations_research::MPSolverInterface::ClearConstraint ( MPConstraint *const   constraint  )  [pure virtual]

Clears a constraint from all its terms.

virtual void operations_research::MPSolverInterface::SetObjectiveCoefficient ( const MPVariable *const   variable,
double  coefficient 
) [pure virtual]

Changes a coefficient in the linear objective.

virtual void operations_research::MPSolverInterface::SetObjectiveOffset ( double  value  )  [pure virtual]

Changes the constant term in the linear objective.

virtual void operations_research::MPSolverInterface::ClearObjective (  )  [pure virtual]

Clears the objective from all its terms.

virtual int64 operations_research::MPSolverInterface::iterations (  )  const [pure virtual]

Query statistics on the solution and the solve Returns the number of simplex iterations.

virtual int64 operations_research::MPSolverInterface::nodes (  )  const [pure virtual]

Returns the number of branch-and-bound nodes.

virtual double operations_research::MPSolverInterface::best_objective_bound (  )  const [pure virtual]

Returns the best objective bound. Only available for discrete problems.

double operations_research::MPSolverInterface::objective_value (  )  const

Returns the objective value of the best solution found so far.

Definition at line 871 of file linear_solver.cc.

virtual MPSolver::BasisStatus operations_research::MPSolverInterface::row_status ( int  constraint_index  )  const [pure virtual]

Returns the basis status of a row.

virtual MPSolver::BasisStatus operations_research::MPSolverInterface::column_status ( int  variable_index  )  const [pure virtual]

Returns the basis status of a constraint.

void operations_research::MPSolverInterface::CheckSolutionIsSynchronized (  )  const

Checks whether the solution is synchronized with the model, i.e.

whether the model has changed since the solution was computed last.

Definition at line 850 of file linear_solver.cc.

void operations_research::MPSolverInterface::CheckSolutionExists (  )  const [virtual]

Checks whether a feasible solution exists.

Default version that can be overwritten by a solver-specific version to accomodate for the quirks of each solver.

Definition at line 857 of file linear_solver.cc.

void operations_research::MPSolverInterface::CheckSolutionIsSynchronizedAndExists (  )  const [inline]

Handy shortcut to do both checks above (it is often used).

Definition at line 957 of file linear_solver.h.

void operations_research::MPSolverInterface::CheckBestObjectiveBoundExists (  )  const [virtual]

Checks whether information on the best objective bound exists.

Default version that can be overwritten by a solver-specific version to accomodate for the quirks of each solver.

Definition at line 865 of file linear_solver.cc.

virtual void operations_research::MPSolverInterface::WriteModel ( const string &  filename  )  [pure virtual]

Misc Writes model to a file.

virtual bool operations_research::MPSolverInterface::IsContinuous (  )  const [pure virtual]

Queries problem type.

For simplicity, the distinction between continuous and discrete is based on the declaration of the user when the solver is created (example: GLPK_LINEAR_PROGRAMMING vs. GLPK_MIXED_INTEGER_PROGRAMMING), not on the actual content of the model. Returns true if the problem is continuous.

virtual bool operations_research::MPSolverInterface::IsLP (  )  const [pure virtual]

Returns true if the problem is continuous and linear.

virtual bool operations_research::MPSolverInterface::IsMIP (  )  const [pure virtual]

Returns true if the problem is discrete and linear.

int operations_research::MPSolverInterface::last_variable_index (  )  const [inline]

Returns the index of the last variable extracted.

Definition at line 981 of file linear_solver.h.

bool operations_research::MPSolverInterface::quiet (  )  const [inline]

Returns the boolean indicating the verbosity of the solver output.

Definition at line 986 of file linear_solver.h.

void operations_research::MPSolverInterface::set_quiet ( bool  quiet_value  )  [inline]

Sets the boolean indicating the verbosity of the solver output.

Definition at line 990 of file linear_solver.h.

MPSolver::ResultStatus operations_research::MPSolverInterface::result_status (  )  const [inline]

Returns the result status of the last solve.

Definition at line 995 of file linear_solver.h.

virtual string operations_research::MPSolverInterface::SolverVersion (  )  const [pure virtual]

Returns a string describing the underlying solver and its version.

virtual void* operations_research::MPSolverInterface::underlying_solver (  )  [pure virtual]

Returns the underlying solver.

virtual double operations_research::MPSolverInterface::ComputeExactConditionNumber (  )  const [pure virtual]

Computes exact condition number.

Only available for continuous problems and only implemented in GLPK.

void operations_research::MPSolverInterface::WriteModelToPredefinedFiles (  )  [protected]

Writes out the model to a file specified by the --solver_write_model command line argument or MPSolver::set_write_model_filename.

The file is written by each solver interface (CBC, CLP, GLPK, SCIP) and each behaves a little differently. If filename ends in ".lp", then the file is written in the LP format (except for the CLP solver that does not support the LP format). In all other cases it is written in the MPS format.

Definition at line 793 of file linear_solver.cc.

void operations_research::MPSolverInterface::ExtractModel (  )  [protected]

Extracts model stored in MPSolver.

Definition at line 809 of file linear_solver.cc.

virtual void operations_research::MPSolverInterface::ExtractNewVariables (  )  [protected, pure virtual]

Extracts the variables that have not been extracted yet.

virtual void operations_research::MPSolverInterface::ExtractNewConstraints (  )  [protected, pure virtual]

Extracts the constraints that have not been extracted yet.

virtual void operations_research::MPSolverInterface::ExtractObjective (  )  [protected, pure virtual]

Extracts the objective.

void operations_research::MPSolverInterface::ResetExtractionInformation (  )  [protected]

Resets the extraction information.

Definition at line 836 of file linear_solver.cc.

void operations_research::MPSolverInterface::InvalidateSolutionSynchronization (  )  [protected]

Change synchronization status from SOLUTION_SYNCHRONIZED to MODEL_SYNCHRONIZED.

To be used for model changes.

Definition at line 876 of file linear_solver.cc.

void operations_research::MPSolverInterface::SetCommonParameters ( const MPSolverParameters param  )  [protected]

Sets parameters common to LP and MIP in the underlying solver.

Definition at line 882 of file linear_solver.cc.

void operations_research::MPSolverInterface::SetMIPParameters ( const MPSolverParameters param  )  [protected]

Sets MIP specific parameters in the underlying solver.

Definition at line 896 of file linear_solver.cc.

virtual void operations_research::MPSolverInterface::SetParameters ( const MPSolverParameters param  )  [protected, pure virtual]

Sets all parameters in the underlying solver.

void operations_research::MPSolverInterface::SetUnsupportedDoubleParam ( MPSolverParameters::DoubleParam  param  )  const [protected]

Sets an unsupported double parameter.

Definition at line 900 of file linear_solver.cc.

void operations_research::MPSolverInterface::SetUnsupportedIntegerParam ( MPSolverParameters::IntegerParam  param  )  const [protected]

Sets an unsupported integer parameter.

Definition at line 904 of file linear_solver.cc.

void operations_research::MPSolverInterface::SetDoubleParamToUnsupportedValue ( MPSolverParameters::DoubleParam  param,
int  value 
) const [protected]

Sets a supported double parameter to an unsupported value.

Definition at line 908 of file linear_solver.cc.

void operations_research::MPSolverInterface::SetIntegerParamToUnsupportedValue ( MPSolverParameters::IntegerParam  param,
double  value 
) const [protected]

Sets a supported integer parameter to an unsupported value.

Definition at line 913 of file linear_solver.cc.

virtual void operations_research::MPSolverInterface::SetRelativeMipGap ( double  value  )  [protected, pure virtual]

Sets each parameter in the underlying solver.

virtual void operations_research::MPSolverInterface::SetPrimalTolerance ( double  value  )  [protected, pure virtual]

virtual void operations_research::MPSolverInterface::SetDualTolerance ( double  value  )  [protected, pure virtual]

virtual void operations_research::MPSolverInterface::SetPresolveMode ( int  value  )  [protected, pure virtual]

virtual void operations_research::MPSolverInterface::SetLpAlgorithm ( int  value  )  [protected, pure virtual]


Friends And Related Function Documentation

friend class MPSolver [friend]

Definition at line 1010 of file linear_solver.h.

friend class MPObjective [friend]

To access the maximize_ bool.

See MPObjective::SetOptimizationDirection() in the .cc.

Definition at line 1014 of file linear_solver.h.


Member Data Documentation

When the underlying solver does not provide the number of simplex iterations.

Definition at line 876 of file linear_solver.h.

When the underlying solver does not provide the number of branch-and-bound nodes.

Definition at line 879 of file linear_solver.h.

When the index of a variable or constraint has not been assigned yet.

Definition at line 881 of file linear_solver.h.

Definition at line 1017 of file linear_solver.h.

Indicates whether the model and the solution are synchronized.

Definition at line 1019 of file linear_solver.h.

Indicates whether the solve has reached optimality, infeasibility, a limit, etc.

Definition at line 1022 of file linear_solver.h.

Optimization direction.

Definition at line 1024 of file linear_solver.h.

Index in MPSolver::variables_ of last constraint extracted.

Definition at line 1027 of file linear_solver.h.

Index in MPSolver::constraints_ of last variable extracted.

Definition at line 1029 of file linear_solver.h.

The value of the objective function.

Definition at line 1032 of file linear_solver.h.

Boolean indicator for the verbosity of the solver output.

Definition at line 1035 of file linear_solver.h.

Index of dummy variable created for empty constraints or the objective offset.

MPSolverInterface.

Definition at line 1039 of file linear_solver.h.


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