CoinUtils  2.10.14
CoinStructuredModel.hpp
Go to the documentation of this file.
1 /* $Id: CoinStructuredModel.hpp 1691 2014-03-19 12:43:56Z forrest $ */
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
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  {}
35 
37 
38 public:
44  int addBlock(const std::string & rowBlock,
45  const std::string & columnBlock,
46  const CoinBaseModel & block);
50  int addBlock(const CoinBaseModel & block);
55  int addBlock(const std::string & rowBlock,
56  const std::string & columnBlock,
57  CoinBaseModel * block);
60  int addBlock(const std::string & rowBlock,
61  const std::string & columnBlock,
62  const CoinPackedMatrix & matrix,
63  const double * rowLower, const double * rowUpper,
64  const double * columnLower, const double * columnUpper,
65  const double * objective);
66 
92  int writeMps(const char *filename, int compression = 0,
93  int formatType = 0, int numberAcross = 2, bool keepStrings=false) ;
95  int readSmps(const char *filename,
96  bool keepNames = false,
97  bool ignoreErrors = false);
98 
105  int decompose(const CoinModel &model,int type,
106  int maxBlocks=50, const char ** starts=NULL);
113  int decompose(const CoinPackedMatrix & matrix,
114  const double * rowLower, const double * rowUpper,
115  const double * columnLower, const double * columnUpper,
116  const double * objective, int type,int maxBlocks=50,
117  int * starts=NULL,
118  double objectiveOffset=0.0);
119 
121 
122 
125  inline int numberRowBlocks() const
127  { return numberRowBlocks_;}
129  inline int numberColumnBlocks() const
130  { return numberColumnBlocks_;}
133  { return numberElementBlocks_;}
135  CoinBigIndex numberElements() const;
137  inline const std::string & getRowBlock(int i) const
138  { return rowBlockNames_[i];}
140  inline void setRowBlock(int i,const std::string &name)
141  { rowBlockNames_[i] = name;}
143  int addRowBlock(int numberRows,const std::string &name) ;
145  int rowBlock(const std::string &name) const;
147  inline const std::string & getColumnBlock(int i) const
148  { return columnBlockNames_[i];}
150  inline void setColumnBlock(int i,const std::string &name)
151  { columnBlockNames_[i] = name;}
153  int addColumnBlock(int numberColumns,const std::string &name) ;
155  int columnBlock(const std::string &name) const;
157  inline const CoinModelBlockInfo & blockType(int i) const
158  { return blockType_[i];}
160  inline CoinBaseModel * block(int i) const
161  { return blocks_[i];}
163  const CoinBaseModel * block(int row,int column) const;
165  CoinModel * coinBlock(int i) const;
167  const CoinBaseModel * coinBlock(int row,int column) const;
169  int blockIndex(int row,int column) const;
173  CoinModel * coinModelBlock(CoinModelBlockInfo & info) ;
175  void setCoinModel(CoinModel * block, int iBlock);
177  void refresh(int iBlock);
180  CoinModelBlockInfo block(int row,int column,
181  const double * & rowLower, const double * & rowUpper,
182  const double * & columnLower, const double * & columnUpper,
183  const double * & objective) const;
185  inline double optimizationDirection() const {
186  return optimizationDirection_;
187  }
189  inline void setOptimizationDirection(double value)
190  { optimizationDirection_=value;}
192 
200  CoinStructuredModel(const char *fileName,int decompose=0,
201  int maxBlocks=50);
203  virtual ~CoinStructuredModel();
205 
211  CoinStructuredModel& operator=(const CoinStructuredModel&);
213  virtual CoinBaseModel * clone() const;
215 
216 private:
217 
221  int fillInfo(CoinModelBlockInfo & info,const CoinModel * block);
224  void fillInfo(CoinModelBlockInfo & info,const CoinStructuredModel * block);
227  int numberRowBlocks_;
236  std::vector<std::string> rowBlockNames_;
238  std::vector<std::string> columnBlockNames_;
246 };
247 #endif
This is a model which is made up of Coin(Structured)Model blocks.
int numberElementBlocks_
Current number of element blocks.
CoinBaseModel ** blocks_
Blocks.
This is a simple minded model which is stored in a format which makes it easier to construct and modi...
Definition: CoinModel.hpp:161
CoinModelBlockInfo * blockType_
Which parts of model are set in block.
const CoinModelBlockInfo & blockType(int i) const
Return i&#39;th block type.
int maximumElementBlocks_
Maximum number of element blocks.
std::vector< std::string > rowBlockNames_
Rowblock name.
const std::string & getColumnBlock(int i) const
Return i&#39;th the column block name.
struct CoinModelInfo2 CoinModelBlockInfo
This is a model which is made up of Coin(Structured)Model blocks.
double optimizationDirection() const
Direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
int numberColumnBlocks() const
Return number of column blocks.
CoinBaseModel * block(int i) const
Return i&#39;th block.
void setRowBlock(int i, const std::string &name)
Set i&#39;th row block name.
void setColumnBlock(int i, const std::string &name)
Set i&#39;th column block name.
void setOptimizationDirection(double value)
Set direction of optimization (1 - minimize, -1 - maximize, 0 - ignore.
CoinModel ** coinModelBlocks_
CoinModel copies of blocks or NULL if original CoinModel.
Sparse Matrix Base Class.
int CoinBigIndex
CoinBigIndex numberElementBlocks() const
Return number of elementBlocks.
int numberColumnBlocks_
Current number of column blocks.
std::vector< std::string > columnBlockNames_
Columnblock name.
const std::string & getRowBlock(int i) const
Return the i&#39;th row block name.