From 59fb7d23578c4da14f9c14cc413090b1af13328c Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 7 Aug 2012 17:56:43 +1000 Subject: Merge complete! Get onto the right branch. --- impl/ImprovementOperator.hpp | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) (limited to 'impl/ImprovementOperator.hpp') diff --git a/impl/ImprovementOperator.hpp b/impl/ImprovementOperator.hpp index a435b6e..8ebf2d1 100644 --- a/impl/ImprovementOperator.hpp +++ b/impl/ImprovementOperator.hpp @@ -39,7 +39,7 @@ struct NaiveImprovementOperator : public ImprovementOperator { strat.set(expr, index); } } - //log::strategy << strat << std::endl; + log::strategy << strat << std::endl; return changed; } }; @@ -68,4 +68,91 @@ struct RepeatedImprovementOperator : public ImprovementOperator { const ImprovementOperator& _subImprovement; }; +<<<<<<< HEAD + + +#include "VariableAssignment.hpp" + +template +struct DynamicMaxStrategy : public MaxStrategy { + DynamicMaxStrategy( + const EquationSystem& system + ) : _system(system), + _rho(NULL), + _values(system), + _stable(system.maxExpressionCount()), + _influence(system.maxExpressionCount(), + IdSet>(system.maxExpressionCount())), + _var_influence(system.variableCount(), + IdSet>(system.maxExpressionCount())) + {} + + void setRho(DynamicVariableAssignment& rho) { + _rho = ρ + } + + unsigned int get(const MaxExpression& e) const { + solve(e); + return _values.get(e); + } + + void invalidate(const Variable& v) const { + log::strategy << "invalidating " << v << " - " << *_system[v] << std::endl; + log::strategy << "\t" << _var_influence[v] << std::endl; + _stable.filter(_var_influence[v]); + + for (auto it = _var_influence[v].begin(); + it != _var_influence[v].end(); + ++it) { + solve(_system.maxExpression(*it)); + } + } + + struct DependencyAssignment : public VariableAssignment{ + DependencyAssignment(const DynamicMaxStrategy& strat, + VariableAssignment& rho, + const MaxExpression& expr) + : _strat(strat), + _rho(rho), + _expr(expr) { + } + const Domain& operator[](const Variable& var) const { + _strat._var_influence[var].insert(_expr); + return _rho[var]; + } + private: + const DynamicMaxStrategy& _strat; + VariableAssignment& _rho; + const MaxExpression& _expr; + }; + + struct DependencyStrategy : public MaxStrategy { + DependencyStrategy(const DynamicMaxStrategy& strat, const MaxExpression& expr) + : _strat(strat), + _expr(expr) { + } + unsigned int get(const MaxExpression& e) const { + _strat.solve(e); + if (&_expr != &e) { + _strat._influence[e].insert(_expr); + } + return _strat._values.get(e); + } + private: + const DynamicMaxStrategy& _strat; + const MaxExpression& _expr; + }; + +private: + const EquationSystem& _system; + mutable DynamicVariableAssignment* _rho; + mutable ConcreteMaxStrategy _values; + mutable IdSet> _stable; + mutable IdMap,IdSet>> _influence; + mutable IdMap,IdSet>> _var_influence; +}; + + +======= +>>>>>>> bitbucket/master #endif -- cgit v1.2.3