From f09ce60d45d5524e36d07e76814b6e0cbc554288 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 28 May 2012 21:50:12 +1000 Subject: Fix issues with some things ignoring strategies. --- impl/Operator.hpp | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'impl/Operator.hpp') diff --git a/impl/Operator.hpp b/impl/Operator.hpp index 80bc8b2..5f7cd1e 100644 --- a/impl/Operator.hpp +++ b/impl/Operator.hpp @@ -13,8 +13,6 @@ float infinity() { template struct Variable; -template -struct VariableSet : public IdSet > {}; template struct VariableAssignment; @@ -24,35 +22,32 @@ struct Expression; template struct Operator { virtual ~Operator() { } - T operator() (const std::vector< Expression* >& args, const VariableAssignment& rho) const { - return (*this)(args, rho, (VariableSet*) NULL); - } - virtual T operator() (const std::vector< Expression* >&, const VariableAssignment&, VariableSet*) const = 0; + virtual T operator() (const std::vector< Expression* >& args, const VariableAssignment& rho) const = 0; }; template struct Maximum : public Operator { - virtual T operator() (const std::vector< Expression* >& args, const VariableAssignment& assignment, VariableSet* visited) const { + virtual T operator() (const std::vector< Expression* >& args, const VariableAssignment& assignment) const { T value = -infinity(); for (typename std::vector< Expression* >::const_iterator it = args.begin(); it != args.end(); ++it) { - T temporary = (**it)(assignment, visited); - value = (temporary < value ? value : temporary); - if (value == infinity()) break; + T temporary = (**it)(assignment); + value = (temporary > value ? temporary : value); + //if (value == infinity()) break; } return value; } }; template struct Minimum : public Operator { - virtual T operator() (const std::vector< Expression* >& args, const VariableAssignment& assignment, VariableSet* visited) const { + virtual T operator() (const std::vector< Expression* >& args, const VariableAssignment& assignment) const { T value = infinity(); for (typename std::vector< Expression* >::const_iterator it = args.begin(); it != args.end(); ++it) { - T temporary = (**it)(assignment, visited); + T temporary = (**it)(assignment); value = (temporary < value ? temporary : value); - if (value == -infinity()) break; + //if (value == -infinity()) break; } return value; } @@ -62,7 +57,7 @@ template struct Constant : public Operator { Constant(const T& val) : _value(val) { } - T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass, VariableSet*) const { + T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass) const { return _value; } private: @@ -71,10 +66,10 @@ struct Constant : public Operator { template struct Addition: public Operator { - T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass, VariableSet* visited) const { + T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass) const { T sum = (*args[0])(ass); for (unsigned int i = 1, size = args.size(); i < size; ++i) { - sum += (*args[i])(ass, visited); + sum += (*args[i])(ass); } return sum; } @@ -82,10 +77,10 @@ struct Addition: public Operator { template struct Subtraction: public Operator { - T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass, VariableSet* visited) const { + T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass) const { T sum = (*args[0])(ass); for (unsigned int i = 1, size = args.size(); i < size; ++i) { - sum -= (*args[i])(ass, visited); + sum -= (*args[i])(ass); } return sum; } @@ -93,24 +88,24 @@ struct Subtraction: public Operator { template struct Comma: public Operator { - T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass, VariableSet* visited) const { - if ((*args[0])(ass, visited) == -infinity()) { + T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass) const { + if ((*args[0])(ass) == -infinity()) { std::cout << "Comma - neg inf" << std::endl; return -infinity(); } else { std::cout << "Comma - finite" << std::endl; - return (*args[1])(ass, visited); + return (*args[1])(ass); } } }; template struct Guard: public Operator { - T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass, VariableSet* visited) const { - if ((*args[0])(ass, visited) < (*args[1])(ass, visited)) { + T operator() (const std::vector< Expression* >& args, const VariableAssignment& ass) const { + if ((*args[0])(ass) < (*args[1])(ass)) { return -infinity(); } else { - return (*args[2])(ass, visited); + return (*args[2])(ass); } } }; -- cgit v1.2.3