diff options
author | Carlo Zancanaro <carlo@carlo-laptop> | 2012-07-09 03:36:11 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@carlo-laptop> | 2012-07-09 03:36:11 +1000 |
commit | f7d846f18354e254353bc417ed1a666c59ef3ea2 (patch) | |
tree | 7d2b94142c48712c5bdfa61551811e03518b803b /impl/EquationSystem.hpp | |
parent | b8045f2fa861959cdd87bd88dc2c6be98c115ec8 (diff) |
Better implementation: smarter strategy iteration
Also add the beginnings of some log stuff, mayhaps.
Diffstat (limited to 'impl/EquationSystem.hpp')
-rw-r--r-- | impl/EquationSystem.hpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/impl/EquationSystem.hpp b/impl/EquationSystem.hpp index 5549674..d09bef2 100644 --- a/impl/EquationSystem.hpp +++ b/impl/EquationSystem.hpp @@ -9,23 +9,11 @@ #include "VariableAssignment.hpp" template<typename Domain> -struct EquationSystem { - virtual ~EquationSystem() { } - virtual const Expression<Domain>* operator[](const Variable<Domain>&) const = 0; - virtual VariableAssignment<Domain>* eval(const VariableAssignment<Domain>& rho) const = 0; - - virtual unsigned int variableCount() const = 0; - virtual Variable<Domain>& variable(unsigned int) const = 0; - - virtual StableVariableAssignment<Domain>* assignment(const Domain& value) const = 0; - virtual Variable<Domain>* varFromExpr(const Expression<Domain>& expr) const = 0; - virtual bool equalAssignments(const VariableAssignment<Domain>&, const VariableAssignment<Domain>&) const = 0; - virtual void print(std::ostream& cout) const = 0; -}; +struct MaxStrategy; template<typename Domain> -struct ConcreteEquationSystem : public EquationSystem<Domain> { - virtual ~ConcreteEquationSystem() { +struct EquationSystem { + virtual ~EquationSystem() { for (typename std::set<Expression<Domain>*>::iterator it = _expressions.begin(); it != _expressions.end(); ++it) { @@ -109,6 +97,17 @@ struct ConcreteEquationSystem : public EquationSystem<Domain> { } return result; } + VariableAssignment<Domain>* eval(const VariableAssignment<Domain>& rho, const MaxStrategy<Domain>& strat) const { + StableVariableAssignment<Domain>* result = this->assignment(-infinity<Domain>()); + for (unsigned int i = 0, length = _variables.size(); + i < length; + ++i) { + const Variable<Domain>& var = *_variables[i]; + const Expression<Domain>& expr = * (*this)[var]; + (*result)[var] = expr.eval(rho, strat); + } + return result; + } Variable<Domain>* varFromExpr(const Expression<Domain>& expr) const { for (unsigned int i = 0, length = _right_sides.size(); i < length; ++i) { @@ -152,4 +151,6 @@ std::ostream& operator<<(std::ostream& cout, const EquationSystem<T>& system) { return cout; } +#include "MaxStrategy.hpp" + #endif |