bande::LinearProgram Class Reference

Encapsulation of a linear program. More...

#include <LinearProgram.hh>

Collaboration diagram for bande::LinearProgram:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LinearProgram ()
 Constructor.
virtual ~LinearProgram ()
 Destructor.
void readMps (const char *fileName)
 Read the problem instance from an MPS file.
void randomizeObjective ()
 Choose a random objective function.
void setColLower (UndoManager &um, int col, double val)
 Set lower bound of a column.
void setColUpper (UndoManager &um, int col, double val)
 Set upper bound of a column.
bool solve ()
 Find optimal solution to current linear program.
void dumpSolution (std::ostream &out=std::cerr) const
 Dump the current solution for debugging purposes.
int getNumRows () const
 Get the number of rows.
int getNumCols () const
 Get the number of columns.
double getColSolution (int index) const
 Get one variable of the solution.
double getColLower (int col) const
 Get the current lower bound of a column.
double getColUpper (int col) const
 Get the current upper bound of a column.
double getRowLower (int row) const
 Get the current lower bound of a row.
double getRowUpper (int row) const
 Get the current upper bound of a row.
std::string getColName (int col) const
 Get the name of a column.
std::string getRowName (int row) const
 Get the name of a row.
OsiSolverInterfacegetSolver ()
 Access to the wrapped solver interface.

Protected Attributes

OsiSolverInterfacesolver
 The wrapped solver interface.
int rows
 Number of rows.
int cols
 Number of columns.
std::vector< std::string > colNames
 Column names.
std::vector< std::string > rowNames
 Row names.
bool hasSolution
 Flag indicating a valid solution.
const double * solution
 Solution values.

Detailed Description

Encapsulation of a linear program.

In the current implementation, this class encapsulates an LP solver through the OsiSolverInterface. It extends that interface by methods to access the row and column names and by registering modifications with an UndoManager.

Definition at line 37 of file LinearProgram.hh.


Constructor & Destructor Documentation

bande::LinearProgram::LinearProgram (  ) 

Constructor.

The current implementation uses OsiClpSolverInterface as the backend behind this wrapper. The model will be uninitialized, waiting to be read by readMps().

Definition at line 37 of file LinearProgram.cc.

References cols, hasSolution, rows, and solver.


Member Function Documentation

void bande::LinearProgram::dumpSolution ( std::ostream &  out = std::cerr  )  const

Dump the current solution for debugging purposes.

Parameters:
out the output stream to which the solution will be dumped.

Definition at line 99 of file LinearProgram.cc.

References getColName(), getColSolution(), and getNumCols().

Referenced by bande::IntegerProgram::dumpSolution().

double bande::LinearProgram::getColLower ( int  col  )  const [inline]

Get the current lower bound of a column.

Parameters:
col the index of the column.
Returns:
the current lower bound of that column.

Definition at line 77 of file LinearProgram.hh.

References OsiSolverInterface::getColLower(), and solver.

Referenced by bande::IntegerProgram::readMps().

std::string bande::LinearProgram::getColName ( int  col  )  const [inline]

Get the name of a column.

This is also the name of the associated variable.

Parameters:
col the index of the column.
Returns:
the name of that column.

Definition at line 106 of file LinearProgram.hh.

References colNames.

Referenced by dumpSolution(), and bande::IntegerProgram::getColName().

double bande::LinearProgram::getColSolution ( int  index  )  const [inline]

Get one variable of the solution.

Parameters:
index the index of the variable.
Returns:
the value of that variable in the current solution.

Definition at line 70 of file LinearProgram.hh.

References solution.

Referenced by dumpSolution(), and bande::IntegerProgram::getColSolution().

double bande::LinearProgram::getColUpper ( int  col  )  const [inline]

Get the current upper bound of a column.

Parameters:
col the index of the column.
Returns:
the current upper bound of that column.

Definition at line 84 of file LinearProgram.hh.

References OsiSolverInterface::getColUpper(), and solver.

Referenced by bande::IntegerProgram::readMps().

int bande::LinearProgram::getNumCols (  )  const [inline]

Get the number of columns.

Each column corresponds to one variable of the solution.

Returns:
the number of columns in the problem.

Definition at line 63 of file LinearProgram.hh.

References cols.

Referenced by dumpSolution(), bande::IntegerProgram::getNumCols(), and randomizeObjective().

int bande::LinearProgram::getNumRows (  )  const [inline]

Get the number of rows.

Each row represents zero to two inequalities, depending on the row bounds.

Returns:
the number of rows in the problem.

Definition at line 56 of file LinearProgram.hh.

References rows.

Referenced by bande::IntegerProgram::getNumRows().

double bande::LinearProgram::getRowLower ( int  row  )  const [inline]

Get the current lower bound of a row.

Parameters:
row the intex of the row.
Returns:
the current lower bound of that row.

Definition at line 91 of file LinearProgram.hh.

References OsiSolverInterface::getRowLower(), and solver.

Referenced by bande::IntegerProgram::readMps().

std::string bande::LinearProgram::getRowName ( int  row  )  const [inline]

Get the name of a row.

Parameters:
row the index of the row.
Returns:
the name of that row.

Definition at line 113 of file LinearProgram.hh.

References rowNames.

Referenced by bande::IntegerProgram::getRowName().

double bande::LinearProgram::getRowUpper ( int  row  )  const [inline]

Get the current upper bound of a row.

Parameters:
row the index of the row.
Returns:
the current upper bound of that row.

Definition at line 98 of file LinearProgram.hh.

References OsiSolverInterface::getRowUpper(), and solver.

Referenced by bande::IntegerProgram::readMps().

OsiSolverInterface* bande::LinearProgram::getSolver (  )  [inline]

Access to the wrapped solver interface.

It is suggested that the returned object be used for read-only access, although this is not strictly required, as many methods of this wrapper simply call corresponding methods of the wrapped interface and thus will reflect changes. Notable Exceptions to this rules are the size of the matrix or the vector of solutions.

The returned pointer is the one used by this class, so it must not be deleted by the caller of this method.

Returns:
a pointer to the solver interface wrapped by this object.

Definition at line 131 of file LinearProgram.hh.

References solver.

Referenced by bande::IntegerProgram::readMps().

void bande::LinearProgram::randomizeObjective (  ) 

Choose a random objective function.

For enumeration purposes, the actual value of the objective function is irrelevant. However, a random objective function which most probably assigns different objective values to all feasible integral solutions will enhance numeric stability.

The implementation uses CoinDrand48() as randum number generator. As that generator is seeded to a fixed value in Settings::run(), consecutive runs of this program will yield the same results in the same order, making the process deterministic and any possible bugs reproducible.

Definition at line 152 of file LinearProgram.cc.

References CoinDrand48(), getNumCols(), OsiSolverInterface::setObjCoeff(), and solver.

Referenced by bande::IntegerProgram::randomizeObjective().

void bande::LinearProgram::readMps ( const char *  fileName  ) 

Read the problem instance from an MPS file.

If a different interface than OsiClpSolverInterface is used, then the file will be read twice, to provide names because access to names is not part of the generic OsiSolverInterface. In case of an error the program will exit with EXIT_FAILURE.

Parameters:
fileName the name of the file to be read in.

Definition at line 59 of file LinearProgram.cc.

References colNames, cols, OsiClpSolverInterface::getColName(), OsiSolverInterface::getNumCols(), OsiSolverInterface::getNumRows(), OsiClpSolverInterface::getRowName(), OsiSolverInterface::messageHandler(), OsiClpSolverInterface::readMps(), OsiSolverInterface::readMps(), rowNames, rows, CoinMessageHandler::setLogLevel(), and solver.

Referenced by bande::IntegerProgram::readMps().

void bande::LinearProgram::setColLower ( UndoManager um,
int  col,
double  val 
)

Set lower bound of a column.

This modification is registered with an undo manager so it can be rewound when switching to a different branch.

Parameters:
um the undo manager to track the modification.
col the index of the column to adjust.
val the new lower bound on the specified column.

Definition at line 118 of file LinearProgram.cc.

References OsiSolverInterface::getColLower(), bande::UndoManager::record(), OsiSolverInterface::setColLower(), and solver.

Referenced by bande::IntegerProgram::setColLower().

void bande::LinearProgram::setColUpper ( UndoManager um,
int  col,
double  val 
)

Set upper bound of a column.

This modification is registered with an undo manager so it can be rewound when switching to a different branch.

Parameters:
um the undo manager to track the modification.
col the index of the column to adjust.
val the new upper bound on the specified column.

Definition at line 132 of file LinearProgram.cc.

References OsiSolverInterface::getColUpper(), bande::UndoManager::record(), OsiSolverInterface::setColUpper(), and solver.

Referenced by bande::IntegerProgram::setColUpper().

bool bande::LinearProgram::solve (  ) 

Find optimal solution to current linear program.

Returns:
whether an optimal solution has been found.

Definition at line 86 of file LinearProgram.cc.

References OsiSolverInterface::getColSolution(), hasSolution, OsiSolverInterface::initialSolve(), OsiSolverInterface::isProvenOptimal(), OsiSolverInterface::resolve(), solution, and solver.

Referenced by bande::IntegerProgram::solve().


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

Generated on Fri Aug 21 08:17:19 2009 for bande by  doxygen 1.6.0