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

Expr.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 __EXPR_H_
00033 #define __EXPR_H_
00034 
00035 #include <list>
00036 #include <iostream>
00037 
00038 #include "ExprNode.h"
00039 
00040 namespace Modelib {
00041 
00042 class Num;
00043 class NumArray;
00044 class NumVar;
00045 class NumVarArray;
00046 class LagrangianParam;
00047 
00048 
00050 
00062 class Expr
00063 {
00064   std::list<ExprNode> nodeList;
00065   protected:
00070     Expr & operator+=(const ExprNode & _node)
00071     {
00072       nodeList.push_back(_node);
00073       isSimplified = false;
00074       return *this;
00075     }
00076     
00077     void Simplify(bool AvecLagrangianParam = false,bool SansConstantes = false);
00078     
00079     bool isSimplified;
00080     bool isParametric;
00081     bool sansConstantes;
00082 
00083     friend class Model;
00084   public:
00085     Expr() {}
00086     Expr( const NumVar & numVar);
00087     Expr( float );
00088     Expr( double );
00089     Expr( int );
00090     Expr( unsigned );
00091     Expr( const Num & num);
00092     Expr( const Num & num, const NumVar & numVar);
00093     Expr( const Num & num, const NumVar & numVar, const LagrangianParam & mult);
00095     Expr( const Expr & _expr) { *this = _expr; }
00096     
00098     Expr & operator= ( const Expr & _expr)
00099     {
00100         if( this != &_expr )
00101         {
00102             nodeList = _expr.nodeList;
00103             isSimplified =  _expr.isSimplified;
00104             isParametric = _expr.isParametric;
00105             sansConstantes = _expr.sansConstantes;
00106         }
00107         return *this;
00108     }
00109     
00110     Expr & operator+=( const Expr & );
00111     Expr & operator-=( const Expr & );
00112 
00113     Expr & operator*=(const Num &);
00114 
00115     Expr & ASS( const Num & num, const NumVar & numVar );
00116     Expr & ASS( const Num & num, const NumVar & numVar, const LagrangianParam & mult );
00117 
00121     unsigned Size() { return nodeList.size(); }
00122     bool IsNum();
00123     bool IsVar();
00124     float GetConstant(bool avecLagrangianParam = true) const;
00125     float Evalue(bool avecLagrangianParam = true) const;
00126 
00127     friend std::ostream & operator<< ( std::ostream & flux, const Expr & expr);
00128     friend std::ostream& operator<<(std::ostream& o,const Model& m);
00129 
00130     ~Expr() {}
00131 }; 
00132 
00133 //Operateurs de constructions d'expressions
00134 Expr operator*( const Num & , const NumVar &);
00135 Expr operator*( const NumVar & , const Num &);
00136 Expr operator*( const NumVarArray & , const NumArray &);
00137 Expr operator*( const NumArray & , const NumVarArray &);
00138 Expr operator*( const Expr &, const Num & );
00139 Expr operator*( const Num & , const Expr &);
00140 Expr operator+( const Expr &, const Expr &);
00141 Expr operator-( const Expr &, const Expr &);
00142 
00143 
00144 std::ostream & operator<< (std::ostream & flux,const Expr & expr);
00145 
00146 Expr Sum(const NumVarArray & );
00147 
00148 }
00149 
00150 #endif

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