Finding the 3 best tuners after the learning process
[satune.git] / src / Tuner / multituner.cc
index 9d8e121..0850f66 100644 (file)
@@ -76,6 +76,52 @@ void MultiTuner::printData() {
        }
 }
 
+void MultiTuner::findBestThreeTuners() {
+       if(allTuners.getSize() < 3){
+               printData();
+               return;
+       }
+       TunerRecord * bestTuners[3];
+       double score = DBL_MAX;
+       for (uint i = 0; i < allTuners.getSize()-2; i++) {
+               for(uint j=i+1; j< allTuners.getSize()-1; j++){
+                       for(uint k=j+1; k<allTuners.getSize(); k++){
+                               TunerRecord *tuner1 = allTuners.get(i);
+                               TunerRecord *tuner2 = allTuners.get(j);
+                               TunerRecord *tuner3 = allTuners.get(k);
+                               double mintimes[problems.getSize()];
+                               for(uint l=0; l < problems.getSize(); l++){
+                                       Problem *problem = problems.get(l);
+                                       mintimes[l] = pow(min(tuner1->getTime(problem), tuner2->getTime(problem), tuner3->getTime(problem)), (double)1 / problems.getSize());
+                               }
+                               double result=1;
+                               for(uint l=0; l< problems.getSize(); l++){
+                                       result *= mintimes[l];
+                               }
+                               if(result < score){
+                                       score = result;
+                                       bestTuners[0] = tuner1;
+                                       bestTuners[1] = tuner2;
+                                       bestTuners[2] = tuner3;
+                               }
+                       }
+               }
+       }
+       model_print("Best 3 tuners:\n");
+       for(uint i=0; i<3; i++){
+               TunerRecord * tuner = bestTuners[i];
+               SearchTuner *stun = tuner->getTuner();
+               model_print("Tuner %u\n", tuner->tunernumber);
+               stun->print();
+               for (uint j = 0; j < tuner->problems.getSize(); j++) {
+                       Problem *problem = tuner->problems.get(j);
+                       model_print("Problem %s\n", problem->getProblem());
+                       model_print("Time = %lld\n", tuner->getTime(problem));
+               }
+               model_print("----------------------------------\n\n\n");
+       }
+}
+
 void MultiTuner::addTuner(SearchTuner *tuner) {
        TunerRecord *t = new TunerRecord(tuner);
        tuners.push(t);