Page principale | Liste des namespaces | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

NumVarMatrix.h

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (c) 2005, Quentin Lequy and Romain Gaucher
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or 
00006     without modification, are permitted provided that the following 
00007     conditions are met:
00008 
00009         * Redistributions of source code must retain the above copyright 
00010           notice, this list of conditions and the following disclaimer.
00011 
00012         * Redistributions in binary form must reproduce the above copyright 
00013           notice, this list of conditions and the following disclaimer in the 
00014           documentation and/or other materials provided with the distribution.
00015 
00016         * Neither the name of Quentin Lequy or Romain Gaucher nor the names 
00017           of its contributors may be used to endorse or promote products 
00018           derived from this software without specific prior written permission.
00019 
00020     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00025     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00026     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027     AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 */
00031 
00032 #ifndef __NUMVARMATRIX_H
00033 #define __NUMVARMARTIX_H
00034 
00035 #include "Config.h"
00036 #include "Constant.h"
00037 #include "MuteVar.h"
00038 
00039 #include <vector>
00040 #include <string>
00041 #include <stdexcept>
00042 
00043 namespace Modelib {
00044 
00045 //Pour éviter les définitions circulaire
00046 class Model;
00047 class NumVar;
00048 class NumVarArray;
00049 
00051 
00055 class NumVarMatrix
00056 {
00057   protected:
00058   Model * modele;                   
00059   std::vector<NumVarArray *> varMatrix;    
00060   MuteVar::VarType type;             
00061 
00062   public:
00064     NumVarMatrix():modele(0),type(MuteVar::FLOAT) {}
00065 
00066     NumVarMatrix( Model & _modele,
00067                  unsigned sizeI = 0,
00068                  unsigned sizeJ = 0,
00069                  float _lb= 0,
00070                  float _ub= Infinity,
00071                  MuteVar::VarType _type = MuteVar::FLOAT,
00072                  const std::string & nom = "unknow",
00073                  const std::string & milieu = "",
00074                  const std::string & fin = "" );
00075 
00076     NumVarMatrix( const NumVarMatrix & nva );
00077     
00078     NumVarMatrix( const std::vector<NumVarArray *> & nva );
00079 
00080     NumVarMatrix & operator= ( const NumVarMatrix & nva );
00081 
00082     unsigned GetNbCols() const;
00083 
00087     unsigned GetNbRows() const
00088     {
00089         return varMatrix.size();
00090     }
00091 
00092     NumVarArray GetCol(unsigned j) const;
00093 
00094     NumVarArray GetRow(unsigned i) const;
00095 
00096     NumVar  operator() (unsigned i,unsigned j) const ;
00097 
00098 #ifndef COMPILE_FOR_PYTHON    
00099     NumVar * Get(unsigned i, unsigned j);
00100 #else
00101     NumVar&   Get(unsigned i, unsigned j);
00102 #endif
00103 
00106     MuteVar::VarType GetType() const { return type;}
00107 
00108     ~NumVarMatrix();
00109 
00110 #ifdef COMPILE_FOR_PYTHON
00111     NumVar&   GetItem(unsigned n) const      {return *(varArray[n]);}
00112     void     SetItem(NumVar* _n, unsigned n) {varArray[n] = _n;  }
00113 #endif
00114 
00115 
00116 };
00117 
00118 /*--------------------------------------------------------------------------------------------*/
00120 
00121 class IntVarMatrix: public NumVarMatrix
00122 {
00123   public:
00124 #ifndef COMPILE_FOR_PYTHON    
00125    IntVarMatrix( Model &_modele,
00126                  unsigned sizeI=0,
00127                  unsigned sizeJ=0,
00128                  int _lb= 0,
00129                  int _ub= Infinity,  // ou MaxInt à voir
00130                  const std::string & nom = "unknow",
00131                  const std::string & milieu = "",
00132                  const std::string & fin = "" )
00133     :NumVarMatrix( _modele,sizeI,sizeJ,static_cast<float>(_lb),static_cast<float>(_ub),MuteVar::INT,nom,milieu,fin) {}
00134 #else
00135     IntVarMatrix( Model &_modele,
00136                  unsigned sizeI=0,
00137                  unsigned sizeJ=0,
00138                  float _lb= 0,
00139                  float _ub= Infinity,
00140                  const std::string & nom = "unknow",
00141                  const std::string & milieu = "",
00142                  const std::string & fin = "" )
00143     :NumVarMatrix( _modele,sizeI,sizeJ,_lb,_ub,MuteVar::INT,nom,milieu,fin) {}
00144 #endif
00145 };
00146 
00148 class FloatVarMatrix: public NumVarMatrix
00149 {
00150   public:
00151     FloatVarMatrix( Model &_modele,
00152                    unsigned sizeI=0,
00153                    unsigned sizeJ=0,
00154                    float _lb= 0.0f,
00155                    float _ub= Infinity,
00156                    const std::string & nom = "unknow",
00157                    const std::string & milieu = "",
00158                    const std::string & fin = "" )
00159     :NumVarMatrix( _modele,sizeI,sizeJ,_lb,_ub,MuteVar::FLOAT,nom,milieu,fin) {}
00160 };
00161 
00163 class BoolVarMatrix: public NumVarMatrix
00164 {
00165   public:
00166     BoolVarMatrix( Model &_modele,
00167                   unsigned sizeI=0,
00168                   unsigned sizeJ=0,
00169                   const std::string & nom = "unknow",
00170                   const std::string & milieu = "",
00171                   const std::string & fin = "" )
00172     :NumVarMatrix( _modele,sizeI,sizeJ,0.0f,1.0f,MuteVar::BOOL,nom,milieu,fin) {}
00173 };
00174 
00175 #ifdef COMPILE_FOR_PYTHON
00176     void export_NumVarMatrix();
00177 #endif
00178 
00179 }
00180 
00181 #endif

Généré le Sun Oct 2 19:13:11 2005 pour Modelib par  doxygen 1.4.4