FLOPC++
MP_variable.hpp
Go to the documentation of this file.
1 // ******************** FlopCpp **********************************************
2 // File: MP_variable.hpp
3 // $Id$
4 // Author: Tim Helge Hultberg (thh@mat.ua.pt)
5 // Copyright (C) 2003 Tim Helge Hultberg
6 // All Rights Reserved.
7 //****************************************************************************
8 
9 #ifndef _MP_variable_hpp_
10 #define _MP_variable_hpp_
11 
12 #include <set>
13 #include <vector>
14 
15 #include "MP_set.hpp"
16 #include "MP_index.hpp"
17 #include "MP_expression.hpp"
18 #include "MP_domain.hpp"
19 #include "MP_data.hpp"
20 
21 namespace flopc {
22 
27 
28  class MP_model;
29  class MP_variable;
30 
36  friend class MP_variable;
37  public:
38  int getColumn() const;
39  private:
41  const MP_index_exp& i1,
42  const MP_index_exp& i2,
43  const MP_index_exp& i3,
44  const MP_index_exp& i4,
45  const MP_index_exp& i5);
46 
47  double level() const;
48 
49  void insertVariables(std::set<MP_variable*>& v) const {
50  v.insert(V);
51  }
52  double getValue() const {
53  return 1.0;
54  }
55  int getStage() const {
56  return 0;
57  }
58  void generate(const MP_domain& domain,
59  std::vector<Constant> multiplicators,
60  GenerateFunctor& f,
61  double m) const;
63  int offset;
65  };
66 
67 
75  class MP_variable : public RowMajor, public Functor , public Named{
76  friend class MP_model;
77  friend class DisplayVariable;
78  friend class VariableRef;
79  public:
81  const MP_set_base &s2 = MP_set::getEmpty(),
82  const MP_set_base &s3 = MP_set::getEmpty(),
83  const MP_set_base &s4 = MP_set::getEmpty(),
84  const MP_set_base &s5 = MP_set::getEmpty());
85 
86  void display(const std::string &s = "");
87 
89  }
90 
92  double level(int i1=0, int i2=0, int i3=0, int i4=0, int i5=0);
93 
96  const MP_index_exp& d1 = MP_index_exp::getEmpty(),
97  const MP_index_exp& d2 = MP_index_exp::getEmpty(),
99  const MP_index_exp& d4 = MP_index_exp::getEmpty(),
101  ) {
102  return *new VariableRef(this, d1, d2, d3, d4, d5);
103  }
104 
105  //void display(string s = "");
106 
108  void binary() {
110  type = discrete;
111  }
112 
114  void integer() {
115  type = discrete;
116  }
117 
122  private:
123  void operator()() const;
124  const MP_set_base *S1, *S2, *S3, *S4, *S5;
126 
129  int offset;
130  };
131 
137  public:
139  const MP_set_base &s2 = MP_set::getEmpty(),
140  const MP_set_base &s3 = MP_set::getEmpty(),
141  const MP_set_base &s4 = MP_set::getEmpty(),
142  const MP_set_base &s5 = MP_set::getEmpty()) :
143  MP_variable(s1,s2,s3,s4,s5) {
144  binary();
145  }
146  };
147 
148 } // End of namespace flopc
149 #endif
const MP_index_exp I2
Definition: MP_variable.hpp:64
void operator()() const
Definition: MP_variable.cpp:84
static MP_set & getEmpty()
gets the distinct &#39;empty&#39; MP_set.
Definition: MP_set.cpp:17
MP_variable(const MP_set_base &s1=MP_set::getEmpty(), const MP_set_base &s2=MP_set::getEmpty(), const MP_set_base &s3=MP_set::getEmpty(), const MP_set_base &s4=MP_set::getEmpty(), const MP_set_base &s5=MP_set::getEmpty())
Definition: MP_variable.cpp:64
const MP_index_exp I3
Definition: MP_variable.hpp:64
const VariableRef & operator()(const MP_index_exp &d1=MP_index_exp::getEmpty(), const MP_index_exp &d2=MP_index_exp::getEmpty(), const MP_index_exp &d3=MP_index_exp::getEmpty(), const MP_index_exp &d4=MP_index_exp::getEmpty(), const MP_index_exp &d5=MP_index_exp::getEmpty())
Interal use only.
Definition: MP_variable.hpp:95
void insertVariables(std::set< MP_variable * > &v) const
Definition: MP_variable.hpp:49
void integer()
Call this method to turn the MP_variable into an integer variable.
void generate(const MP_domain &domain, std::vector< Constant > multiplicators, GenerateFunctor &f, double m) const
Definition: MP_variable.cpp:55
Representation of an index.This is one of the main public interface classes. It is used to iterate th...
Definition: MP_index.hpp:53
friend class DisplayVariable
Definition: MP_variable.hpp:77
MP_data upperLimit
Upper bound on the variable value.
void binary()
Call this method to turn the variable into a binary variable.
const MP_set_base * S1
variableType
Enumeration for indicating variable type.
Definition: MP_variable.hpp:26
void initialize(double d)
similar to value() but copies the same value to all entries.
Definition: MP_data.hpp:79
friend class VariableRef
Definition: MP_variable.hpp:78
Utility interface class for adding a string name onto a structure.
void display(const std::string &s="")
Definition: MP_variable.cpp:98
const MP_index_exp I4
Definition: MP_variable.hpp:64
double level() const
Definition: MP_variable.cpp:31
Representation of an expression involving an index.This is one of the main public interface classes...
Definition: MP_index.hpp:145
const MP_set_base * S5
MP_variable * V
Definition: MP_variable.hpp:62
static const MP_index_exp & getEmpty()
Return the unique empty expression.
Definition: MP_index.cpp:23
This is the anchor point for all constructs in a FlopC++ model.The constructors take an OsiSolverInte...
Definition: MP_model.hpp:89
VariableRef(MP_variable *v, const MP_index_exp &i1, const MP_index_exp &i2, const MP_index_exp &i3, const MP_index_exp &i4, const MP_index_exp &i5)
Definition: MP_variable.cpp:21
double level(int i1=0, int i2=0, int i3=0, int i4=0, int i5=0)
Returns the value of the variable given the specific index values.
Definition: MP_variable.cpp:80
const MP_set_base * S2
Range over which some other constuct is defined.This is one of the main public interface classes...
Definition: MP_domain.hpp:61
int getColumn() const
Definition: MP_variable.cpp:40
int getStage() const
Definition: MP_variable.hpp:55
MP_binary_variable(const MP_set_base &s1=MP_set::getEmpty(), const MP_set_base &s2=MP_set::getEmpty(), const MP_set_base &s3=MP_set::getEmpty(), const MP_set_base &s4=MP_set::getEmpty(), const MP_set_base &s5=MP_set::getEmpty())
Symantic representation of a variable.This is one of the main public interface classes. It should be directly declared by clients of the FlopC++. The parametersof construction are MP_set s which specify the indexes over which the variable is defined.
Definition: MP_variable.hpp:75
Function object. Often used.
const MP_index_exp I5
Definition: MP_variable.hpp:64
Input data set.This is one of the main public interface classes. It is normally directly constructed ...
Definition: MP_data.hpp:71
Functor to facilitate generation of coefficients.
const MP_index_exp I1
Definition: MP_variable.hpp:64
const MP_set_base * S3
Internal representation of a &quot;set&quot;.
Definition: MP_set.hpp:28
variableType type
The base class for all expressions.
const MP_set_base * S4
double getValue() const
Definition: MP_variable.hpp:52
MP_data lowerLimit
Lower bound on the variable value.