summaryrefslogtreecommitdiff
path: root/impl
diff options
context:
space:
mode:
Diffstat (limited to 'impl')
-rw-r--r--impl/MaxStrategy.hpp27
-rw-r--r--impl/VariableAssignment.hpp10
2 files changed, 8 insertions, 29 deletions
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<Domain> {
return _values[e];
}
- void invalidate(const Variable<Domain>& v) {
- log::strategy << indent() << "Invalidating " << v << " - " << *_system[v] << std::endl;
-
- IdSet<MaxExpression<Domain> > infl = _influence[*_system[v]];
- for (typename IdSet<MaxExpression<Domain> >::iterator
- it = infl.begin(),
- end = infl.end();
- it != end;
- ++it) {
- invalidate(_system.maxExpression(*it));
- }
- }
-
void invalidate(const MaxExpression<Domain>& v) {
if (_stable.contains(v)) {
log::strategy << indent() << "Invalidating " << v << std::endl;
@@ -90,7 +77,6 @@ struct DynamicMaxStrategy : public MaxStrategy<Domain> {
private:
void solve(const MaxExpression<Domain>& 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<Domain>& 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<Variable<Domain> > changed = _rho.get_changed();
for (typename IdSet<Variable<Domain> >::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<Domain> {
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<Domain>();
IdSet<Variable<Domain> > infl = _influence[x];
@@ -66,19 +66,15 @@ struct DynamicVariableAssignment : public VariableAssignment<Domain> {
it != ei;
++it) {
Variable<Domain>& 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<Variable<Domain>, Domain> get_old_values() const {
- return _old_values;
- }
-
private:
void solve(const Variable<Domain>& x) {