Modelib: NumVarMatrix.h Source File

Page principale | Hiérarchie des classes | Liste des composants | Liste des fichiers | Composants

# NumVarMatrix.h

    00001 #ifndef __NUMVARMATRIX_H
    00002 #define __NUMVARMARTIX_H
    00003
    00004 #include "Config.h"
    00005 #include "Constant.h"
    00006 #include "MuteVar.h"
    00007
    00008 #include <vector>
    00009 #include <string>
    00010 #include <stdexcept>
    00011
    00012 //Pour éviter les définitions circulaire
    00013 class Model;
    00014 class NumVar;
    00015 class NumVarArray;
    00016
    00018
    00022 class NumVarMatrix
    00023 {
    00024   protected:
    00025   Model * modele;
    00026   std::vector<NumVarArray *> varMatrix;
    00027   MuteVar::VarType type;
    00028
    00029   public:
    00031     NumVarMatrix():modele(0),type(MuteVar::FLOAT) {}
    00032
    00033     NumVarMatrix( Model & _modele,
    00034                  unsigned sizeI = 0,
    00035                  unsigned sizeJ = 0,
    00036                  float _lb= 0,
    00037                  float _ub= Infinity,
    00038                  MuteVar::VarType _type = MuteVar::FLOAT,
    00039                  const std::string & nom = "unknow",
    00040                  const std::string & milieu = "",
    00041                  const std::string & fin = "" );
    00042
    00043     NumVarMatrix( const NumVarMatrix & nva );
    00044
    00045     NumVarMatrix( const std::vector<NumVarArray *> & nva );
    00046
    00047     NumVarMatrix & operator= ( const NumVarMatrix & nva );
    00048
    00049     unsigned GetNbCols() const;
    00050
    00054     unsigned GetNbRows() const
    00055     {
    00056         return varMatrix.size();
    00057     }
    00058
    00059     NumVarArray GetCol(unsigned j) const;
    00060
    00061     NumVarArray GetRow(unsigned i) const;
    00062
    00063     NumVar  operator() (unsigned i,unsigned j) const ;
    00064
    00065 #ifndef COMPILE_FOR_PYTHON
    00066         NumVar * Get(unsigned i, unsigned j);
    00067 #else
    00068         NumVar&   Get(unsigned i, unsigned j);
    00069 #endif
    00070
    00073     MuteVar::VarType GetType() const { return type;}
    00074
    00075     ~NumVarMatrix();
    00076
    00077 #ifdef COMPILE_FOR_PYTHON
    00078     NumVar&   GetItem(unsigned n) const      {return *(varArray[n]);}
    00079     void     SetItem(NumVar* _n, unsigned n) {varArray[n] = _n;  }
    00080 #endif
    00081
    00082
    00083 };
    00084
    00085 /*--------------------------------------------------------------------------------------------*/
    00087
    00088 class IntVarMatrix: public NumVarMatrix
    00089 {
    00090   public:
    00091 #ifndef COMPILE_FOR_PYTHON
    00092    IntVarMatrix( Model &_modele,
    00093                  unsigned sizeI=0,
    00094                  unsigned sizeJ=0,
    00095                  int _lb= 0,
    00096                  int _ub= Infinity,  // ou MaxInt à voir
    00097                  const std::string & nom = "unknow",
    00098                  const std::string & milieu = "",
    00099                  const std::string & fin = "" )
    00100     :NumVarMatrix( _modele,sizeI,sizeJ,static_cast<float>(_lb),static_cast<float>(_ub),MuteVar::INT,nom,milieu,fin) {}
    00101 #else
    00102     IntVarMatrix( Model &_modele,
    00103                  unsigned sizeI=0,
    00104                  unsigned sizeJ=0,
    00105                  float _lb= 0,
    00106                  float _ub= Infinity,
    00107                  const std::string & nom = "unknow",
    00108                  const std::string & milieu = "",
    00109                  const std::string & fin = "" )
    00110     :NumVarMatrix( _modele,sizeI,sizeJ,_lb,_ub,MuteVar::INT,nom,milieu,fin) {}
    00111 #endif
    00112 };
    00113
    00115 class FloatVarMatrix: public NumVarMatrix
    00116 {
    00117   public:
    00118     FloatVarMatrix( Model &_modele,
    00119                    unsigned sizeI=0,
    00120                    unsigned sizeJ=0,
    00121                    float _lb= 0.0f,
    00122                    float _ub= Infinity,
    00123                    const std::string & nom = "unknow",
    00124                    const std::string & milieu = "",
    00125                    const std::string & fin = "" )
    00126     :NumVarMatrix( _modele,sizeI,sizeJ,_lb,_ub,MuteVar::FLOAT,nom,milieu,fin) {}
    00127 };
    00128
    00130 class BoolVarMatrix: public NumVarMatrix
    00131 {
    00132   public:
    00133     BoolVarMatrix( Model &_modele,
    00134                   unsigned sizeI=0,
    00135                   unsigned sizeJ=0,
    00136                   const std::string & nom = "unknow",
    00137                   const std::string & milieu = "",
    00138                   const std::string & fin = "" )
    00139     :NumVarMatrix( _modele,sizeI,sizeJ,0.0f,1.0f,MuteVar::BOOL,nom,milieu,fin) {}
    00140 };
    00141
    00142 #ifdef COMPILE_FOR_PYTHON
    00143         void export_NumVarMatrix();
    00144 #endif
    00145
    00146 #endif