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

- File List
- File Members

# /home/coin/svn-release/Smi-0.93.1/CoinUtils/src/CoinStructuredModel.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinStructuredModel.hpp 1372 2011-01-03 23:31:00Z lou $ */
    00002 // Copyright (C) 2008, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00005
    00006 #ifndef CoinStructuredModel_H
    00007 #define CoinStructuredModel_H
    00008
    00009 #include "CoinModel.hpp"
    00010 #include <vector>
    00011
    00015   typedef struct CoinModelInfo2 {
    00016     int rowBlock; // Which row block
    00017     int columnBlock; // Which column block
    00018     char matrix; // nonzero if matrix exists
    00019     char rhs; // nonzero if non default rhs exists
    00020     char rowName; // nonzero if row names exists
    00021     char integer; // nonzero if integer information exists
    00022     char bounds; // nonzero if non default bounds/objective exists
    00023     char columnName; // nonzero if column names exists
    00024     CoinModelInfo2() :
    00025       rowBlock(0),
    00026       columnBlock(0),
    00027       matrix(0),
    00028       rhs(0),
    00029       rowName(0),
    00030       integer(0),
    00031       bounds(0),
    00032       columnName(0)
    00033     {}
    00034 } CoinModelBlockInfo;
    00035
    00036 class CoinStructuredModel : public CoinBaseModel {
    00037
    00038 public:
    00044   int addBlock(const std::string & rowBlock,
    00045                 const std::string & columnBlock,
    00046                 const CoinBaseModel & block);
    00050   int addBlock(const CoinBaseModel & block);
    00055   int addBlock(const std::string & rowBlock,
    00056                 const std::string & columnBlock,
    00057                 CoinBaseModel * block);
    00060   int addBlock(const std::string & rowBlock,
    00061                const std::string & columnBlock,
    00062                const CoinPackedMatrix & matrix,
    00063                const double * rowLower, const double * rowUpper,
    00064                const double * columnLower, const double * columnUpper,
    00065                const double * objective);
    00066
    00092   int writeMps(const char *filename, int compression = 0,
    00093                int formatType = 0, int numberAcross = 2, bool keepStrings=false) ;
    00100   int decompose(const CoinModel &model,int type,
    00101                 int maxBlocks=50);
    00108   int decompose(const CoinPackedMatrix & matrix,
    00109                 const double * rowLower, const double * rowUpper,
    00110                 const double * columnLower, const double * columnUpper,
    00111                 const double * objective, int type,int maxBlocks=50,
    00112                 double objectiveOffset=0.0);
    00113
    00115
    00116
    00119
    00120   inline int numberRowBlocks() const
    00121   { return numberRowBlocks_;}
    00123   inline int numberColumnBlocks() const
    00124   { return numberColumnBlocks_;}
    00126   inline CoinBigIndex numberElementBlocks() const
    00127   { return numberElementBlocks_;}
    00129   CoinBigIndex numberElements() const;
    00131   inline const std::string & getRowBlock(int i) const
    00132   { return rowBlockNames_[i];}
    00134   inline void setRowBlock(int i,const std::string &name)
    00135   { rowBlockNames_[i] = name;}
    00137   int addRowBlock(int numberRows,const std::string &name) ;
    00139   int rowBlock(const std::string &name) const;
    00141   inline const std::string & getColumnBlock(int i) const
    00142   { return columnBlockNames_[i];}
    00144   inline void setColumnBlock(int i,const std::string &name)
    00145   { columnBlockNames_[i] = name;}
    00147   int addColumnBlock(int numberColumns,const std::string &name) ;
    00149   int columnBlock(const std::string &name) const;
    00151   inline const CoinModelBlockInfo &  blockType(int i) const
    00152   { return blockType_[i];}
    00154   inline CoinBaseModel * block(int i) const
    00155   { return blocks_[i];}
    00157   const CoinBaseModel *  block(int row,int column) const;
    00159   CoinModel * coinBlock(int i) const;
    00161   const CoinBaseModel *  coinBlock(int row,int column) const;
    00163   int  blockIndex(int row,int column) const;
    00167   CoinModel * coinModelBlock(CoinModelBlockInfo & info) ;
    00169   void setCoinModel(CoinModel * block, int iBlock);
    00171   void refresh(int iBlock);
    00174   CoinModelBlockInfo block(int row,int column,
    00175              const double * & rowLower, const double * & rowUpper,
    00176              const double * & columnLower, const double * & columnUpper,
    00177              const double * & objective) const;
    00179   inline double optimizationDirection() const {
    00180     return  optimizationDirection_;
    00181   }
    00183   inline void setOptimizationDirection(double value)
    00184   { optimizationDirection_=value;}
    00186
    00190   CoinStructuredModel();
    00194   CoinStructuredModel(const char *fileName,int decompose=0,
    00195                       int maxBlocks=50);
    00197    virtual ~CoinStructuredModel();
    00199
    00203    CoinStructuredModel(const CoinStructuredModel&);
    00205    CoinStructuredModel& operator=(const CoinStructuredModel&);
    00207   virtual CoinBaseModel * clone() const;
    00209
    00210 private:
    00211
    00215   int fillInfo(CoinModelBlockInfo & info,const CoinModel * block);
    00218   void fillInfo(CoinModelBlockInfo & info,const CoinStructuredModel * block);
    00221
    00222   int numberRowBlocks_;
    00224   int numberColumnBlocks_;
    00226   int numberElementBlocks_;
    00228   int maximumElementBlocks_;
    00230   std::vector<std::string> rowBlockNames_;
    00232   std::vector<std::string> columnBlockNames_;
    00234   CoinBaseModel ** blocks_;
    00236   CoinModel ** coinModelBlocks_;
    00238   CoinModelBlockInfo * blockType_;
    00240 };
    00241 #endif