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

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.2/CoinUtils/src/CoinStructuredModel.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinStructuredModel.hpp 1191 2009-07-25 08:38:12Z forrest $ */
    00002 // Copyright (C) 2008, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 #ifndef CoinStructuredModel_H
    00005 #define CoinStructuredModel_H
    00006
    00007 #include "CoinModel.hpp"
    00008 #include <vector>
    00009
    00013   typedef struct CoinModelInfo2 {
    00014     int rowBlock; // Which row block
    00015     int columnBlock; // Which column block
    00016     char matrix; // nonzero if matrix exists
    00017     char rhs; // nonzero if non default rhs exists
    00018     char rowName; // nonzero if row names exists
    00019     char integer; // nonzero if integer information exists
    00020     char bounds; // nonzero if non default bounds/objective exists
    00021     char columnName; // nonzero if column names exists
    00022     CoinModelInfo2() :
    00023       rowBlock(0),
    00024       columnBlock(0),
    00025       matrix(0),
    00026       rhs(0),
    00027       rowName(0),
    00028       integer(0),
    00029       bounds(0),
    00030       columnName(0)
    00031     {}
    00032 } CoinModelBlockInfo;
    00033
    00034 class CoinStructuredModel : public CoinBaseModel {
    00035
    00036 public:
    00042   int addBlock(const std::string & rowBlock,
    00043                 const std::string & columnBlock,
    00044                 const CoinBaseModel & block);
    00048   int addBlock(const CoinBaseModel & block);
    00053   int addBlock(const std::string & rowBlock,
    00054                 const std::string & columnBlock,
    00055                 CoinBaseModel * block);
    00058   int addBlock(const std::string & rowBlock,
    00059                const std::string & columnBlock,
    00060                const CoinPackedMatrix & matrix,
    00061                const double * rowLower, const double * rowUpper,
    00062                const double * columnLower, const double * columnUpper,
    00063                const double * objective);
    00064
    00090   int writeMps(const char *filename, int compression = 0,
    00091                int formatType = 0, int numberAcross = 2, bool keepStrings=false) ;
    00098   int decompose(const CoinModel &model,int type,
    00099                 int maxBlocks=50);
    00106   int decompose(const CoinPackedMatrix & matrix,
    00107                 const double * rowLower, const double * rowUpper,
    00108                 const double * columnLower, const double * columnUpper,
    00109                 const double * objective, int type,int maxBlocks=50,
    00110                 double objectiveOffset=0.0);
    00111
    00113
    00114
    00117
    00118   inline int numberRowBlocks() const
    00119   { return numberRowBlocks_;}
    00121   inline int numberColumnBlocks() const
    00122   { return numberColumnBlocks_;}
    00124   inline CoinBigIndex numberElementBlocks() const
    00125   { return numberElementBlocks_;}
    00127   CoinBigIndex numberElements() const;
    00129   inline const std::string & getRowBlock(int i) const
    00130   { return rowBlockNames_[i];}
    00132   inline void setRowBlock(int i,const std::string &name)
    00133   { rowBlockNames_[i] = name;}
    00135   int addRowBlock(int numberRows,const std::string &name) ;
    00137   int rowBlock(const std::string &name) const;
    00139   inline const std::string & getColumnBlock(int i) const
    00140   { return columnBlockNames_[i];}
    00142   inline void setColumnBlock(int i,const std::string &name)
    00143   { columnBlockNames_[i] = name;}
    00145   int addColumnBlock(int numberColumns,const std::string &name) ;
    00147   int columnBlock(const std::string &name) const;
    00149   inline const CoinModelBlockInfo &  blockType(int i) const
    00150   { return blockType_[i];}
    00152   inline CoinBaseModel * block(int i) const
    00153   { return blocks_[i];}
    00155   const CoinBaseModel *  block(int row,int column) const;
    00157   CoinModel * coinBlock(int i) const;
    00159   const CoinBaseModel *  coinBlock(int row,int column) const;
    00161   int  blockIndex(int row,int column) const;
    00165   CoinModel * coinModelBlock(CoinModelBlockInfo & info) ;
    00167   void setCoinModel(CoinModel * block, int iBlock);
    00169   void refresh(int iBlock);
    00172   CoinModelBlockInfo block(int row,int column,
    00173              const double * & rowLower, const double * & rowUpper,
    00174              const double * & columnLower, const double * & columnUpper,
    00175              const double * & objective) const;
    00177   inline double optimizationDirection() const {
    00178     return  optimizationDirection_;
    00179   }
    00181   inline void setOptimizationDirection(double value)
    00182   { optimizationDirection_=value;}
    00184
    00188   CoinStructuredModel();
    00192   CoinStructuredModel(const char *fileName,int decompose=0,
    00193                       int maxBlocks=50);
    00195    virtual ~CoinStructuredModel();
    00197
    00201    CoinStructuredModel(const CoinStructuredModel&);
    00203    CoinStructuredModel& operator=(const CoinStructuredModel&);
    00205   virtual CoinBaseModel * clone() const;
    00207
    00208 private:
    00209
    00213   int fillInfo(CoinModelBlockInfo & info,const CoinModel * block);
    00216   void fillInfo(CoinModelBlockInfo & info,const CoinStructuredModel * block);
    00219
    00220   int numberRowBlocks_;
    00222   int numberColumnBlocks_;
    00224   int numberElementBlocks_;
    00226   int maximumElementBlocks_;
    00228   std::vector<std::string> rowBlockNames_;
    00230   std::vector<std::string> columnBlockNames_;
    00232   CoinBaseModel ** blocks_;
    00234   CoinModel ** coinModelBlocks_;
    00236   CoinModelBlockInfo * blockType_;
    00238 };
    00239 #endif