From 0cca9a599a66758cbb5a958b619de3315f26b528 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Thu, 5 Jul 2012 16:39:32 +1000 Subject: Intermediate (broken) commit - smarter strategy --- impl/EquationSystem.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'impl/EquationSystem.hpp') diff --git a/impl/EquationSystem.hpp b/impl/EquationSystem.hpp index 50a0e45..5549674 100644 --- a/impl/EquationSystem.hpp +++ b/impl/EquationSystem.hpp @@ -13,11 +13,13 @@ struct EquationSystem { virtual ~EquationSystem() { } virtual const Expression* operator[](const Variable&) const = 0; virtual VariableAssignment* eval(const VariableAssignment& rho) const = 0; + virtual unsigned int variableCount() const = 0; virtual Variable& variable(unsigned int) const = 0; + virtual StableVariableAssignment* assignment(const Domain& value) const = 0; + virtual Variable* varFromExpr(const Expression& expr) const = 0; virtual bool equalAssignments(const VariableAssignment&, const VariableAssignment&) const = 0; - virtual void print(std::ostream& cout) const = 0; }; @@ -86,10 +88,10 @@ struct ConcreteEquationSystem : public EquationSystem { return *constant; } - Expression* operator[](const Variable& var) const { + MaxExpression* operator[](const Variable& var) const { return _right_sides[var.id()]; } - Expression*& operator[](const Variable& var) { + MaxExpression*& operator[](const Variable& var) { return _right_sides[var.id()]; } @@ -108,6 +110,14 @@ struct ConcreteEquationSystem : public EquationSystem { return result; } + Variable* varFromExpr(const Expression& expr) const { + for (unsigned int i = 0, length = _right_sides.size(); i < length; ++i) { + if (_right_sides[i] == &expr) + return _variables[i]; + } + return NULL; + } + virtual bool equalAssignments(const VariableAssignment& l, const VariableAssignment& r) const { for (unsigned int i = 0, length = _variables.size(); i < length; @@ -133,7 +143,7 @@ struct ConcreteEquationSystem : public EquationSystem { std::vector*> _variables; std::map*> _variable_names; std::vector*> _max_expressions; - std::vector*> _right_sides; + std::vector*> _right_sides; }; template -- cgit v1.2.3