Bug fix: besttime for each problem
authorHamed Gorjiara <hgorjiar@uci.edu>
Thu, 18 Oct 2018 04:38:55 +0000 (21:38 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Thu, 18 Oct 2018 04:38:55 +0000 (21:38 -0700)
src/Tuner/multituner.cc
src/Tuner/multituner.h

index 2d823fe397149b7c6e24ed65d471d47893a33c58..e872fac42f92f23dec32841ffa8c616395a00094 100644 (file)
@@ -7,10 +7,11 @@
 #include <string.h>
 #include <iostream>
 #include <fstream>
+#include <limits>
 
 #define UNSETVALUE -1
 
-Problem::Problem(const char *_problem) : problemnumber(-1), result(UNSETVALUE) {
+Problem::Problem(const char *_problem) : problemnumber(-1), result(UNSETVALUE) , besttime(std::numeric_limits<double>::infinity()){
        uint len = strlen(_problem);
        problem = (char *) ourmalloc(len + 1);
        memcpy(problem, _problem, len + 1);
@@ -39,7 +40,7 @@ TunerRecord *TunerRecord::changeTuner(SearchTuner *_newtuner) {
 }
 
 MultiTuner::MultiTuner(uint _budget, uint _rounds, uint _timeout) :
-       budget(_budget), rounds(_rounds), timeout(_timeout), besttime(_timeout), execnum(0) {
+       budget(_budget), rounds(_rounds), timeout(_timeout), execnum(0) {
 }
 
 MultiTuner::~MultiTuner() {
@@ -193,7 +194,7 @@ long long MultiTuner::evaluate(Problem *problem, TunerRecord *tuner) {
                        myfile >> sat;
                        myfile.close();
                }
-               updateTimeout(metric);
+               updateTimeout(problem, metric);
                snprintf(buffer, sizeof(buffer), "tuner%uused", execnum);
                tuner->getTuner()->addUsed(buffer);
        }
@@ -211,14 +212,14 @@ long long MultiTuner::evaluate(Problem *problem, TunerRecord *tuner) {
        return metric;
 }
 
-void MultiTuner::updateTimeout(long long metric){
+void MultiTuner::updateTimeout(Problem *problem, long long metric){
        double currentTime= metric / NANOSEC;
-       if(currentTime < besttime){
-               besttime = currentTime;
+       if(currentTime < problem->besttime){
+               problem->besttime = currentTime;
        }
        uint adoptive;
-       if(besttime > 30){
-               adoptive = besttime * 5;
+       if(problem->besttime > 30){
+               adoptive = problem->besttime * 5;
        }else {
                adoptive = 150;
        }
index f566828d86a72f5b282ab0b1ca07528df1e0b5c3..95354c8d73b0f10290df9b427a96ea78fecae055 100644 (file)
@@ -15,6 +15,7 @@ private:
        int problemnumber;
        int result;
        char *problem;
+        double besttime;
        friend class MultiTuner;
 };
 
@@ -42,7 +43,7 @@ public:
        void addProblem(const char *filename);
        void addTuner(SearchTuner *tuner);
        void readData(uint numRuns);
-        void updateTimeout(long long metric);
+        void updateTimeout(Problem *problem, long long metric);
        void tuneK();
        void tuneComp();
        void printData();
@@ -61,7 +62,6 @@ protected:
        uint budget;
        uint rounds;
        uint timeout;
-       double besttime;
        int execnum;
 };
 #endif