Fix result file
[satune.git] / src / Tuner / multituner.cc
index fbf66c7..1cdeee2 100644 (file)
@@ -59,21 +59,22 @@ 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), "./run.sh 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%u > log%u", problem->getProblem(), timeout, execnum, 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);
+               snprintf(buffer, sizeof(buffer), "result%u", execnum);
 
                ifstream myfile;
                myfile.open (buffer, ios::in);
@@ -84,6 +85,9 @@ long long MultiTuner::evaluate(Problem *problem, SearchTuner *tuner) {
                        myfile >> sat;
                        myfile.close();
                }
+
+               snprintf(buffer, sizeof(buffer), "tuner%uused", execnum);
+               tuner->getTuner()->addUsed(buffer);
        }
        //Increment execution count
        execnum++;
@@ -113,7 +117,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);
                                }
@@ -173,7 +177,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 +231,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);
                }