FlopCpp trunk
Loading...
Searching...
No Matches
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
21namespace 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;
62 MP_variable* V;
63 int offset;
64 const MP_index_exp I1,I2,I3,I4,I5;
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
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;
125 MP_index i1,i2,i3,i4,i5;
126
127 MP_model *M;
128 variableType type;
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
Function object.
Specialized subclass of MP_variable where the variable is pre-specified to be binary.
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())
Input data set.
Definition: MP_data.hpp:71
void initialize(double d)
similar to value() but copies the same value to all entries.
Definition: MP_data.hpp:79
Representation of an expression involving an index.
Definition: MP_index.hpp:145
static const MP_index_exp & getEmpty()
Return the unique empty expression.
Representation of an index.
Definition: MP_index.hpp:53
This is the anchor point for all constructs in a FlopC++ model.
Definition: MP_model.hpp:89
Internal representation of a "set".
Definition: MP_set.hpp:28
static MP_set & getEmpty()
gets the distinct 'empty' MP_set.
Symantic representation of a variable.
Definition: MP_variable.hpp:75
void binary()
Call this method to turn the variable into a binary variable.
friend class VariableRef
Definition: MP_variable.hpp:78
MP_data upperLimit
Upper bound on the variable value.
MP_data lowerLimit
Lower bound on the variable value.
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.
void display(const std::string &s="")
friend class DisplayVariable
Definition: MP_variable.hpp:77
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 integer()
Call this method to turn the MP_variable into an integer variable.
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())
Utility interface class for adding a string name onto a structure.
Utility class to flatten multidimensional information into single dimentional offset information.
The base class for all expressions.
Semantic representation of a variable in a Math Program.
Definition: MP_variable.hpp:35
friend class MP_variable
Definition: MP_variable.hpp:36
int getColumn() const
variableType
Enumeration for indicating variable type.
Definition: MP_variable.hpp:26
@ discrete
Definition: MP_variable.hpp:26
@ continuous
Definition: MP_variable.hpp:26
All flopc++ code is contained within the flopc namespace.
Definition: flopc.hpp:49