-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVariables.h
executable file
·122 lines (77 loc) · 1.83 KB
/
Variables.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#ifndef VARIABLES_H
#define VARIABLES_H
#include <vector>
#include <string>
#define BIG_INTEGER 1000000
#define BIG_FLOAT 1000000
using std::string;
namespace VariableTypes
{
typedef int Type;
enum { Unknown = -1, Float = 0, Integer = 1, Boolian = 2 };
};
class Model;
class BaseVar
{
friend class Model;
public:
BaseVar();
int getLocalIndex() const;
int getGlobalIndex() const;
VariableTypes::Type getType() const;
string getName() const;
BaseVar& setName(string name);
protected:
int localIndex_;
int globalIndex_;
bool active_;
string name_;
VariableTypes::Type type_;
void setLocalIndex(int index);
void setGlobalIndex(int index);
void activate();
};
class FloatVar : public BaseVar
{
public:
FloatVar();
FloatVar(double lowerBound);
FloatVar(double lowerBound, double upperBound);
double getLowerBound() const;
double getUpperBound() const;
bool hasLowerBound() const;
bool hasUpperBound() const;
FloatVar* setLowerBound(Model& env, double lb);
FloatVar* setUpperBound(Model& env, double ub);
private:
double lowerBound_;
double upperBound_;
bool hasLowerBound_;
bool hasUpperBound_;
};
class IntVar : public BaseVar
{
public:
IntVar();
IntVar(int lowerBound);
IntVar(int lowerBound, int upperBound);
int getLowerBound() const;
int getUpperBound() const;
IntVar* setLowerBound(Model& env, int lb);
IntVar* setUpperBound(Model& env, int ub);
private:
int lowerBound_;
int upperBound_;
};
class BoolVar : public BaseVar
{
public:
BoolVar();
BoolVar(bool sense);
bool isTrue() const;
BoolVar* setSense(Model& env, bool sense);
private:
bool sense_;
};
#endif