blob: 579db258cf34905922a8e5ab75e06bb76c32eff4 (
about) (
plain)
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
|
#include <iostream>
#include <vector>
#include <math.h>
#include "Operator.hpp"
#include "Expression.hpp"
#include "EquationSystem.hpp"
#include "MaxStrategy.hpp"
using namespace std;
/*template<typename T>
struct Complete {
Complete(const T& value)
: _value(value) { }
private:
bool _infinity;
T _value;
};*/
typedef std::vector<Expression<float>*> Args;
typedef Expression<float> E;
typedef Constant<float> C;
typedef Minimum<float> Min;
std::vector< Expression<float>* > empty;
int main () {
EquationSystem<float> sys;
Variable<float>* x = sys.newVariable("x");
Args incArgs;
incArgs.push_back(new E(x, empty));
Args minArgs;
minArgs.push_back(new E(new Increment<float>, incArgs));
minArgs.push_back(new E(new C(100), empty));
Args maxArgs;
maxArgs.push_back(new E(new C(0), empty));
maxArgs.push_back(new E(new Min(), minArgs));
sys[*x] = sys.newMaxExpression(maxArgs);
// x = max(0, min(x+1, 100))
cout << sys.minFixpoint()[*x] << endl;
// -> 100, as expected
return 0;
}
|