summaryrefslogtreecommitdiff
path: root/impl/Operator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/Operator.hpp')
-rw-r--r--impl/Operator.hpp43
1 files changed, 19 insertions, 24 deletions
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<typename T>
struct Variable;
-template<typename T>
-struct VariableSet : public IdSet<const Variable<T> > {};
template<typename T>
struct VariableAssignment;
@@ -24,35 +22,32 @@ struct Expression;
template<typename T>
struct Operator {
virtual ~Operator() { }
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& rho) const {
- return (*this)(args, rho, (VariableSet<T>*) NULL);
- }
- virtual T operator() (const std::vector< Expression<T>* >&, const VariableAssignment<T>&, VariableSet<T>*) const = 0;
+ virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& rho) const = 0;
};
template<typename T>
struct Maximum : public Operator<T> {
- virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& assignment, VariableSet<T>* visited) const {
+ virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& assignment) const {
T value = -infinity<T>();
for (typename std::vector< Expression<T>* >::const_iterator it = args.begin();
it != args.end();
++it) {
- T temporary = (**it)(assignment, visited);
- value = (temporary < value ? value : temporary);
- if (value == infinity<T>()) break;
+ T temporary = (**it)(assignment);
+ value = (temporary > value ? temporary : value);
+ //if (value == infinity<T>()) break;
}
return value;
}
};
template<typename T>
struct Minimum : public Operator<T> {
- virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& assignment, VariableSet<T>* visited) const {
+ virtual T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& assignment) const {
T value = infinity<T>();
for (typename std::vector< Expression<T>* >::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<T>()) break;
+ //if (value == -infinity<T>()) break;
}
return value;
}
@@ -62,7 +57,7 @@ template<typename T>
struct Constant : public Operator<T> {
Constant(const T& val)
: _value(val) { }
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass, VariableSet<T>*) const {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
return _value;
}
private:
@@ -71,10 +66,10 @@ struct Constant : public Operator<T> {
template<typename T>
struct Addition: public Operator<T> {
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass, VariableSet<T>* visited) const {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& 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<T> {
template<typename T>
struct Subtraction: public Operator<T> {
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass, VariableSet<T>* visited) const {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& 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<T> {
template<typename T>
struct Comma: public Operator<T> {
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass, VariableSet<T>* visited) const {
- if ((*args[0])(ass, visited) == -infinity<T>()) {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
+ if ((*args[0])(ass) == -infinity<T>()) {
std::cout << "Comma - neg inf" << std::endl;
return -infinity<T>();
} else {
std::cout << "Comma - finite" << std::endl;
- return (*args[1])(ass, visited);
+ return (*args[1])(ass);
}
}
};
template<typename T>
struct Guard: public Operator<T> {
- T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass, VariableSet<T>* visited) const {
- if ((*args[0])(ass, visited) < (*args[1])(ass, visited)) {
+ T operator() (const std::vector< Expression<T>* >& args, const VariableAssignment<T>& ass) const {
+ if ((*args[0])(ass) < (*args[1])(ass)) {
return -infinity<T>();
} else {
- return (*args[2])(ass, visited);
+ return (*args[2])(ass);
}
}
};