00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _MP_variable_hpp_
00010 #define _MP_variable_hpp_
00011
00012 #include <set>
00013 #include <vector>
00014
00015 #include "MP_set.hpp"
00016 #include "MP_index.hpp"
00017 #include "MP_expression.hpp"
00018 #include "MP_domain.hpp"
00019 #include "MP_data.hpp"
00020
00021 namespace flopc {
00022
00026 enum variableType {continuous, discrete};
00027
00028 class MP_model;
00029 class MP_variable;
00030
00035 class VariableRef : public TerminalExpression {
00036 friend class MP_variable;
00037 public:
00038 int getColumn() const;
00039 private:
00040 VariableRef(MP_variable* v,
00041 const MP_index_exp& i1,
00042 const MP_index_exp& i2,
00043 const MP_index_exp& i3,
00044 const MP_index_exp& i4,
00045 const MP_index_exp& i5);
00046
00047 double level() const;
00048
00049 void insertVariables(std::set<MP_variable*>& v) const {
00050 v.insert(V);
00051 }
00052 double getValue() const {
00053 return 1.0;
00054 }
00055 int getStage() const {
00056 return 0;
00057 }
00058 void generate(const MP_domain& domain,
00059 std::vector<Constant> multiplicators,
00060 GenerateFunctor& f,
00061 double m) const;
00062 MP_variable* V;
00063 int offset;
00064 const MP_index_exp I1,I2,I3,I4,I5;
00065 };
00066
00067
00075 class MP_variable : public RowMajor, public Functor , public Named{
00076 friend class MP_model;
00077 friend class DisplayVariable;
00078 friend class VariableRef;
00079 public:
00080 MP_variable(const MP_set_base &s1 = MP_set::getEmpty(),
00081 const MP_set_base &s2 = MP_set::getEmpty(),
00082 const MP_set_base &s3 = MP_set::getEmpty(),
00083 const MP_set_base &s4 = MP_set::getEmpty(),
00084 const MP_set_base &s5 = MP_set::getEmpty());
00085
00086 void display(const std::string &s = "");
00087
00088 ~MP_variable() {
00089 }
00090
00092 double level(int i1=0, int i2=0, int i3=0, int i4=0, int i5=0);
00093
00095 const VariableRef& operator()(
00096 const MP_index_exp& d1 = MP_index_exp::getEmpty(),
00097 const MP_index_exp& d2 = MP_index_exp::getEmpty(),
00098 const MP_index_exp& d3 = MP_index_exp::getEmpty(),
00099 const MP_index_exp& d4 = MP_index_exp::getEmpty(),
00100 const MP_index_exp& d5 = MP_index_exp::getEmpty()
00101 ) {
00102 return *new VariableRef(this, d1, d2, d3, d4, d5);
00103 }
00104
00105
00106
00108 void binary() {
00109 upperLimit.initialize(1);
00110 type = discrete;
00111 }
00112
00114 void integer() {
00115 type = discrete;
00116 }
00117
00119 MP_data upperLimit;
00121 MP_data lowerLimit;
00122 private:
00123 void operator()() const;
00124 const MP_set_base *S1, *S2, *S3, *S4, *S5;
00125 MP_index i1,i2,i3,i4,i5;
00126
00127 MP_model *M;
00128 variableType type;
00129 int offset;
00130 };
00131
00136 class MP_binary_variable : public MP_variable {
00137 public:
00138 MP_binary_variable(const MP_set_base &s1 = MP_set::getEmpty(),
00139 const MP_set_base &s2 = MP_set::getEmpty(),
00140 const MP_set_base &s3 = MP_set::getEmpty(),
00141 const MP_set_base &s4 = MP_set::getEmpty(),
00142 const MP_set_base &s5 = MP_set::getEmpty()) :
00143 MP_variable(s1,s2,s3,s4,s5) {
00144 binary();
00145 }
00146 };
00147
00148 }
00149 #endif