Finding the 3 best tuners after the learning process
authorHamed Gorjiara <hgorjiar@uci.edu>
Sat, 20 Oct 2018 23:21:38 +0000 (16:21 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Sat, 20 Oct 2018 23:21:38 +0000 (16:21 -0700)
src/Test/analyzemultituner.cc
src/Tuner/multituner.cc
src/Tuner/multituner.h
src/common.h
src/config.h

index c0149f5..fab9082 100644 (file)
@@ -12,7 +12,7 @@ int main(int argc, char **argv) {
 
        MultiTuner *multituner = new MultiTuner(0, 0, 0);
        multituner->readData(numruns);
-       multituner->printData();
+       multituner->findBestThreeTuners();
        delete multituner;
        return 0;
 }
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);
index 1e878ee..398eb84 100644 (file)
@@ -47,6 +47,7 @@ public:
        void tuneK();
        void tuneComp();
        void printData();
+       void findBestThreeTuners();
        CMEMALLOC;
 protected:
        long long evaluate(Problem *problem, TunerRecord *tuner);
@@ -55,7 +56,11 @@ protected:
        void mapProblemsToTuners(Vector<TunerRecord *> *tunerV);
        void improveTuners(Vector<TunerRecord *> *tunerV);
        TunerRecord *tune(TunerRecord *tuner);
-
+        inline long long min(long long num1, long long num2, long long num3){
+                return num1 < num2 && num1 < num3? num1:
+                        num2 < num3? num2 : num3;
+        }
+        
        Vector<TunerRecord *> allTuners;
        Vector<Problem *> problems;
        Vector<TunerRecord *> tuners;
index 879c1f2..b3ddb77 100644 (file)
@@ -45,6 +45,7 @@ extern int switch_alloc;
 #define DBG_ENABLED() (1)
 #else
 #define DEBUG(fmt, ...)
+#define LOG(fmt, ...)
 #define DBG()
 #define DBG_ENABLED() (0)
 #endif
index 4d56dfb..ce13d3c 100644 (file)
@@ -16,7 +16,7 @@
 
 /** Turn on debugging. */
 #ifndef CONFIG_DEBUG
-#define CONFIG_DEBUG
+//#define CONFIG_DEBUG
 #endif
 
 #ifndef CONFIG_ASSERT