Clp 1.17.6

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinStructuredModel.hpp
Go to the documentation of this file.
1 /* $Id: CoinStructuredModel.hpp 2083 2019-01-06 19:38:09Z unxusr $ */
2 // Copyright (C) 2008, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5
6 #ifndef CoinStructuredModel_H
7 #define CoinStructuredModel_H
8
9 #include "CoinModel.hpp"
10 #include <vector>
11
15 typedef struct CoinModelInfo2 {
16 int rowBlock; // Which row block
17 int columnBlock; // Which column block
18 char matrix; // nonzero if matrix exists
19 char rhs; // nonzero if non default rhs exists
20 char rowName; // nonzero if row names exists
21 char integer; // nonzero if integer information exists
22 char bounds; // nonzero if non default bounds/objective exists
23 char columnName; // nonzero if column names exists
24 CoinModelInfo2()
25 : rowBlock(0)
26 , columnBlock(0)
27 , matrix(0)
28 , rhs(0)
29 , rowName(0)
30 , integer(0)
31 , bounds(0)
32 , columnName(0)
33 {
34 }
35 } CoinModelBlockInfo;
36
37 class CoinStructuredModel : public CoinBaseModel {
38
39 public:
45 int addBlock(const std::string &rowBlock,
46 const std::string &columnBlock,
47 const CoinBaseModel &block);
51 int addBlock(const CoinBaseModel &block);
56 int addBlock(const std::string &rowBlock,
57 const std::string &columnBlock,
58 CoinBaseModel *block);
61 int addBlock(const std::string &rowBlock,
62 const std::string &columnBlock,
63 const CoinPackedMatrix &matrix,
64 const double *rowLower, const double *rowUpper,
65 const double *columnLower, const double *columnUpper,
66 const double *objective);
67
93 int writeMps(const char *filename, int compression = 0,
94 int formatType = 0, int numberAcross = 2, bool keepStrings = false);
96 int readSmps(const char *filename,
97 bool keepNames = false,
98 bool ignoreErrors = false);
99
106 int decompose(const CoinModel &model, int type,
107 int maxBlocks = 50, const char **starts = NULL);
114 int decompose(const CoinPackedMatrix &matrix,
115 const double *rowLower, const double *rowUpper,
116 const double *columnLower, const double *columnUpper,
117 const double *objective, int type, int maxBlocks = 50,
118 int *starts = NULL,
119 double objectiveOffset = 0.0);
120
122
125 inline int numberRowBlocks() const
127 {
128 return numberRowBlocks_;
129 }
131 inline int numberColumnBlocks() const
132 {
133 return numberColumnBlocks_;
134 }
136 inline int numberElementBlocks() const
137 {
138 return numberElementBlocks_;
139 }
141 CoinBigIndex numberElements() const;
143 inline const std::string &getRowBlock(int i) const
144 {
145 return rowBlockNames_[i];
146 }
148 inline void setRowBlock(int i, const std::string &name)
149 {
150 rowBlockNames_[i] = name;
151 }
153 int addRowBlock(int numberRows, const std::string &name);
155 int rowBlock(const std::string &name) const;
157 inline const std::string &getColumnBlock(int i) const
158 {
159 return columnBlockNames_[i];
160 }
162 inline void setColumnBlock(int i, const std::string &name)
163 {
164 columnBlockNames_[i] = name;
165 }
167 int addColumnBlock(int numberColumns, const std::string &name);
169 int columnBlock(const std::string &name) const;
171 inline const CoinModelBlockInfo &blockType(int i) const
172 {
173 return blockType_[i];
174 }
176 inline CoinBaseModel *block(int i) const
177 {
178 return blocks_[i];
179 }
181 const CoinBaseModel *block(int row, int column) const;
183 CoinModel *coinBlock(int i) const;
185 const CoinBaseModel *coinBlock(int row, int column) const;
187 int blockIndex(int row, int column) const;
191 CoinModel *coinModelBlock(CoinModelBlockInfo &info);
193 void setCoinModel(CoinModel *block, int iBlock);
195 void refresh(int iBlock);
198 CoinModelBlockInfo block(int row, int column,
199 const double *&rowLower, const double *&rowUpper,
200 const double *&columnLower, const double *&columnUpper,
201 const double *&objective) const;
203 inline double optimizationDirection() const
204 {
205 return optimizationDirection_;
206 }
208 inline void setOptimizationDirection(double value)
209 {
210 optimizationDirection_ = value;
211 }
213
217 CoinStructuredModel();
221 CoinStructuredModel(const char *fileName, int decompose = 0,
222 int maxBlocks = 50);
224 virtual ~CoinStructuredModel();
226
230 CoinStructuredModel(const CoinStructuredModel &);
232 CoinStructuredModel &operator=(const CoinStructuredModel &);
234 virtual CoinBaseModel *clone() const;
236
237 private:
241 int fillInfo(CoinModelBlockInfo &info, const CoinModel *block);
244 void fillInfo(CoinModelBlockInfo &info, const CoinStructuredModel *block);
247 int numberRowBlocks_;
250 int numberColumnBlocks_;
252 int numberElementBlocks_;
254 int maximumElementBlocks_;
256 std::vector< std::string > rowBlockNames_;
258 std::vector< std::string > columnBlockNames_;
260 CoinBaseModel **blocks_;
262 CoinModel **coinModelBlocks_;
264 CoinModelBlockInfo *blockType_;
266 };
267 #endif
268
269 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
270 */
CoinStructuredModel::refresh
void refresh(int iBlock)
Refresh info in blockType_.
CoinStructuredModel::numberElementBlocks
int numberElementBlocks() const
Return number of elementBlocks.
Definition: CoinStructuredModel.hpp:136
CoinModelInfo2
This is a model which is made up of Coin(Structured)Model blocks.
Definition: CoinStructuredModel.hpp:15
CoinStructuredModel::blockType
const CoinModelBlockInfo & blockType(int i) const
Return i&#39;th block type.
Definition: CoinStructuredModel.hpp:171
CoinBaseModel::optimizationDirection_
double optimizationDirection_
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinModel.hpp:118
CoinStructuredModel::numberElementBlocks_
int numberElementBlocks_
Current number of element blocks.
Definition: CoinStructuredModel.hpp:252
CoinStructuredModel::~CoinStructuredModel
virtual ~CoinStructuredModel()
Destructor.
CoinModelInfo2::matrix
char matrix
Definition: CoinStructuredModel.hpp:18
CoinStructuredModel::block
CoinBaseModel * block(int i) const
Return i&#39;th block.
Definition: CoinStructuredModel.hpp:176
CoinModelInfo2::columnBlock
int columnBlock
Definition: CoinStructuredModel.hpp:17
CoinStructuredModel::fillInfo
int fillInfo(CoinModelBlockInfo &info, const CoinModel *block)
Fill in info structure and update counts Returns number of inconsistencies on border.
CoinStructuredModel::blocks_
CoinBaseModel ** blocks_
Blocks.
Definition: CoinStructuredModel.hpp:260
CoinModelInfo2::rhs
char rhs
Definition: CoinStructuredModel.hpp:19
CoinStructuredModel::clone
virtual CoinBaseModel * clone() const
Clone.
CoinModel
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
Definition: CoinModel.hpp:181
CoinStructuredModel::operator=
CoinStructuredModel & operator=(const CoinStructuredModel &)
=
CoinStructuredModel::blockType_
CoinModelBlockInfo * blockType_
Which parts of model are set in block.
Definition: CoinStructuredModel.hpp:264
CoinBaseModel
Definition: CoinModel.hpp:13
CoinStructuredModel::maximumElementBlocks_
int maximumElementBlocks_
Maximum number of element blocks.
Definition: CoinStructuredModel.hpp:254
CoinStructuredModel::coinBlock
CoinModel * coinBlock(int i) const
Return i&#39;th block as CoinModel (or NULL)
CoinStructuredModel::setCoinModel
void setCoinModel(CoinModel *block, int iBlock)
Sets given block into coinModelBlocks_.
CoinModelInfo2::bounds
char bounds
Definition: CoinStructuredModel.hpp:22
CoinStructuredModel
Definition: CoinStructuredModel.hpp:37
CoinModelBlockInfo
struct CoinModelInfo2 CoinModelBlockInfo
This is a model which is made up of Coin(Structured)Model blocks.
CoinStructuredModel::columnBlock
int columnBlock(const std::string &name) const
Return a column block index given a column block name.
CoinBaseModel::numberColumns
int numberColumns() const
Return number of columns.
Definition: CoinModel.hpp:42
CoinStructuredModel::decompose
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 ...
CoinStructuredModel::addColumnBlock
int addColumnBlock(int numberColumns, const std::string &name)
Add or check a column block name and number of columns.
CoinStructuredModel::getRowBlock
const std::string & getRowBlock(int i) const
Return the i&#39;th row block name.
Definition: CoinStructuredModel.hpp:143
CoinStructuredModel::coinModelBlock
CoinModel * coinModelBlock(CoinModelBlockInfo &info)
Return model as a CoinModel block and fill in info structure and update counts.
CoinStructuredModel::addRowBlock
int addRowBlock(int numberRows, const std::string &name)
Add or check a row block name and number of rows.
CoinStructuredModel::numberRowBlocks
int numberRowBlocks() const
Return number of row blocks.
Definition: CoinStructuredModel.hpp:126
CoinStructuredModel::getColumnBlock
const std::string & getColumnBlock(int i) const
Return i&#39;th the column block name.
Definition: CoinStructuredModel.hpp:157
CoinStructuredModel::rowBlockNames_
std::vector< std::string > rowBlockNames_
Rowblock name.
Definition: CoinStructuredModel.hpp:256
CoinStructuredModel::setRowBlock
void setRowBlock(int i, const std::string &name)
Set i&#39;th row block name.
Definition: CoinStructuredModel.hpp:148
CoinStructuredModel::setColumnBlock
void setColumnBlock(int i, const std::string &name)
Set i&#39;th column block name.
Definition: CoinStructuredModel.hpp:162
CoinStructuredModel::setOptimizationDirection
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinStructuredModel.hpp:208
CoinStructuredModel::writeMps
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.
CoinStructuredModel::coinModelBlocks_
CoinModel ** coinModelBlocks_
CoinModel copies of blocks or NULL if original CoinModel.
Definition: CoinStructuredModel.hpp:262
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CoinStructuredModel::CoinStructuredModel
CoinStructuredModel()
Default constructor.
CoinModelInfo2::rowName
char rowName
Definition: CoinStructuredModel.hpp:20
CoinStructuredModel::readSmps
int readSmps(const char *filename, bool keepNames=false, bool ignoreErrors=false)
Read SMPS model.
CoinStructuredModel::optimizationDirection
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
Definition: CoinStructuredModel.hpp:203
CoinStructuredModel::addBlock
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...
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:136
CoinModelInfo2::columnName
char columnName
Definition: CoinStructuredModel.hpp:23
CoinModelInfo2::integer
char integer
Definition: CoinStructuredModel.hpp:21
CoinStructuredModel::columnBlockNames_
std::vector< std::string > columnBlockNames_
Columnblock name.
Definition: CoinStructuredModel.hpp:258
CoinStructuredModel::numberColumnBlocks_
int numberColumnBlocks_
Current number of column blocks.
Definition: CoinStructuredModel.hpp:250
CoinModelInfo2::rowBlock
int rowBlock
Definition: CoinStructuredModel.hpp:16
CoinStructuredModel::blockIndex
int blockIndex(int row, int column) const
Return block number corresponding to row and column.
CoinBaseModel::objectiveOffset
double objectiveOffset() const
Returns the (constant) objective offset This is the RHS entry for the objective row.
Definition: CoinModel.hpp:51
CoinBaseModel::numberRows
int numberRows() const
Return number of rows.
Definition: CoinModel.hpp:37
CoinModel.hpp
CoinStructuredModel::numberElements
CoinBigIndex numberElements() const
Return number of elements.
CoinStructuredModel::rowBlock
int rowBlock(const std::string &name) const
Return a row block index given a row block name.
CoinStructuredModel::numberColumnBlocks
int numberColumnBlocks() const
Return number of column blocks.
Definition: CoinStructuredModel.hpp:131
CoinStructuredModel::numberRowBlocks_
int numberRowBlocks_
Current number of row blocks.
Definition: CoinStructuredModel.hpp:248
CoinModelInfo2::CoinModelInfo2
CoinModelInfo2()
Definition: CoinStructuredModel.hpp:24