# CoinStructuredModel Class Reference

`#include <CoinStructuredModel.hpp>`

Inheritance diagram for CoinStructuredModel:
[legend]
Collaboration diagram for CoinStructuredModel:
[legend]

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 | readSmps (const char *filename, bool keepNames=false, bool ignoreErrors=false)
| Read SMPS model.
int | decompose (const CoinModel &model, int type, int maxBlocks=50, const char **starts=NULL)
| 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, int *starts=NULL, 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 CoinModelBlockInfo & | blockType (int i) const
| Return i'th block type.
CoinBaseModel * | block (int i) const
| Return i'th block.
const CoinBaseModel * | block (int row, int column) const
| Return block corresponding to row and column.
CoinModel * | coinBlock (int i) const
| Return i'th block as CoinModel (or NULL).
const CoinBaseModel * | coinBlock (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.
CoinModel * | coinModelBlock (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.
CoinStructuredModel & | operator= (const CoinStructuredModel &)
| =
virtual CoinBaseModel * | clone () const
| Clone.
## Private Member Functions
int | fillInfo (CoinModelBlockInfo &info, const CoinModel *block)
| Fill in info structure and update counts Returns number of inconsistencies on border.
void | fillInfo (CoinModelBlockInfo &info, const CoinStructuredModel *block)
| Fill in info structure and update counts.
## Private Attributes
Data members
int | numberRowBlocks_
| Current number of row blocks.
int | numberColumnBlocks_
| Current number of column blocks.
int | numberElementBlocks_
| Current number of element blocks.
int | maximumElementBlocks_
| Maximum number of element blocks.
std::vector< std::string > | rowBlockNames_
| Rowblock name.
std::vector< std::string > | columnBlockNames_
| Columnblock name.
CoinBaseModel ** | blocks_
| Blocks.
CoinModel ** | coinModelBlocks_
| CoinModel copies of blocks or NULL if original CoinModel.
CoinModelBlockInfo * | blockType_
| Which parts of model are set in block.

## Detailed Description

Definition at line 36 of file CoinStructuredModel.hpp.

## Constructor & Destructor Documentation

CoinStructuredModel::CoinStructuredModel | ( |  | ) |

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

virtual CoinStructuredModel::~CoinStructuredModel | ( |  | ) | `[virtual]`

Destructor.

CoinStructuredModel::CoinStructuredModel | ( | const CoinStructuredModel & |  | ) |

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)

int CoinStructuredModel::addBlock | ( | const CoinBaseModel & | block | ) |

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:

  | compression | can 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.
  | formatType | specifies the precision to used for values in the MPS file 0: normal precision (default) 1: extra accuracy 2: IEEE hex
  | numberAcross | specifies 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::readSmps | ( | const char * | filename,
|  | bool | keepNames = `false`,
|  | bool | ignoreErrors = `false` |
| ) |  |  |

Read SMPS model.

int CoinStructuredModel::decompose | ( | const CoinModel & | model,
|  | int | type,
|  | int | maxBlocks = `50`,
|  | const char ** | starts = `NULL` |
| ) |  |  |

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`,
|  | int * | starts = `NULL`,
|  | 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 126 of file CoinStructuredModel.hpp.

int CoinStructuredModel::numberColumnBlocks | ( |  | ) | const`[inline]`

Return number of column blocks.

Definition at line 129 of file CoinStructuredModel.hpp.

CoinBigIndex CoinStructuredModel::numberElementBlocks | ( |  | ) | const`[inline]`

Return number of elementBlocks.

Definition at line 132 of file CoinStructuredModel.hpp.

CoinBigIndex CoinStructuredModel::numberElements | ( |  | ) | const`[virtual]`

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 137 of file CoinStructuredModel.hpp.

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

Set i'th row block name.

Definition at line 140 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 147 of file CoinStructuredModel.hpp.

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

Set i'th column block name.

Definition at line 150 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 157 of file CoinStructuredModel.hpp.

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

Return i'th block.

Definition at line 160 of file CoinStructuredModel.hpp.

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

Return block corresponding to row and column.

CoinModel* CoinStructuredModel::coinBlock | ( | int | i | ) | const

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.

CoinModel* CoinStructuredModel::coinModelBlock | ( | CoinModelBlockInfo & | info | ) |

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_.

void CoinStructuredModel::refresh | ( | int | iBlock | ) |

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 185 of file CoinStructuredModel.hpp.

void CoinStructuredModel::setOptimizationDirection | ( | double | value | ) | `[inline]`

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

Reimplemented from CoinBaseModel.

Definition at line 189 of file CoinStructuredModel.hpp.

CoinStructuredModel& CoinStructuredModel::operator= | ( | const CoinStructuredModel & |  | ) |

=

Reimplemented from CoinBaseModel.

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

Clone.

Implements CoinBaseModel.

int CoinStructuredModel::fillInfo | ( | CoinModelBlockInfo & | info,
|  | const CoinModel * | block |
| ) |  |  | `[private]`

Fill in info structure and update counts Returns number of inconsistencies on border.

void CoinStructuredModel::fillInfo | ( | CoinModelBlockInfo & | info,
|  | const CoinStructuredModel * | block |
| ) |  |  | `[private]`

Fill in info structure and update counts.

## Member Data Documentation

int CoinStructuredModel::numberRowBlocks_`[private]`

Current number of row blocks.

Definition at line 228 of file CoinStructuredModel.hpp.

int CoinStructuredModel::numberColumnBlocks_`[private]`

Current number of column blocks.

Definition at line 230 of file CoinStructuredModel.hpp.

int CoinStructuredModel::numberElementBlocks_`[private]`

Current number of element blocks.

Definition at line 232 of file CoinStructuredModel.hpp.

int CoinStructuredModel::maximumElementBlocks_`[private]`

Maximum number of element blocks.

Definition at line 234 of file CoinStructuredModel.hpp.

std::vector<std::string> CoinStructuredModel::rowBlockNames_`[private]`

Rowblock name.

Definition at line 236 of file CoinStructuredModel.hpp.

std::vector<std::string> CoinStructuredModel::columnBlockNames_`[private]`

Columnblock name.

Definition at line 238 of file CoinStructuredModel.hpp.

CoinBaseModel** CoinStructuredModel::blocks_`[private]`

Blocks.

Definition at line 240 of file CoinStructuredModel.hpp.

CoinModel** CoinStructuredModel::coinModelBlocks_`[private]`

CoinModel copies of blocks or NULL if original CoinModel.

Definition at line 242 of file CoinStructuredModel.hpp.

CoinModelBlockInfo* CoinStructuredModel::blockType_`[private]`

Which parts of model are set in block.

Definition at line 244 of file CoinStructuredModel.hpp.

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

- /home/coin/svn-release/Osi-0.107.5/CoinUtils/src/CoinStructuredModel.hpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines