CoinUtils  trunk
CoinStructuredModel Class Reference

#include <CoinStructuredModel.hpp>

+ Inheritance diagram for CoinStructuredModel:
+ Collaboration diagram for CoinStructuredModel:

List of all members.

Public Member Functions

Useful methods for building model
int addBlock (const std::string &rowBlock, const std::string &columnBlock, const CoinBaseModel &block)
 add a block from a CoinModel using names given as parameters returns number of errors (e.g.
int addBlock (const CoinBaseModel &block)
 add a block from a CoinModel with names in model returns number of errors (e.g.
int addBlock (const std::string &rowBlock, const std::string &columnBlock, CoinBaseModel *block)
 add a block from a CoinModel using names given as parameters returns number of errors (e.g.
int addBlock (const std::string &rowBlock, const std::string &columnBlock, const CoinPackedMatrix &matrix, const double *rowLower, const double *rowUpper, const double *columnLower, const double *columnUpper, const double *objective)
 add a block using names
int writeMps (const char *filename, int compression=0, int formatType=0, int numberAcross=2, bool keepStrings=false)
 Write the problem in MPS format to a file with the given filename.
int decompose (const CoinModel &model, int type, int maxBlocks=50)
 Decompose a CoinModel 1 - try D-W 2 - try Benders 3 - try Staircase Returns number of blocks or zero if no structure.
int decompose (const CoinPackedMatrix &matrix, const double *rowLower, const double *rowUpper, const double *columnLower, const double *columnUpper, const double *objective, int type, int maxBlocks=50, double objectiveOffset=0.0)
 Decompose a model specified as arrays + CoinPackedMatrix 1 - try D-W 2 - try Benders 3 - try Staircase Returns number of blocks or zero if no structure.
For getting information
int numberRowBlocks () const
 Return number of row blocks.
int numberColumnBlocks () const
 Return number of column blocks.
CoinBigIndex numberElementBlocks () const
 Return number of elementBlocks.
CoinBigIndex numberElements () const
 Return number of elements.
const std::string & getRowBlock (int i) const
 Return the i'th row block name.
void setRowBlock (int i, const std::string &name)
 Set i'th row block name.
int addRowBlock (int numberRows, const std::string &name)
 Add or check a row block name and number of rows.
int rowBlock (const std::string &name) const
 Return a row block index given a row block name.
const std::string & getColumnBlock (int i) const
 Return i'th the column block name.
void setColumnBlock (int i, const std::string &name)
 Set i'th column block name.
int addColumnBlock (int numberColumns, const std::string &name)
 Add or check a column block name and number of columns.
int columnBlock (const std::string &name) const
 Return a column block index given a column block name.
const CoinModelBlockInfoblockType (int i) const
 Return i'th block type.
CoinBaseModelblock (int i) const
 Return i'th block.
const CoinBaseModelblock (int row, int column) const
 Return block corresponding to row and column.
CoinModelcoinBlock (int i) const
 Return i'th block as CoinModel (or NULL)
const CoinBaseModelcoinBlock (int row, int column) const
 Return block corresponding to row and column as CoinModel.
int blockIndex (int row, int column) const
 Return block number corresponding to row and column.
CoinModelcoinModelBlock (CoinModelBlockInfo &info)
 Return model as a CoinModel block and fill in info structure and update counts.
void setCoinModel (CoinModel *block, int iBlock)
 Sets given block into coinModelBlocks_.
void refresh (int iBlock)
 Refresh info in blockType_.
CoinModelBlockInfo block (int row, int column, const double *&rowLower, const double *&rowUpper, const double *&columnLower, const double *&columnUpper, const double *&objective) const
 Fill pointers corresponding to row and column.
double optimizationDirection () const
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
void setOptimizationDirection (double value)
 Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Constructors, destructor
 CoinStructuredModel ()
 Default constructor.
 CoinStructuredModel (const char *fileName, int decompose=0, int maxBlocks=50)
 Read a problem in MPS format from the given filename.
virtual ~CoinStructuredModel ()
 Destructor.
Copy method
 CoinStructuredModel (const CoinStructuredModel &)
 The copy constructor.
CoinStructuredModeloperator= (const CoinStructuredModel &)
 =
virtual CoinBaseModelclone () const
 Clone.

Detailed Description

Definition at line 36 of file CoinStructuredModel.hpp.


Constructor & Destructor Documentation

Default constructor.

CoinStructuredModel::CoinStructuredModel ( const char *  fileName,
int  decompose = 0,
int  maxBlocks = 50 
)

Read a problem in MPS format from the given filename.

May try and decompose

Destructor.

The copy constructor.


Member Function Documentation

int CoinStructuredModel::addBlock ( const std::string &  rowBlock,
const std::string &  columnBlock,
const CoinBaseModel block 
)

add a block from a CoinModel using names given as parameters returns number of errors (e.g.

both have objectives but not same)

add a block from a CoinModel with names in model returns number of errors (e.g.

both have objectives but not same)

int CoinStructuredModel::addBlock ( const std::string &  rowBlock,
const std::string &  columnBlock,
CoinBaseModel block 
)

add a block from a CoinModel using names given as parameters returns number of errors (e.g.

both have objectives but not same) This passes in block - structured model takes ownership

int CoinStructuredModel::addBlock ( const std::string &  rowBlock,
const std::string &  columnBlock,
const CoinPackedMatrix matrix,
const double *  rowLower,
const double *  rowUpper,
const double *  columnLower,
const double *  columnUpper,
const double *  objective 
)

add a block using names

int CoinStructuredModel::writeMps ( const char *  filename,
int  compression = 0,
int  formatType = 0,
int  numberAcross = 2,
bool  keepStrings = false 
)

Write the problem in MPS format to a file with the given filename.

Parameters:
compressioncan be set to three values to indicate what kind of file should be written
  • 0: plain text (default)
  • 1: gzip compressed (.gz is appended to filename)
  • 2: bzip2 compressed (.bz2 is appended to filename) (TODO)
If the library was not compiled with the requested compression then writeMps falls back to writing a plain text file.
formatTypespecifies the precision to used for values in the MPS file
  • 0: normal precision (default)
  • 1: extra accuracy
  • 2: IEEE hex
numberAcrossspecifies whether 1 or 2 (default) values should be specified on every data line in the MPS file.

not const as may change model e.g. fill in default bounds

int CoinStructuredModel::decompose ( const CoinModel model,
int  type,
int  maxBlocks = 50 
)

Decompose a CoinModel 1 - try D-W 2 - try Benders 3 - try Staircase Returns number of blocks or zero if no structure.

int CoinStructuredModel::decompose ( const CoinPackedMatrix matrix,
const double *  rowLower,
const double *  rowUpper,
const double *  columnLower,
const double *  columnUpper,
const double *  objective,
int  type,
int  maxBlocks = 50,
double  objectiveOffset = 0.0 
)

Decompose a model specified as arrays + CoinPackedMatrix 1 - try D-W 2 - try Benders 3 - try Staircase Returns number of blocks or zero if no structure.

int CoinStructuredModel::numberRowBlocks ( ) const [inline]

Return number of row blocks.

Definition at line 120 of file CoinStructuredModel.hpp.

Return number of column blocks.

Definition at line 123 of file CoinStructuredModel.hpp.

Return number of elementBlocks.

Definition at line 126 of file CoinStructuredModel.hpp.

Return number of elements.

Implements CoinBaseModel.

const std::string& CoinStructuredModel::getRowBlock ( int  i) const [inline]

Return the i'th row block name.

Definition at line 131 of file CoinStructuredModel.hpp.

void CoinStructuredModel::setRowBlock ( int  i,
const std::string &  name 
) [inline]

Set i'th row block name.

Definition at line 134 of file CoinStructuredModel.hpp.

int CoinStructuredModel::addRowBlock ( int  numberRows,
const std::string &  name 
)

Add or check a row block name and number of rows.

int CoinStructuredModel::rowBlock ( const std::string &  name) const

Return a row block index given a row block name.

const std::string& CoinStructuredModel::getColumnBlock ( int  i) const [inline]

Return i'th the column block name.

Definition at line 141 of file CoinStructuredModel.hpp.

void CoinStructuredModel::setColumnBlock ( int  i,
const std::string &  name 
) [inline]

Set i'th column block name.

Definition at line 144 of file CoinStructuredModel.hpp.

int CoinStructuredModel::addColumnBlock ( int  numberColumns,
const std::string &  name 
)

Add or check a column block name and number of columns.

int CoinStructuredModel::columnBlock ( const std::string &  name) const

Return a column block index given a column block name.

const CoinModelBlockInfo& CoinStructuredModel::blockType ( int  i) const [inline]

Return i'th block type.

Definition at line 151 of file CoinStructuredModel.hpp.

CoinBaseModel* CoinStructuredModel::block ( int  i) const [inline]

Return i'th block.

Definition at line 154 of file CoinStructuredModel.hpp.

const CoinBaseModel* CoinStructuredModel::block ( int  row,
int  column 
) const

Return block corresponding to row and column.

Return i'th block as CoinModel (or NULL)

const CoinBaseModel* CoinStructuredModel::coinBlock ( int  row,
int  column 
) const

Return block corresponding to row and column as CoinModel.

int CoinStructuredModel::blockIndex ( int  row,
int  column 
) const

Return block number corresponding to row and column.

Return model as a CoinModel block and fill in info structure and update counts.

void CoinStructuredModel::setCoinModel ( CoinModel block,
int  iBlock 
)

Sets given block into coinModelBlocks_.

Refresh info in blockType_.

CoinModelBlockInfo CoinStructuredModel::block ( int  row,
int  column,
const double *&  rowLower,
const double *&  rowUpper,
const double *&  columnLower,
const double *&  columnUpper,
const double *&  objective 
) const

Fill pointers corresponding to row and column.

double CoinStructuredModel::optimizationDirection ( ) const [inline]

Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.

Reimplemented from CoinBaseModel.

Definition at line 179 of file CoinStructuredModel.hpp.

Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.

Reimplemented from CoinBaseModel.

Definition at line 183 of file CoinStructuredModel.hpp.

CoinStructuredModel& CoinStructuredModel::operator= ( const CoinStructuredModel )

=

virtual CoinBaseModel* CoinStructuredModel::clone ( ) const [virtual]

Clone.

Implements CoinBaseModel.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines