From 6f49860389b973bf0ec58cdefc63cda41f432d1c Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 5 Nov 2012 18:14:23 +1100 Subject: Remove a bit of junk and fix up the logging again. --- impl/MaxStrategy.hpp | 27 +++++---------------------- impl/VariableAssignment.hpp | 10 +++------- 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'impl') diff --git a/impl/MaxStrategy.hpp b/impl/MaxStrategy.hpp index 1b471e0..32f3e32 100644 --- a/impl/MaxStrategy.hpp +++ b/impl/MaxStrategy.hpp @@ -20,7 +20,7 @@ unsigned int stack_depth = 1; std::string indent() { std::string result = ""; for (unsigned int i = 0; i < stack_depth; ++i) { - result += ' '; + result += '\t'; } return result; } @@ -57,19 +57,6 @@ struct DynamicMaxStrategy : public MaxStrategy { return _values[e]; } - void invalidate(const Variable& v) { - log::strategy << indent() << "Invalidating " << v << " - " << *_system[v] << std::endl; - - IdSet > infl = _influence[*_system[v]]; - for (typename IdSet >::iterator - it = infl.begin(), - end = infl.end(); - it != end; - ++it) { - invalidate(_system.maxExpression(*it)); - } - } - void invalidate(const MaxExpression& v) { if (_stable.contains(v)) { log::strategy << indent() << "Invalidating " << v << std::endl; @@ -90,7 +77,6 @@ struct DynamicMaxStrategy : public MaxStrategy { private: void solve(const MaxExpression& x) { if (!_stable.contains(x)) { - std::cerr << indent() << x.id() << std::endl; _stable.insert(x); log::strategy << indent() << "Stabilise " << x << std::endl; @@ -101,7 +87,6 @@ private: stack_depth--; if (val != _values[x]) { - std::cerr << indent() << "-" << std::endl; log::strategy << x << " => " << *x.arguments()[val] << std::endl; _values[x] = val; @@ -140,13 +125,11 @@ private: _current(strat._system.variableCount()) { } const Domain operator[](const Variable& var) { - // solve the strategy for this variable, too - // recursive magic! - _strat.solve(*_strat._system[var]); - _strat._influence[*_strat._system[var]].insert(_expr); - // force evaluation to get touched variables Domain value = _rho[var]; + + _strat._influence[*_strat._system[var]].insert(_expr); + // invalidate touched variables IdSet > changed = _rho.get_changed(); for (typename IdSet >::iterator @@ -154,7 +137,7 @@ private: ei = changed.end(); it != ei; ++it) { - _strat.invalidate(_strat._system.variable(*it)); + _strat.invalidate(*_strat._system[_strat._system.variable(*it)]); } return value; } diff --git a/impl/VariableAssignment.hpp b/impl/VariableAssignment.hpp index fff00b5..08002b8 100644 --- a/impl/VariableAssignment.hpp +++ b/impl/VariableAssignment.hpp @@ -41,8 +41,8 @@ struct DynamicVariableAssignment : public VariableAssignment { log::fixpoint << indent() << "Invalidating " << x << std::endl; _unstable.insert(x); - _old_values[x] = _values[x]; _touched.insert(x); + _old_values[x] = _values[x]; _values[x] = infinity(); IdSet > infl = _influence[x]; @@ -66,19 +66,15 @@ struct DynamicVariableAssignment : public VariableAssignment { it != ei; ++it) { Variable& var = _system.variable(*it); - //if (_old_values[var] != _values[var]) { + if (!_unstable.contains(var) && _old_values[var] != _values[var]) { changed.insert(var); _touched.remove(var); - //} + } } //_touched.clear(); return changed; } - const IdMap, Domain> get_old_values() const { - return _old_values; - } - private: void solve(const Variable& x) { -- cgit v1.2.3