summaryrefslogtreecommitdiff
path: root/impl/main.cpp
blob: 814a3eefd5ff141bdc6dbcda2c8b1705a777be65 (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
#include "Constant.h"
#include "Variable.h"
#include "Min.h"
#include "Max.h"
#include "Sum.h"
#include "Equation.h"
#include "EquationSystem.h"

#include <iostream>

using namespace std;

int main() {
  std::map<std::string, int> mappings;
  mappings["x"] = 10;

  Equation<int> e(Variable<int>("x"),
    new Max<int>(
      new Min<int>(
        new Constant<int>(100),
        new Sum<int>(
          new Variable<int>("x"),
          new Constant<int>(100))),
      new Constant<int>(20)));

  Equation<int> e2(Variable<int>("x"),
    new Constant<int>(200));

  EquationSystem<int> es;
  es.add(e);
  es.add(e2);
  std::map<std::string, int> result = es.solve(mappings);
  cout << result["x"] << endl;

  return 0;
}