Osi  0.108.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
OsiPresolve Class Reference

OSI interface to COIN problem simplification capabilities. More...

#include <OsiPresolve.hpp>

+ Collaboration diagram for OsiPresolve:

Public Member Functions

 OsiPresolve ()
 Default constructor (empty object) More...
 
virtual ~OsiPresolve ()
 Virtual destructor. More...
 
virtual OsiSolverInterfacepresolvedModel (OsiSolverInterface &origModel, double feasibilityTolerance=0.0, bool keepIntegers=true, int numberPasses=5, const char *prohibited=NULL, bool doStatus=true, const char *rowProhibited=NULL)
 Create a new OsiSolverInterface loaded with the presolved problem. More...
 
virtual void postsolve (bool updateStatus=true)
 Restate the solution to the presolved problem in terms of the original problem and load it into the original model. More...
 
OsiSolverInterfacemodel () const
 Return a pointer to the presolved model. More...
 
OsiSolverInterfaceoriginalModel () const
 Return a pointer to the original model. More...
 
void setOriginalModel (OsiSolverInterface *model)
 Set the pointer to the original model. More...
 
const int * originalColumns () const
 Return a pointer to the original columns. More...
 
const int * originalRows () const
 Return a pointer to the original rows. More...
 
int getNumRows () const
 Return number of rows in original model. More...
 
int getNumCols () const
 Return number of columns in original model. More...
 
void setNonLinearValue (double value)
 "Magic" number. More...
 
double nonLinearValue () const
 
void setPresolveActions (int action)
 Fine control over presolve actions. More...
 
OsiSolverInterfacepresolvedModel () const
 Get presolved model. More...
 
void setPresolvedModel (OsiSolverInterface *presolvedModel)
 Set presolved model. More...
 

Protected Member Functions

virtual const CoinPresolveActionpresolve (CoinPresolveMatrix *prob)
 Apply presolve transformations to the problem. More...
 
virtual void postsolve (CoinPostsolveMatrix &prob)
 Reverse presolve transformations to recover the solution to the original problem. More...
 
void gutsOfDestroy ()
 Destroys queued postsolve actions. More...
 

Private Attributes

OsiSolverInterfaceoriginalModel_
 Original model (solver interface loaded with the original problem). More...
 
OsiSolverInterfacepresolvedModel_
 Presolved model (solver interface loaded with the presolved problem) More...
 
double nonLinearValue_
 "Magic" number. More...
 
int * originalColumn_
 Original column numbers. More...
 
int * originalRow_
 Original row numbers. More...
 
const CoinPresolveActionpaction_
 The list of transformations applied. More...
 
int ncols_
 Number of columns in original model. More...
 
int nrows_
 Number of rows in original model. More...
 
CoinBigIndex nelems_
 Number of nonzero matrix coefficients in the original model. More...
 
int presolveActions_
 Whether we want to skip dual part of presolve etc. More...
 
int numberPasses_
 Number of major passes. More...
 

Detailed Description

OSI interface to COIN problem simplification capabilities.

COIN provides a number of classes which implement problem simplification algorithms (CoinPresolveAction, CoinPrePostsolveMatrix, and derived classes). The model of operation is as follows:

The COIN presolve algorithms are unaware of OSI. The OsiPresolve class takes care of the interface. Given an OsiSolverInterface origModel, it will take care of creating a clone properly loaded with the presolved problem and ready for optimization. After optimization, it will apply postsolve transformations and load the result back into origModel.

Assuming a problem has been loaded into an OsiSolverInterface origModel, a bare-bones application looks like this:

OsiPresolve pinfo ;
// Return an OsiSolverInterface loaded with the presolved problem.
presolvedModel = pinfo.presolvedModel(*origModel,1.0e-8,false,numberPasses) ;
presolvedModel->initialSolve() ;
// Restate the solution and load it back into origModel.
pinfo.postsolve(true) ;

Definition at line 59 of file OsiPresolve.hpp.

Constructor & Destructor Documentation

OsiPresolve::OsiPresolve ( )

Default constructor (empty object)

virtual OsiPresolve::~OsiPresolve ( )
virtual

Virtual destructor.

Member Function Documentation

virtual OsiSolverInterface* OsiPresolve::presolvedModel ( OsiSolverInterface origModel,
double  feasibilityTolerance = 0.0,
bool  keepIntegers = true,
int  numberPasses = 5,
const char *  prohibited = NULL,
bool  doStatus = true,
const char *  rowProhibited = NULL 
)
virtual

Create a new OsiSolverInterface loaded with the presolved problem.

This method implements the first two steps described in the class documentation. It clones origModel and applies presolve transformations, storing the resulting list of postsolve transformations. It returns a pointer to a new OsiSolverInterface loaded with the presolved problem, or NULL if the problem is infeasible or unbounded. If keepIntegers is true then bounds may be tightened in the original. Bounds will be moved by up to feasibilityTolerance to try and stay feasible. When doStatus is true, the current solution will be transformed to match the presolved model.

This should be paired with postsolve(). It is up to the client to destroy the returned OsiSolverInterface, after calling postsolve().

This method is virtual. Override this method if you need to customize the steps of creating a model to apply presolve transformations.

In some sense, a wrapper for presolve(CoinPresolveMatrix*).

virtual void OsiPresolve::postsolve ( bool  updateStatus = true)
virtual

Restate the solution to the presolved problem in terms of the original problem and load it into the original model.

postsolve() restates the solution in terms of the original problem and updates the original OsiSolverInterface supplied to presolvedModel(). If the problem has not been solved to optimality, there are no guarantees. If you are using an algorithm like simplex that has a concept of a basic solution, then set updateStatus

The advantage of going back to the original problem is that it will be exactly as it was, i.e., 0.0 will not become 1.0e-19.

Note that if you modified the original problem after presolving, then you must ``undo'' these modifications before calling postsolve().

In some sense, a wrapper for postsolve(CoinPostsolveMatrix&).

OsiSolverInterface* OsiPresolve::model ( ) const

Return a pointer to the presolved model.

OsiSolverInterface* OsiPresolve::originalModel ( ) const

Return a pointer to the original model.

void OsiPresolve::setOriginalModel ( OsiSolverInterface model)

Set the pointer to the original model.

const int* OsiPresolve::originalColumns ( ) const

Return a pointer to the original columns.

const int* OsiPresolve::originalRows ( ) const

Return a pointer to the original rows.

int OsiPresolve::getNumRows ( ) const
inline

Return number of rows in original model.

Definition at line 130 of file OsiPresolve.hpp.

int OsiPresolve::getNumCols ( ) const
inline

Return number of columns in original model.

Definition at line 136 of file OsiPresolve.hpp.

void OsiPresolve::setNonLinearValue ( double  value)
inline

"Magic" number.

If this is non-zero then any elements with this value may change and so presolve is very limited in what can be done to the row and column. This is for non-linear problems.

Definition at line 145 of file OsiPresolve.hpp.

double OsiPresolve::nonLinearValue ( ) const
inline

Definition at line 149 of file OsiPresolve.hpp.

void OsiPresolve::setPresolveActions ( int  action)
inline

Fine control over presolve actions.

Set/clear the following bits to allow or suppress actions:

  • 0x01 allow duplicate column processing on integer columns and dual stuff on integers
  • 0x02 switch off actions which can change +1 to something else (doubleton, tripleton, implied free)
  • 0x04 allow transfer of costs from singletons and between integer variables (when advantageous)
  • 0x08 do not allow x+y+z=1 transform
  • 0x10 allow actions that don't easily unroll
  • 0x20 allow dubious gub element reduction

GUB element reduction is only partially implemented in CoinPresolve (see gubrow_action) and willl cause an abort at postsolve. It's not clear what's meant by `dual stuff on integers'. – lh, 110605 –

Definition at line 171 of file OsiPresolve.hpp.

OsiSolverInterface* OsiPresolve::presolvedModel ( ) const
inline

Get presolved model.

Definition at line 176 of file OsiPresolve.hpp.

void OsiPresolve::setPresolvedModel ( OsiSolverInterface presolvedModel)
inline

Set presolved model.

Definition at line 181 of file OsiPresolve.hpp.

virtual const CoinPresolveAction* OsiPresolve::presolve ( CoinPresolveMatrix prob)
protectedvirtual

Apply presolve transformations to the problem.

Handles the core activity of applying presolve transformations.

If you want to apply the individual presolve routines differently, or perhaps add your own to the mix, define a derived class and override this method

virtual void OsiPresolve::postsolve ( CoinPostsolveMatrix prob)
protectedvirtual

Reverse presolve transformations to recover the solution to the original problem.

Handles the core activity of applying postsolve transformations.

Postsolving is pretty generic; just apply the transformations in reverse order. You will probably only be interested in overriding this method if you want to add code to test for consistency while debugging new presolve techniques.

void OsiPresolve::gutsOfDestroy ( )
protected

Destroys queued postsolve actions.

E.g., when presolve() determines the problem is infeasible, so that it will not be necessary to actually solve the presolved problem and convert the result back to the original problem.

Member Data Documentation

OsiSolverInterface* OsiPresolve::originalModel_
private

Original model (solver interface loaded with the original problem).

Must not be destroyed until after postsolve().

Definition at line 191 of file OsiPresolve.hpp.

OsiSolverInterface* OsiPresolve::presolvedModel_
private

Presolved model (solver interface loaded with the presolved problem)

Must be destroyed by the client (using delete) after postsolve().

Definition at line 197 of file OsiPresolve.hpp.

double OsiPresolve::nonLinearValue_
private

"Magic" number.

If this is non-zero then any elements with this value may change and so presolve is very limited in what can be done to the row and column. This is for non-linear problems. One could also allow for cases where sign of coefficient is known.

Definition at line 204 of file OsiPresolve.hpp.

int* OsiPresolve::originalColumn_
private

Original column numbers.

Definition at line 207 of file OsiPresolve.hpp.

int* OsiPresolve::originalRow_
private

Original row numbers.

Definition at line 210 of file OsiPresolve.hpp.

const CoinPresolveAction* OsiPresolve::paction_
private

The list of transformations applied.

Definition at line 213 of file OsiPresolve.hpp.

int OsiPresolve::ncols_
private

Number of columns in original model.

The problem will expand back to its former size as postsolve transformations are applied. It is efficient to allocate data structures for the final size of the problem rather than expand them as needed.

Definition at line 221 of file OsiPresolve.hpp.

int OsiPresolve::nrows_
private

Number of rows in original model.

Definition at line 224 of file OsiPresolve.hpp.

CoinBigIndex OsiPresolve::nelems_
private

Number of nonzero matrix coefficients in the original model.

Definition at line 227 of file OsiPresolve.hpp.

int OsiPresolve::presolveActions_
private

Whether we want to skip dual part of presolve etc.

1 bit allows duplicate column processing on integer columns and dual stuff on integers 4 transfers costs to integer variables

Definition at line 234 of file OsiPresolve.hpp.

int OsiPresolve::numberPasses_
private

Number of major passes.

Definition at line 236 of file OsiPresolve.hpp.


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