00001
00002
00003
00004
00005
00006
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
00035 class MP_variable : public RowMajor, public Functor , public Named {
00036 friend class MP_model;
00037 friend class DisplayVariable;
00038 friend class VariableRef;
00039 public:
00040 MP_variable(const MP_set_base &s1 = MP_set::getEmpty(),
00041 const MP_set_base &s2 = MP_set::getEmpty(),
00042 const MP_set_base &s3 = MP_set::getEmpty(),
00043 const MP_set_base &s4 = MP_set::getEmpty(),
00044 const MP_set_base &s5 = MP_set::getEmpty());
00045
00046 void display(const std::string &s = "");
00047
00048 ~MP_variable() {
00049 }
00050
00052 double level(int i1=0, int i2=0, int i3=0, int i4=0, int i5=0);
00053
00055 const VariableRef& operator()(
00056 const MP_index_exp& d1 = MP_index_exp::getEmpty(),
00057 const MP_index_exp& d2 = MP_index_exp::getEmpty(),
00058 const MP_index_exp& d3 = MP_index_exp::getEmpty(),
00059 const MP_index_exp& d4 = MP_index_exp::getEmpty(),
00060 const MP_index_exp& d5 = MP_index_exp::getEmpty()
00061 ) {
00062 return *new VariableRef(this, d1, d2, d3, d4, d5);
00063 }
00064
00065
00066
00068 void binary() {
00069 upperLimit.initialize(1);
00070 type = discrete;
00071 }
00072
00074 void integer() {
00075 type = discrete;
00076 }
00077
00079 MP_data upperLimit;
00081 MP_data lowerLimit;
00082 private:
00083 void operator()() const;
00084 const MP_set_base *S1, *S2, *S3, *S4, *S5;
00085 MP_index i1,i2,i3,i4,i5;
00086
00087 MP_model *M;
00088 variableType type;
00089 int offset;
00090 };
00091
00096 class MP_binary_variable : public MP_variable {
00097 public:
00098 MP_binary_variable(const MP_set_base &s1 = MP_set::getEmpty(),
00099 const MP_set_base &s2 = MP_set::getEmpty(),
00100 const MP_set_base &s3 = MP_set::getEmpty(),
00101 const MP_set_base &s4 = MP_set::getEmpty(),
00102 const MP_set_base &s5 = MP_set::getEmpty()) :
00103 MP_variable(s1,s2,s3,s4,s5) {
00104 binary();
00105 }
00106 };
00107
00108 }
00109 #endif