Fixing autoTuner's bug + making logs more legible
authorHamed Gorjiara <hgorjiar@uci.edu>
Sat, 28 Apr 2018 19:48:03 +0000 (12:48 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Sat, 28 Apr 2018 19:48:03 +0000 (12:48 -0700)
src/Tuner/autotuner.cc
src/Tuner/autotuner.h
src/Tuner/searchtuner.cc
src/Tuner/tunable.cc
src/Tuner/tunable.h

index bdfeb614b0386fff6bef467d857f19670004b41b..4a35fcd9650298c427e512a26bb47e6a26f2d605 100644 (file)
@@ -5,8 +5,10 @@
 #include <stdlib.h>
 #include <float.h>
 
 #include <stdlib.h>
 #include <float.h>
 
+#define UNSETVALUE -1
+
 AutoTuner::AutoTuner(uint _budget) :
 AutoTuner::AutoTuner(uint _budget) :
-       budget(_budget) {
+       budget(_budget), result(UNSETVALUE) {
 }
 
 void AutoTuner::addProblem(CSolver *solver) {
 }
 
 void AutoTuner::addProblem(CSolver *solver) {
@@ -17,7 +19,13 @@ long long AutoTuner::evaluate(CSolver *problem, SearchTuner *tuner) {
        CSolver *copy = problem->clone();
        copy->setTuner(tuner);
         model_print("**********************\n");
        CSolver *copy = problem->clone();
        copy->setTuner(tuner);
         model_print("**********************\n");
-       int result = copy->solve();
+       int sat = copy->solve();
+        if(result == UNSETVALUE)
+                result = sat;
+        else if(result != sat){
+                model_print("&&&&&&&&&&&&&&&&&& Result has changed &&&&&&&&&&&&&\n");
+                copy->printConstraints();
+        }
        //model_print("SAT %d\n", result);
        long long elapsedTime = copy->getElapsedTime();
 //     long long encodeTime = copy->getEncodeTime();
        //model_print("SAT %d\n", result);
        long long elapsedTime = copy->getElapsedTime();
 //     long long encodeTime = copy->getEncodeTime();
index d9fb430388a377a470dda9fe187790572b3996f1..0346e42f57fe76e99b9dd2e741f65c595956bc6a 100644 (file)
@@ -16,5 +16,6 @@ private:
 
        Vector<CSolver *> solvers;
        uint budget;
 
        Vector<CSolver *> solvers;
        uint budget;
+        int result;
 };
 #endif
 };
 #endif
index c1195977f2ab618fea8e6d0b7267468f38d82079..a0fc1bca4a90d5b0d03bff4e541910b767b0d517 100644 (file)
@@ -42,10 +42,10 @@ void TunableSetting::setDecision(int _low, int _high, int _default, int _selecti
 
 void TunableSetting::print() {
        if (hasVar) {
 
 void TunableSetting::print() {
        if (hasVar) {
-               model_print("Type1 %" PRIu64 ", ", type1);
-               model_print("Type2 %" PRIu64 ", ", type2);
+               model_print("VarType1 %" PRIu64 ", ", type1);
+               model_print("VarType2 %" PRIu64 ", ", type2);
        }
        }
-       model_print("Param %u = %u\n", param, selectedValue);
+       model_print("Param %s = %u \t range=[%u,%u]\n", tunableParameterToString( (Tunables)param), selectedValue, lowValue, highValue);
 }
 
 unsigned int tunableSettingHash(TunableSetting *setting) {
 }
 
 unsigned int tunableSettingHash(TunableSetting *setting) {
index eeba3a29de8ef4b46e4071dd47ef5e0b20f64bd5..a57a601d9643e667fa4fc16c365ca75c3a76eaac 100644 (file)
@@ -14,3 +14,30 @@ int DefaultTuner::getVarTunable(VarType vartype, TunableParam param, TunableDesc
 int DefaultTuner::getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor) {
        return descriptor->defaultValue;
 }
 int DefaultTuner::getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor) {
        return descriptor->defaultValue;
 }
+
+const char* tunableParameterToString(Tunables tunable){
+        switch(tunable){
+                case DECOMPOSEORDER:
+                        return "DECOMPOSEORDER";
+                case MUSTREACHGLOBAL:
+                        return "MUSTREACHGLOBAL";
+                case MUSTREACHLOCAL:
+                        return "MUSTREACHLOCAL";
+                case MUSTREACHPRUNE:
+                        return "MUSTREACHPRUNE";
+                case OPTIMIZEORDERSTRUCTURE:
+                        return "OPTIMIZEORDERSTRUCTURE";
+                case ORDERINTEGERENCODING:
+                        return "ORDERINTEGERENCODING";
+                case PREPROCESS:
+                        return "PREPROCESS";
+                case NODEENCODING:
+                        return "NODEENCODING";
+                case EDGEENCODING:
+                        return "EDGEENCODING";
+                case MUSTEDGEPRUNE:
+                        return "MUSTEDGEPRUNE";
+                default:
+                        ASSERT(0);
+        }
+}
\ No newline at end of file
index 9edcd3c828a53cacf54deeea49bbea0e4ceae10d..fcc97be9e8295b63401073138c5dcd993e7afb26 100644 (file)
@@ -41,4 +41,6 @@ static TunableDesc offon(0, 1, 0);
 
 enum Tunables {DECOMPOSEORDER, MUSTREACHGLOBAL, MUSTREACHLOCAL, MUSTREACHPRUNE, OPTIMIZEORDERSTRUCTURE, ORDERINTEGERENCODING, PREPROCESS, NODEENCODING, EDGEENCODING, MUSTEDGEPRUNE};
 typedef enum Tunables Tunables;
 
 enum Tunables {DECOMPOSEORDER, MUSTREACHGLOBAL, MUSTREACHLOCAL, MUSTREACHPRUNE, OPTIMIZEORDERSTRUCTURE, ORDERINTEGERENCODING, PREPROCESS, NODEENCODING, EDGEENCODING, MUSTEDGEPRUNE};
 typedef enum Tunables Tunables;
+
+const char* tunableParameterToString(Tunables tunable);
 #endif
 #endif