Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Private Member Functions | List of all members
CoinStructuredModel Class Reference

#include <CoinStructuredModel.hpp>

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

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. More...
 
int addBlock (const CoinBaseModel &block)
 add a block from a CoinModel with names in model returns number of errors (e.g. More...
 
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. More...
 
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 More...
 
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. More...
 
int readSmps (const char *filename, bool keepNames=false, bool ignoreErrors=false)
 Read SMPS model. More...
 
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. More...
 
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. More...
 
For getting information
int numberRowBlocks () const
 Return number of row blocks. More...
 
int numberColumnBlocks () const
 Return number of column blocks. More...
 
int numberElementBlocks () const
 Return number of elementBlocks. More...
 
CoinBigIndex numberElements () const
 Return number of elements. More...
 
const std::string & getRowBlock (int i) const
 Return the i'th row block name. More...
 
void setRowBlock (int i, const std::string &name)
 Set i'th row block name. More...
 
int addRowBlock (int numberRows, const std::string &name)
 Add or check a row block name and number of rows. More...
 
int rowBlock (const std::string &name) const
 Return a row block index given a row block name. More...
 
const std::string & getColumnBlock (int i) const
 Return i'th the column block name. More...
 
void setColumnBlock (int i, const std::string &name)
 Set i'th column block name. More...
 
int addColumnBlock (int numberColumns, const std::string &name)
 Add or check a column block name and number of columns. More...
 
int columnBlock (const std::string &name) const
 Return a column block index given a column block name. More...
 
const CoinModelBlockInfoblockType (int i) const
 Return i'th block type. More...
 
CoinBaseModelblock (int i) const
 Return i'th block. More...
 
const CoinBaseModelblock (int row, int column) const
 Return block corresponding to row and column. More...
 
CoinModelcoinBlock (int i) const
 Return i'th block as CoinModel (or NULL) More...
 
const CoinBaseModelcoinBlock (int row, int column) const
 Return block corresponding to row and column as CoinModel. More...
 
int blockIndex (int row, int column) const
 Return block number corresponding to row and column. More...
 
CoinModelcoinModelBlock (CoinModelBlockInfo &info)
 Return model as a CoinModel block and fill in info structure and update counts. More...
 
void setCoinModel (CoinModel *block, int iBlock)
 Sets given block into coinModelBlocks_. More...
 
void refresh (int iBlock)
 Refresh info in blockType_. More...
 
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. More...
 
double optimizationDirection () const
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
void setOptimizationDirection (double value)
 Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
Constructors, destructor
 CoinStructuredModel ()
 Default constructor. More...
 
 CoinStructuredModel (const char *fileName, int decompose=0, int maxBlocks=50)
 Read a problem in MPS format from the given filename. More...
 
virtual ~CoinStructuredModel ()
 Destructor. More...
 
Copy method
 CoinStructuredModel (const CoinStructuredModel &)
 The copy constructor. More...
 
CoinStructuredModeloperator= (const CoinStructuredModel &)
 = More...
 
virtual CoinBaseModelclone () const
 Clone. More...
 
- Public Member Functions inherited from CoinBaseModel
 CoinBaseModel ()
 Default Constructor. More...
 
 CoinBaseModel (const CoinBaseModel &rhs)
 Copy constructor. More...
 
CoinBaseModeloperator= (const CoinBaseModel &rhs)
 Assignment operator. More...
 
virtual ~CoinBaseModel ()
 Destructor. More...
 
int numberRows () const
 Return number of rows. More...
 
int numberColumns () const
 Return number of columns. More...
 
double objectiveOffset () const
 Returns the (constant) objective offset This is the RHS entry for the objective row. More...
 
void setObjectiveOffset (double value)
 Set objective offset. More...
 
double optimizationDirection () const
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
void setOptimizationDirection (double value)
 Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
int logLevel () const
 Get print level 0 - off, 1 - errors, 2 - more. More...
 
void setLogLevel (int value)
 Set print level 0 - off, 1 - errors, 2 - more. More...
 
const char * getProblemName () const
 Return the problem name. More...
 
void setProblemName (const char *name)
 Set problem name. More...
 
void setProblemName (const std::string &name)
 Set problem name. More...
 
const std::string & getRowBlock () const
 Return the row block name. More...
 
void setRowBlock (const std::string &name)
 Set row block name. More...
 
const std::string & getColumnBlock () const
 Return the column block name. More...
 
void setColumnBlock (const std::string &name)
 Set column block name. More...
 
void setMessageHandler (CoinMessageHandler *handler)
 Pass in message handler. More...
 

Private Member Functions

int fillInfo (CoinModelBlockInfo &info, const CoinModel *block)
 Fill in info structure and update counts Returns number of inconsistencies on border. More...
 
void fillInfo (CoinModelBlockInfo &info, const CoinStructuredModel *block)
 Fill in info structure and update counts. More...
 

Private Attributes

Data members
int numberRowBlocks_
 Current number of row blocks. More...
 
int numberColumnBlocks_
 Current number of column blocks. More...
 
int numberElementBlocks_
 Current number of element blocks. More...
 
int maximumElementBlocks_
 Maximum number of element blocks. More...
 
std::vector< std::string > rowBlockNames_
 Rowblock name. More...
 
std::vector< std::string > columnBlockNames_
 Columnblock name. More...
 
CoinBaseModel ** blocks_
 Blocks. More...
 
CoinModel ** coinModelBlocks_
 CoinModel copies of blocks or NULL if original CoinModel. More...
 
CoinModelBlockInfoblockType_
 Which parts of model are set in block. More...
 

Additional Inherited Members

- Protected Attributes inherited from CoinBaseModel
int numberRows_
 Current number of rows. More...
 
int numberColumns_
 Current number of columns. More...
 
double optimizationDirection_
 Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore. More...
 
double objectiveOffset_
 Objective offset to be passed on. More...
 
std::string problemName_
 Problem name. More...
 
std::string rowBlockName_
 Rowblock name. More...
 
std::string columnBlockName_
 Columnblock name. More...
 
CoinMessageHandlerhandler_
 Message handler (Passed in) More...
 
CoinMessages messages_
 Messages. More...
 
int logLevel_
 Print level. More...
 

Detailed Description

Definition at line 37 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
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::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 131 of file CoinStructuredModel.hpp.

int CoinStructuredModel::numberElementBlocks ( ) const
inline

Return number of elementBlocks.

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

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

Set i'th row block name.

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

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

Set i'th column block name.

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

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

Return i'th block.

Definition at line 176 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.

Definition at line 203 of file CoinStructuredModel.hpp.

void CoinStructuredModel::setOptimizationDirection ( double  value)
inline

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

Definition at line 208 of file CoinStructuredModel.hpp.

CoinStructuredModel& CoinStructuredModel::operator= ( const CoinStructuredModel )

=

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

int CoinStructuredModel::numberColumnBlocks_
private

Current number of column blocks.

Definition at line 250 of file CoinStructuredModel.hpp.

int CoinStructuredModel::numberElementBlocks_
private

Current number of element blocks.

Definition at line 252 of file CoinStructuredModel.hpp.

int CoinStructuredModel::maximumElementBlocks_
private

Maximum number of element blocks.

Definition at line 254 of file CoinStructuredModel.hpp.

std::vector< std::string > CoinStructuredModel::rowBlockNames_
private

Rowblock name.

Definition at line 256 of file CoinStructuredModel.hpp.

std::vector< std::string > CoinStructuredModel::columnBlockNames_
private

Columnblock name.

Definition at line 258 of file CoinStructuredModel.hpp.

CoinBaseModel** CoinStructuredModel::blocks_
private

Blocks.

Definition at line 260 of file CoinStructuredModel.hpp.

CoinModel** CoinStructuredModel::coinModelBlocks_
private

CoinModel copies of blocks or NULL if original CoinModel.

Definition at line 262 of file CoinStructuredModel.hpp.

CoinModelBlockInfo* CoinStructuredModel::blockType_
private

Which parts of model are set in block.

Definition at line 264 of file CoinStructuredModel.hpp.


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