diff options
author | Carlo Zancanaro <carlo@carlo-laptop> | 2012-05-28 21:50:12 +1000 |
---|---|---|
committer | Carlo Zancanaro <carlo@carlo-laptop> | 2012-05-28 21:50:12 +1000 |
commit | f09ce60d45d5524e36d07e76814b6e0cbc554288 (patch) | |
tree | 3e7e786a6f0b20ddcd934969c93c09cc02625f70 /impl/MaxStrategy.hpp | |
parent | 72b70a4ff7dad8185eb2dd652bdd2983b829930a (diff) |
Fix issues with some things ignoring strategies.
Diffstat (limited to 'impl/MaxStrategy.hpp')
-rw-r--r-- | impl/MaxStrategy.hpp | 15 |
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; } |