summaryrefslogtreecommitdiff
path: root/impl/MaxStrategy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/MaxStrategy.hpp')
-rw-r--r--impl/MaxStrategy.hpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/impl/MaxStrategy.hpp b/impl/MaxStrategy.hpp
index 8f40c99..d15884c 100644
--- a/impl/MaxStrategy.hpp
+++ b/impl/MaxStrategy.hpp
@@ -12,6 +12,16 @@ struct MaxStrategy {
virtual unsigned int get(const MaxExpression<Domain>& e) const = 0;
};
+unsigned int stack_depth = 1;
+
+std::string indent() {
+ std::string result = "";
+ for (unsigned int i = 0; i < stack_depth; ++i) {
+ result += '\t';
+ }
+ return result;
+}
+
#include "VariableAssignment.hpp"
template<typename Domain>
@@ -41,7 +51,7 @@ struct DynamicMaxStrategy : public MaxStrategy<Domain> {
}
void invalidate(const Variable<Domain>& v) const {
- log::strategy << "\tInvalidating " << v << " - " << *_system[v] << std::endl;
+ log::strategy << indent() << "Invalidating " << v << " - " << *_system[v] << std::endl;
_stable.filter(_var_influence[v]);
for (auto it = _var_influence[v].begin();
@@ -55,10 +65,12 @@ private:
void solve(const MaxExpression<Domain>& x) const {
if (!_stable.contains(x)) {
_stable.insert(x);
- log::strategy << "\tStabilise " << x << std::endl;
+ log::strategy << indent() << "Stabilise " << x << std::endl;
+ stack_depth++;
unsigned int val = x.bestStrategy(DependencyAssignment(*this, *_rho, x),
DependencyStrategy(*this, x));
+ stack_depth--;
if (val != _values[x]) {
log::strategy << x << " => " << *x.arguments()[val] << std::endl;
@@ -77,10 +89,10 @@ private:
solve(_system.maxExpression(*it));
}
} else {
- log::strategy << "\t" << x << " did not change" << std::endl;
+ log::strategy << indent() << x << " did not change" << std::endl;
}
} else {
- log::strategy << "\t" << x << " is stable" << std::endl;
+ log::strategy << indent() << x << " is stable" << std::endl;
}
}