Tuner shouldn't try to find really bad implementations
[satune.git] / src / Tuner / multituner.cc
index 09e44914d4cfa2df7a7ee08bd8b0a1b19f98f6a4..e0fee46074f5656e7df7fd9bba9cd4a7ba5e18a1 100644 (file)
@@ -114,7 +114,7 @@ void MultiTuner::readData(uint numRuns) {
                long long metric = -1;
                int sat = IS_INDETER;
                //Read data in from results file
-               snprintf(buffer, sizeof(buffer), "result%u", execnum);
+               snprintf(buffer, sizeof(buffer), "result%u", i);
 
                myfile.open (buffer, ios::in);
 
@@ -130,9 +130,11 @@ void MultiTuner::readData(uint numRuns) {
                        model_print("******** Result has changed ********\n");
                }
 
-               if (metric != -1)
+               if (metric != -1) {
+                       if (tuner->getTime(problem) == -1)
+                               tuner->problems.push(problem);
                        tuner->setTime(problem, metric);
-
+               }
 
        }
 
@@ -215,6 +217,7 @@ void MultiTuner::tuneComp() {
                        SearchTuner *tmpTuner = mutateTuner(tunerV->get(i)->getTuner(), b);
                        TunerRecord *tmp = new TunerRecord(tmpTuner);
                        tmp->tunernumber = allTuners.getSize();
+                       model_print("Mutated tuner %u to generate tuner %u\n", tunerV->get(i)->tunernumber, tmp->tunernumber);
                        allTuners.push(tmp);
                        tunerV->push(tmp);
                }
@@ -228,6 +231,11 @@ void MultiTuner::tuneComp() {
                                long long metric = tuner->getTime(problem);
                                if (metric == -1) {
                                        metric = evaluate(problem, tuner);
+                                       if (tuner->getTime(problem) == -1) {
+                                               tuner->problems.push(problem);
+                                       }
+                                       DEBUG("%u.Problem<%s>\tTuner<%p>\tMetric<%lld>\n", i, problem->problem,tuner, metric);
+                                       DEBUG("*****************************\n");
                                        if (metric != -1)
                                                tuner->setTime(problem, metric);
                                }
@@ -237,18 +245,21 @@ void MultiTuner::tuneComp() {
                                                if (metric < places.get(k)->getTime(problem))
                                                        break;
                                        }
+                                       DEBUG("place[%u]=Tuner<%p>\n", k, tuner);
                                        places.insertAt(k, tuner);
                                }
                        }
                        int points = 9;
                        for (uint k = 0; k < places.getSize() && points; k++) {
                                TunerRecord *tuner = places.get(k);
-                               points = points / 3;
                                int currScore = 0;
                                if (scores.contains(tuner))
                                        currScore = scores.get(tuner);
                                currScore += points;
+                               DEBUG("Problem<%s>\tTuner<%p>\tmetric<%d>\n", problem->problem, tuner, currScore);
+                               DEBUG("**************************\n");
                                scores.put(tuner, currScore);
+                               points = points / 3;
                        }
                }
                Vector<TunerRecord *> ranking;
@@ -263,13 +274,17 @@ void MultiTuner::tuneComp() {
                                int tscore = 0;
                                if (scores.contains(t))
                                        tscore = scores.get(t);
-                               if (score < tscore)
+                               if (score > tscore)
                                        break;
                        }
+                       DEBUG("ranking[%u]=tuner<%p>(Score=%d)\n", j, tuner, score);
+                       DEBUG("************************\n");
                        ranking.insertAt(j, tuner);
                }
+               DEBUG("tunerSize=%u\trankingSize=%u\ttunerVSize=%u\n", tuners.getSize(), ranking.getSize(), tunerV->getSize());
                for (uint i = tuners.getSize(); i < ranking.getSize(); i++) {
                        TunerRecord *tuner = ranking.get(i);
+                       model_print("Removing tuner %u\n", tuner->tunernumber);
                        for (uint j = 0; j < tunerV->getSize(); j++) {
                                if (tunerV->get(j) == tuner)
                                        tunerV->removeAt(j);