MP_variable.hpp

Go to the documentation of this file.
00001 // ******************** FlopCpp **********************************************
00002 // File: MP_variable.hpp
00003 // $Id$
00004 // Author: Tim Helge Hultberg (thh@mat.ua.pt)
00005 // Copyright (C) 2003 Tim Helge Hultberg
00006 // All Rights Reserved.
00007 //****************************************************************************
00008 
00009 #ifndef _MP_variable_hpp_
00010 #define _MP_variable_hpp_
00011 
00012 #include "MP_set.hpp"
00013 #include "MP_index.hpp"
00014 #include "MP_expression.hpp"
00015 #include "MP_domain.hpp"
00016 #include "MP_data.hpp"
00017 
00018 namespace flopc {
00019 
00023     enum variableType {continuous, discrete};
00024 
00025     class MP_model;
00026     class MP_variable;
00027 
00032     class VariableRef : public TerminalExpression {
00033         friend class MP_variable;
00034     public:
00035         int getColumn() const;
00036     private:
00037         VariableRef(MP_variable* v, 
00038                     const MP_index_exp& i1,
00039                     const MP_index_exp& i2,
00040                     const MP_index_exp& i3,
00041                     const MP_index_exp& i4,
00042                     const MP_index_exp& i5);
00043 
00044         double level() const;
00045 
00046         void insertVariables(set<MP_variable*>& v) const {
00047             v.insert(V);
00048         }
00049         double getValue() const { 
00050             return 1.0;
00051         }
00052         int getStage() const { 
00053             return 0;
00054         }
00055         void generate(const MP_domain& domain,
00056                       vector<Constant> multiplicators,
00057                       GenerateFunctor& f,
00058                       double m) const;
00059         MP_variable* V;
00060         int offset;
00061         const MP_index_exp I1,I2,I3,I4,I5;
00062     };
00063 
00064 
00072     class MP_variable : public RowMajor, public Functor , public Named{
00073         friend class MP_model;
00074         friend class DisplayVariable;
00075         friend class VariableRef;
00076     public:
00077         MP_variable(const MP_set_base &s1 = MP_set::getEmpty(), 
00078                     const MP_set_base &s2 = MP_set::getEmpty(), 
00079                     const MP_set_base &s3 = MP_set::getEmpty(),
00080                     const MP_set_base &s4 = MP_set::getEmpty(), 
00081                     const MP_set_base &s5 = MP_set::getEmpty());
00082 
00083         void display(const std::string &s = "");  
00084 
00085         ~MP_variable() {
00086         }
00087 
00089         double level(int i1=0, int i2=0, int i3=0, int i4=0, int i5=0);
00090 
00092         const VariableRef& operator()(
00093             const MP_index_exp& d1 = MP_index_exp::getEmpty(), 
00094             const MP_index_exp& d2 = MP_index_exp::getEmpty(), 
00095             const MP_index_exp& d3 = MP_index_exp::getEmpty(),
00096             const MP_index_exp& d4 = MP_index_exp::getEmpty(), 
00097             const MP_index_exp& d5 = MP_index_exp::getEmpty()
00098             ) {
00099             return *new VariableRef(this, d1, d2, d3, d4, d5);
00100         }
00101     
00102         //void display(string s = "");  
00103 
00105         void binary() { 
00106             upperLimit.initialize(1);
00107             type = discrete; 
00108         }
00109 
00111         void integer() { 
00112             type = discrete; 
00113         }
00114  
00116         MP_data upperLimit;
00118         MP_data lowerLimit;
00119     private:
00120         void operator()() const;
00121         const MP_set_base *S1, *S2, *S3, *S4, *S5;
00122         MP_index i1,i2,i3,i4,i5;
00123 
00124         MP_model *M;
00125         variableType type;
00126         int offset;
00127     };
00128 
00133     class MP_binary_variable : public MP_variable {
00134     public:
00135         MP_binary_variable(const MP_set_base &s1 = MP_set::getEmpty(), 
00136                            const MP_set_base &s2 = MP_set::getEmpty(), 
00137                            const MP_set_base &s3 = MP_set::getEmpty(),
00138                            const MP_set_base &s4 = MP_set::getEmpty(), 
00139                            const MP_set_base &s5 = MP_set::getEmpty()) :
00140             MP_variable(s1,s2,s3,s4,s5) {
00141             binary();
00142         }
00143     };
00144 
00145 } // End of namespace flopc
00146 #endif 

Generated on Fri Aug 26 03:02:58 2011 for FLOPC++ by  doxygen 1.4.7