summaryrefslogtreecommitdiff
path: root/impl/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/main.cpp')
-rw-r--r--impl/main.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/impl/main.cpp b/impl/main.cpp
index 6f84cdd..579db25 100644
--- a/impl/main.cpp
+++ b/impl/main.cpp
@@ -18,30 +18,32 @@ struct Complete {
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> fac;
- Variable<float>* x = fac.newVariable("x");
- Variable<float>* y = fac.newVariable("y");
- VariableAssignment<float> rho(2);
- rho[*x] = 12;
- rho[*y] = 10;
- Expression<float> expr(x, empty);
-
- std::vector<Expression<float>*> args;
- args.push_back(new Expression<float>(x, empty));
- args.push_back(new Expression<float>(y, empty));
- args.push_back(new Expression<float>(new Constant<float>(10), empty));
- MaxExpression<float>* maxExpression = fac.newMaxExpression(args);
- Expression<float>* minExpression = new Expression<float>(new Minimum<float>(), args);
-
-
- MaxStrategy<float> strat(1);
- strat[*maxExpression] = 0;
- cout << strat(*maxExpression,rho) << endl;
-
- fac[*x] = minExpression;
- fac[*y] = minExpression;
- cout << fac.maxFixpoint()[*x] << endl;
+ 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;
}