# CoinStructuredModel.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinStructuredModel.hpp 1691 2014-03-19 12:43:56Z forrest $ */
    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) ;
    00095   int readSmps(const char *filename,
    00096                  bool keepNames = false,
    00097                  bool ignoreErrors = false);
    00098
    00105   int decompose(const CoinModel &model,int type,
    00106                 int maxBlocks=50, const char ** starts=NULL);
    00113   int decompose(const CoinPackedMatrix & matrix,
    00114                 const double * rowLower, const double * rowUpper,
    00115                 const double * columnLower, const double * columnUpper,
    00116                 const double * objective, int type,int maxBlocks=50,
    00117                 int * starts=NULL,
    00118                 double objectiveOffset=0.0);
    00119
    00121
    00122
    00125
    00126   inline int numberRowBlocks() const
    00127   { return numberRowBlocks_;}
    00129   inline int numberColumnBlocks() const
    00130   { return numberColumnBlocks_;}
    00132   inline CoinBigIndex numberElementBlocks() const
    00133   { return numberElementBlocks_;}
    00135   CoinBigIndex numberElements() const;
    00137   inline const std::string & getRowBlock(int i) const
    00138   { return rowBlockNames_[i];}
    00140   inline void setRowBlock(int i,const std::string &name)
    00141   { rowBlockNames_[i] = name;}
    00143   int addRowBlock(int numberRows,const std::string &name) ;
    00145   int rowBlock(const std::string &name) const;
    00147   inline const std::string & getColumnBlock(int i) const
    00148   { return columnBlockNames_[i];}
    00150   inline void setColumnBlock(int i,const std::string &name)
    00151   { columnBlockNames_[i] = name;}
    00153   int addColumnBlock(int numberColumns,const std::string &name) ;
    00155   int columnBlock(const std::string &name) const;
    00157   inline const CoinModelBlockInfo &  blockType(int i) const
    00158   { return blockType_[i];}
    00160   inline CoinBaseModel * block(int i) const
    00161   { return blocks_[i];}
    00163   const CoinBaseModel *  block(int row,int column) const;
    00165   CoinModel * coinBlock(int i) const;
    00167   const CoinBaseModel *  coinBlock(int row,int column) const;
    00169   int  blockIndex(int row,int column) const;
    00173   CoinModel * coinModelBlock(CoinModelBlockInfo & info) ;
    00175   void setCoinModel(CoinModel * block, int iBlock);
    00177   void refresh(int iBlock);
    00180   CoinModelBlockInfo block(int row,int column,
    00181              const double * & rowLower, const double * & rowUpper,
    00182              const double * & columnLower, const double * & columnUpper,
    00183              const double * & objective) const;
    00185   inline double optimizationDirection() const {
    00186     return  optimizationDirection_;
    00187   }
    00189   inline void setOptimizationDirection(double value)
    00190   { optimizationDirection_=value;}
    00192
    00196   CoinStructuredModel();
    00200   CoinStructuredModel(const char *fileName,int decompose=0,
    00201                       int maxBlocks=50);
    00203    virtual ~CoinStructuredModel();
    00205
    00209    CoinStructuredModel(const CoinStructuredModel&);
    00211    CoinStructuredModel& operator=(const CoinStructuredModel&);
    00213   virtual CoinBaseModel * clone() const;
    00215
    00216 private:
    00217
    00221   int fillInfo(CoinModelBlockInfo & info,const CoinModel * block);
    00224   void fillInfo(CoinModelBlockInfo & info,const CoinStructuredModel * block);
    00227
    00228   int numberRowBlocks_;
    00230   int numberColumnBlocks_;
    00232   int numberElementBlocks_;
    00234   int maximumElementBlocks_;
    00236   std::vector<std::string> rowBlockNames_;
    00238   std::vector<std::string> columnBlockNames_;
    00240   CoinBaseModel ** blocks_;
    00242   CoinModel ** coinModelBlocks_;
    00244   CoinModelBlockInfo * blockType_;
    00246 };
    00247 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines