Fix tuner issues
[satune.git] / src / Tuner / multituner.cc
index 2504110..03bfeec 100644 (file)
@@ -59,18 +59,19 @@ void MultiTuner::addTuner(SearchTuner *tuner) {
        allTuners.push(t);
 }
 
-long long MultiTuner::evaluate(Problem *problem, SearchTuner *tuner) {
+long long MultiTuner::evaluate(Problem *problem, TunerRecord *tuner) {
        char buffer[512];
        //Write out the tuner
        snprintf(buffer, sizeof(buffer), "tuner%u", execnum);
-       tuner->serialize(buffer);
+       tuner->getTuner()->serialize(buffer);
 
        //Do run
-       snprintf(buffer, sizeof(buffer), "deserializerun %s %u tuner%u result%s%u > log%u", problem->getProblem(), timeout, execnum, problem->getProblem(), execnum, execnum);
+       snprintf(buffer, sizeof(buffer), "./run.sh deserializerun %s %u tuner%u result%s%u > log%u", problem->getProblem(), timeout, execnum, problem->getProblem(), execnum, execnum);
        int status = system(buffer);
 
        long long metric = -1;
        int sat = IS_INDETER;
+
        if (status == 0) {
                //Read data in from results file
                snprintf(buffer, sizeof(buffer), "result%s%u", problem->getProblem(), execnum);
@@ -84,6 +85,12 @@ long long MultiTuner::evaluate(Problem *problem, SearchTuner *tuner) {
                        myfile >> sat;
                        myfile.close();
                }
+
+               snprintf(buffer, sizeof(buffer), "tuner%uused", execnum);
+               SearchTuner *usedtuner = new SearchTuner(buffer);
+               delete tuner->getTuner();
+               tuner->updateTuner(usedtuner);
+
        }
        //Increment execution count
        execnum++;
@@ -113,7 +120,7 @@ void MultiTuner::tuneComp() {
                                TunerRecord *tuner = tunerV->get(j);
                                long long metric = tuner->getTime(problem);
                                if (metric == -1) {
-                                       metric = evaluate(problem, tuner->getTuner());
+                                       metric = evaluate(problem, tuner);
                                        if (metric != -1)
                                                tuner->setTime(problem, metric);
                                }
@@ -155,11 +162,11 @@ void MultiTuner::tuneComp() {
                        ranking.insertAt(j, tuner);
                }
                for (uint i = tuners.getSize(); i < ranking.getSize(); i++) {
-                 TunerRecord * tuner = ranking.get(i);
-                 for(uint j = 0; j < tunerV->getSize(); j++) {
-                   if (tunerV->get(j) == tuner)
-                     tunerV->removeAt(j);
-                 }
+                       TunerRecord *tuner = ranking.get(i);
+                       for (uint j = 0; j < tunerV->getSize(); j++) {
+                               if (tunerV->get(j) == tuner)
+                                       tunerV->removeAt(j);
+                       }
                }
        }
 }
@@ -173,7 +180,7 @@ void MultiTuner::mapProblemsToTuners(Vector<TunerRecord *> *tunerV) {
                        TunerRecord *tuner = tunerV->get(j);
                        long long metric = tuner->getTime(problem);
                        if (metric == -1) {
-                               metric = evaluate(problem, tuner->getTuner());
+                               metric = evaluate(problem, tuner);
                                if (metric != -1)
                                        tuner->setTime(problem, metric);
                        }
@@ -227,7 +234,7 @@ double MultiTuner::evaluateAll(TunerRecord *tuner) {
                Problem *problem = tuner->problems.get(i);
                long long metric = tuner->getTime(problem);
                if (metric == -1) {
-                       metric = evaluate(problem, tuner->getTuner());
+                       metric = evaluate(problem, tuner);
                        if (metric != -1)
                                tuner->setTime(problem, metric);
                }