From 0cca9a599a66758cbb5a958b619de3315f26b528 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Thu, 5 Jul 2012 16:39:32 +1000 Subject: Intermediate (broken) commit - smarter strategy --- impl/main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'impl/main.cpp') diff --git a/impl/main.cpp b/impl/main.cpp index b761587..26aedbe 100644 --- a/impl/main.cpp +++ b/impl/main.cpp @@ -6,6 +6,7 @@ #include "Operator.hpp" #include "EquationSystem.hpp" #include "MaxStrategy.hpp" +#include "ImprovementOperator.hpp" #include "FixpointAlgorithm.hpp" extern "C" { @@ -126,14 +127,17 @@ int main (int argc, char* argv[]) { } // PARSE ARGUMENTS - strat improvement - MaxStrategy::ImprovementOperator* naiveImprovement = new MaxStrategy::NaiveImprovementOperator(); - MaxStrategy::ImprovementOperator* improvement = NULL; + ImprovementOperator* naiveImprovement = new NaiveImprovementOperator(); + ImprovementOperator* improvement = NULL; if (!strcmp(argv[3], "repeat")) { - improvement = new MaxStrategy::RepeatedImprovementOperator(*naiveImprovement); + improvement = new RepeatedImprovementOperator(*naiveImprovement); cout << "Repeated strategy improvement" << endl; } else if (!strcmp(argv[3], "naive")) { improvement = naiveImprovement; cout << "Naive strategy improvement" << endl; + } else if (!strcmp(argv[3], "smart")) { + improvement = new SmartImprovementOperator(system); + cout << "Smart strategy improvement" << endl; } else { cout << "Unknown strategy improvement algorithm." << endl; } @@ -143,7 +147,7 @@ int main (int argc, char* argv[]) { cout << system << endl; StableVariableAssignment result(system.variableCount(), infinity()); - MaxStrategy strategy(system); + ConcreteMaxStrategy strategy(system); IdSet > s1(system.variableCount()); IdSet > s2(system.variableCount()); bool changed = false; @@ -159,7 +163,9 @@ int main (int argc, char* argv[]) { cout << endl; exit(0);*/ - changed = strategy.improve(*improvement, result, s1, s2); + s2.clear(); + changed = improvement->improve(strategy, result, s1, s2); + std::cout << (changed ? "true" : "false") << std::endl; } while(changed); cout << endl; -- cgit v1.2.3