summaryrefslogtreecommitdiff
path: root/impl/MaxStrategy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/MaxStrategy.hpp')
-rw-r--r--impl/MaxStrategy.hpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/impl/MaxStrategy.hpp b/impl/MaxStrategy.hpp
index a1c50d8..aa49c9d 100644
--- a/impl/MaxStrategy.hpp
+++ b/impl/MaxStrategy.hpp
@@ -59,7 +59,7 @@ struct MaxStrategy {
if (max == NULL) {
return expr(rho);
} else {
- return (*max->argument(_assignment[max->id()]))(rho);
+ return (*this)(*max->argument(_assignment[max->id()]), rho);
}
}
MaxStrategy<T> improve(const EquationSystem<T>& s, const VariableAssignment<T>& rho) const {
@@ -67,16 +67,15 @@ struct MaxStrategy {
for (unsigned int i = 0; i < _length; ++i) {
const MaxExpression<T>& expr = *s.getMax(i);
const T oldValue = (*this)(expr, rho);
- std::pair<const T,unsigned int> best = expr.bestStrategy(rho);
+
+ // this relies on the fact that deeper MaxExpressions have a lower id
+ // than the MaxExpressions containing them. This means that we know that
+ // we have enough of a strategy to work with what we have within us
+ std::pair<const T,unsigned int> best = expr.bestStrategy(rho, newStrategy);
+
if (best.first > oldValue)
newStrategy[expr] = best.second;
}
- std::cerr << "Strat improvement: ";
- if (_length > 0)
- std::cerr << newStrategy[*s.getMax(0)];
- else
- std::cerr << "no max expressions";
- std::cerr << std::endl;
return newStrategy;
}