From: Hamed Gorjiara Date: Sat, 20 Oct 2018 23:21:38 +0000 (-0700) Subject: Finding the 3 best tuners after the learning process X-Git-Url: http://plrg.eecs.uci.edu/git/?p=satune.git;a=commitdiff_plain;h=b94774b8783de1b4eabc3ca4b0ef6aeee7a89538;hp=97c421c75f29cf910384af857d7db90f83676b82 Finding the 3 best tuners after the learning process --- diff --git a/src/Test/analyzemultituner.cc b/src/Test/analyzemultituner.cc index c0149f5..fab9082 100644 --- a/src/Test/analyzemultituner.cc +++ b/src/Test/analyzemultituner.cc @@ -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; } diff --git a/src/Tuner/multituner.cc b/src/Tuner/multituner.cc index 9d8e121..0850f66 100644 --- a/src/Tuner/multituner.cc +++ b/src/Tuner/multituner.cc @@ -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; kgetTime(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); diff --git a/src/Tuner/multituner.h b/src/Tuner/multituner.h index 1e878ee..398eb84 100644 --- a/src/Tuner/multituner.h +++ b/src/Tuner/multituner.h @@ -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 *tunerV); void improveTuners(Vector *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 allTuners; Vector problems; Vector tuners; diff --git a/src/common.h b/src/common.h index 879c1f2..b3ddb77 100644 --- a/src/common.h +++ b/src/common.h @@ -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 diff --git a/src/config.h b/src/config.h index 4d56dfb..ce13d3c 100644 --- a/src/config.h +++ b/src/config.h @@ -16,7 +16,7 @@ /** Turn on debugging. */ #ifndef CONFIG_DEBUG -#define CONFIG_DEBUG +//#define CONFIG_DEBUG #endif #ifndef CONFIG_ASSERT