two best tuner instead of three
authorHamed Gorjiara <hgorjiar@uci.edu>
Fri, 18 Oct 2019 04:24:41 +0000 (21:24 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Fri, 18 Oct 2019 04:24:41 +0000 (21:24 -0700)
src/Test/analyzemultituner.cc
src/Tuner/comptuner.cc
src/Tuner/comptuner.h

index f132e74..93487f0 100644 (file)
@@ -27,7 +27,7 @@ int main(int argc, char **argv) {
        printf("Number of Runs: %u\n", numruns);
        CompTuner *multituner = new CompTuner(0, 0);
        multituner->readData(numruns);
-       multituner->findBestThreeTuners();
+       multituner->findBestTwoTuners();
        delete multituner;
        return 0;
 }
index 8069915..92a8985 100644 (file)
@@ -15,39 +15,35 @@ CompTuner::~CompTuner() {
 
 }
 
-void CompTuner::findBestThreeTuners() {
-       if (allTuners.getSize() < 3) {
+void CompTuner::findBestTwoTuners() {
+       if (allTuners.getSize() < 2) {
                printData();
                return;
        }
-       TunerRecord *bestTuners[3];
+       TunerRecord *bestTuners[2];
        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;
-                               }
+       for (uint j = 0; j < allTuners.getSize() - 1; j++) {
+               for (uint k = j + 1; k < allTuners.getSize(); k++) {
+                       TunerRecord *tuner1 = allTuners.get(j);
+                       TunerRecord *tuner2 = 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)), (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;
                        }
                }
        }
-       model_print("Best 3 tuners:\n");
-       for (uint i = 0; i < 3; i++) {
+       model_print("Best 2 tuners:\n");
+       for (uint i = 0; i < 2; i++) {
                TunerRecord *tuner = bestTuners[i];
                SearchTuner *stun = tuner->getTuner();
                char buffer[512];
@@ -60,6 +56,7 @@ void CompTuner::findBestThreeTuners() {
        }
 }
 
+
 void CompTuner::readData(uint numRuns) {
        for (uint i = 0; i < numRuns; i++) {
                ifstream myfile;
index 39e7946..74183bc 100644 (file)
@@ -11,7 +11,7 @@ public:
        virtual ~CompTuner();
        void readData(uint numRuns);
        void tune();
-       void findBestThreeTuners();
+       void findBestTwoTuners();
 protected:
 
 };