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

- File List
- File Members

# /home/coin/SVN-release/Bcps-0.91.0/CoinUtils/src/CoinStructuredModel.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2008, International Business Machines
    00002 // Corporation and others.  All Rights Reserved.
    00003 #ifndef CoinStructuredModel_H
    00004 #define CoinStructuredModel_H
    00005
    00006 #include "CoinModel.hpp"
    00007 #include <vector>
    00008
    00012   typedef struct CoinModelInfo2 {
    00013     unsigned int matrix:1; // nonzero if matrix exists
    00014     unsigned int rhs:1; // nonzero if non default rhs exists
    00015     unsigned int rowName:1; // nonzero if row names exists
    00016     unsigned int integer:1; // nonzero if integer information exists
    00017     unsigned int bounds:1; // nonzero if non default bounds/objective exists
    00018     unsigned int columnName:1; // nonzero if column names exists
    00019     int rowBlock; // Which row block
    00020     int columnBlock; // Which column block
    00021     CoinModelInfo2() :
    00022       matrix(0),
    00023       rhs(0),
    00024       rowName(0),
    00025       integer(0),
    00026       bounds(0),
    00027       columnName(0),
    00028       rowBlock(0),
    00029       columnBlock(0)
    00030     {}
    00031 } CoinModelBlockInfo;
    00032
    00033 class CoinStructuredModel : public CoinBaseModel {
    00034
    00035 public:
    00041   int addBlock(const std::string & rowBlock,
    00042                 const std::string & columnBlock,
    00043                 const CoinBaseModel & block);
    00047   int addBlock(const CoinBaseModel & block);
    00052   int addBlock(const std::string & rowBlock,
    00053                 const std::string & columnBlock,
    00054                 CoinBaseModel * block);
    00057   int addBlock(const std::string & rowBlock,
    00058                const std::string & columnBlock,
    00059                const CoinPackedMatrix & matrix,
    00060                const double * rowLower, const double * rowUpper,
    00061                const double * columnLower, const double * columnUpper,
    00062                const double * objective);
    00063
    00089   int writeMps(const char *filename, int compression = 0,
    00090                int formatType = 0, int numberAcross = 2, bool keepStrings=false) ;
    00097   int decompose(const CoinModel &model,int type,
    00098                 int maxBlocks=50);
    00105   int decompose(const CoinPackedMatrix & matrix,
    00106                 const double * rowLower, const double * rowUpper,
    00107                 const double * columnLower, const double * columnUpper,
    00108                 const double * objective, int type,int maxBlocks=50,
    00109                 double objectiveOffset=0.0);
    00110
    00112
    00113
    00116
    00117   inline int numberRowBlocks() const
    00118   { return numberRowBlocks_;}
    00120   inline int numberColumnBlocks() const
    00121   { return numberColumnBlocks_;}
    00123   inline CoinBigIndex numberElementBlocks() const
    00124   { return numberElementBlocks_;}
    00126   CoinBigIndex numberElements() const;
    00128   inline const std::string & getRowBlock(int i) const
    00129   { return rowBlockNames_[i];}
    00131   inline void setRowBlock(int i,const std::string &name)
    00132   { rowBlockNames_[i] = name;}
    00134   int addRowBlock(int numberRows,const std::string &name) ;
    00136   int rowBlock(const std::string &name) const;
    00138   inline const std::string & getColumnBlock(int i) const
    00139   { return columnBlockNames_[i];}
    00141   inline void setColumnBlock(int i,const std::string &name)
    00142   { columnBlockNames_[i] = name;}
    00144   int addColumnBlock(int numberColumns,const std::string &name) ;
    00146   int columnBlock(const std::string &name) const;
    00148   inline const CoinModelBlockInfo &  blockType(int i) const
    00149   { return blockType_[i];}
    00151   inline CoinBaseModel * block(int i) const
    00152   { return blocks_[i];}
    00154   const CoinBaseModel *  block(int row,int column) const;
    00156   CoinModel * coinBlock(int i) const;
    00158   const CoinBaseModel *  coinBlock(int row,int column) const;
    00160   int  blockIndex(int row,int column) const;
    00164   CoinModel * coinModelBlock(CoinModelBlockInfo & info) ;
    00166   void setCoinModel(CoinModel * block, int iBlock);
    00168   void refresh(int iBlock);
    00171   CoinModelBlockInfo block(int row,int column,
    00172              const double * & rowLower, const double * & rowUpper,
    00173              const double * & columnLower, const double * & columnUpper,
    00174              const double * & objective) const;
    00176   inline double optimizationDirection() const {
    00177     return  optimizationDirection_;
    00178   }
    00180   inline void setOptimizationDirection(double value)
    00181   { optimizationDirection_=value;}
    00183
    00187   CoinStructuredModel();
    00191   CoinStructuredModel(const char *fileName,int decompose=0,
    00192                       int maxBlocks=50);
    00194    virtual ~CoinStructuredModel();
    00196
    00200    CoinStructuredModel(const CoinStructuredModel&);
    00202    CoinStructuredModel& operator=(const CoinStructuredModel&);
    00204   virtual CoinBaseModel * clone() const;
    00206
    00207 private:
    00208
    00212   int fillInfo(CoinModelBlockInfo & info,const CoinModel * block);
    00215   void fillInfo(CoinModelBlockInfo & info,const CoinStructuredModel * block);
    00218
    00219   int numberRowBlocks_;
    00221   int numberColumnBlocks_;
    00223   int numberElementBlocks_;
    00225   int maximumElementBlocks_;
    00227   std::vector<std::string> rowBlockNames_;
    00229   std::vector<std::string> columnBlockNames_;
    00231   CoinBaseModel ** blocks_;
    00233   CoinModel ** coinModelBlocks_;
    00235   CoinModelBlockInfo * blockType_;
    00237 };
    00238 #endif