-
Notifications
You must be signed in to change notification settings - Fork 4
/
ConstraintGroup.h
163 lines (136 loc) · 4.18 KB
/
ConstraintGroup.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef CONSTRAINTGROUP_H
#define CONSTRAINTGROUP_H
#include <cstdlib>
#include <iostream>
#include <string>
#include "LocatingArray.h"
#include "FactorData.h"
using namespace std;
class LocatingArray;
class BoolResult {
protected:
LocatingArray *array;
public:
BoolResult(LocatingArray *array);
static BoolResult *readBoolResult(LocatingArray *array, ifstream &ifs);
virtual bool getResult(int test) = 0;
virtual void writeToStream(ofstream &ofs) = 0;
virtual ~BoolResult();
};
class FloatResult {
protected:
LocatingArray *array;
public:
FloatResult(LocatingArray *array);
static FloatResult *readFloatResult(LocatingArray *array, ifstream &ifs);
virtual float getResult(int test) = 0;
virtual void writeToStream(ofstream &ofs) = 0;
virtual ~FloatResult();
};
class ConstraintGroup {
private:
LocatingArray *groupLA;
int constraints;
BoolResult** boolConstraints;
// there exists a weight window for each row (larger weight window means more likely to be chosen)
int *weightMin; // bottom of weight window for each row
int *weightMax; // top of weight window for each row
int weightRandMax;
public:
int factors;
int *factorIndeces;
ConstraintGroup(LocatingArray *array, ifstream &ifs);
void populateGroupLA(LocatingArray *array, char *levelRow, char *factorLevels, int fixedFactors, int **settingCount, int &fullFactorialCount);
bool satisfiableInGroupLA(char *requireLevelRow, char *avoidLevelRow);
virtual bool getResult(int test);
void randPopulateLevelRow(char *levelRow);
void writeToStream(ofstream &ofs);
virtual ~ConstraintGroup();
};
class EqResult: public BoolResult {
private:
FloatResult *floatResult1; // LHS of Eq equation
FloatResult *floatResult2; // RHS of Eq equation
public:
EqResult(LocatingArray *array, ifstream &ifs);
virtual bool getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~EqResult();
};
class LtEqResult: public BoolResult {
private:
FloatResult *floatResult1; // LHS of LtEq equation
FloatResult *floatResult2; // RHS of LtEq equation
public:
LtEqResult(LocatingArray *array, ifstream &ifs);
virtual bool getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~LtEqResult();
};
class GtResult: public BoolResult {
private:
FloatResult *floatResult1; // LHS of Gt equation
FloatResult *floatResult2; // RHS of Gt equation
public:
GtResult(LocatingArray *array, ifstream &ifs);
virtual bool getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~GtResult();
};
class IfResult: public BoolResult {
private:
BoolResult *boolResult1; // If this is true
BoolResult *boolResult2; // Then this must also be true
public:
IfResult(LocatingArray *array, ifstream &ifs);
virtual bool getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~IfResult();
};
class AdditionResult: public FloatResult {
private:
FloatResult *floatResult1;
FloatResult *floatResult2;
public:
AdditionResult(LocatingArray *array, ifstream &ifs);
virtual float getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~AdditionResult();
};
class MultiplicationResult: public FloatResult {
private:
FloatResult *floatResult1;
FloatResult *floatResult2;
public:
MultiplicationResult(LocatingArray *array, ifstream &ifs);
virtual float getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~MultiplicationResult();
};
class DivisionResult: public FloatResult {
private:
FloatResult *floatResult1;
FloatResult *floatResult2;
public:
DivisionResult(LocatingArray *array, ifstream &ifs);
virtual float getResult(int test);
virtual void writeToStream(ofstream &ofs);
virtual ~DivisionResult();
};
class ConstantResult: public FloatResult {
private:
float value;
public:
ConstantResult(LocatingArray *array, ifstream &ifs);
float getResult(int test);
virtual void writeToStream(ofstream &ofs);
};
class FactorAssignment: public FloatResult {
private:
int factor_i;
public:
FactorAssignment(LocatingArray *array, ifstream &ifs);
float getResult(int test);
virtual void writeToStream(ofstream &ofs);
};
#endif