summaryrefslogtreecommitdiff
path: root/impl/Expression.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/Expression.hpp')
-rw-r--r--impl/Expression.hpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/impl/Expression.hpp b/impl/Expression.hpp
index 4798e60..d3dfcf3 100644
--- a/impl/Expression.hpp
+++ b/impl/Expression.hpp
@@ -7,6 +7,8 @@
template<typename T>
struct Variable;
+template<typename T>
+struct MaxStrategy;
int ExpressionCount;
@@ -22,9 +24,6 @@ struct Expression {
virtual T operator() (const VariableAssignment<T>& assignment) const {
return (*_operator)(_arguments, assignment);
}
- virtual T operator() (const VariableAssignment<T>& assignment, VariableSet<T>* visited) const {
- return (*_operator)(_arguments, assignment, visited);
- }
protected:
Operator<T>* _operator;
std::vector< Expression<T>* > _arguments;
@@ -46,14 +45,17 @@ struct MaxExpression : public Expression<T> {
}
return Expression<T>::_arguments[i];
}
- std::pair<T, unsigned int> bestStrategy(const VariableAssignment<T>& rho) const {
+ virtual T operator() (const VariableAssignment<T>& assignment) const {
+ throw "error";
+ }
+ std::pair<T, unsigned int> bestStrategy(const VariableAssignment<T>& rho, const MaxStrategy<T>& strat) const {
std::pair<T, unsigned int> best = std::pair<T, unsigned int>(-infinity<T>(), 0);
for (unsigned int i = 0, size = Expression<T>::_arguments.size(); i < size; ++i) {
- T value = (*Expression<T>::_arguments[i])(rho);
+ T value = strat(*Expression<T>::_arguments[i], rho);
if (value > best.first)
best = std::pair<T, unsigned int>(value, i);
}
- std::cerr << "Best strategy: (" << best.first << ", " << best.second << ")" << std::endl;
+ std::cerr << "Best strategy: (" << best.first << ", " << best.second << ")" << std::endl << std::endl;
return best;
}
private:
@@ -61,5 +63,6 @@ struct MaxExpression : public Expression<T> {
};
#include "Variable.hpp"
+#include "MaxStrategy.hpp"
#endif