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 bdfeb61..4a35fcd 100644 (file)
@@ -5,8 +5,10 @@
 #include <stdlib.h>
 #include <float.h>
 
+#define UNSETVALUE -1
+
 AutoTuner::AutoTuner(uint _budget) :
-       budget(_budget) {
+       budget(_budget), result(UNSETVALUE) {
 }
 
 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");
-       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();
index d9fb430..0346e42 100644 (file)
@@ -16,5 +16,6 @@ private:
 
        Vector<CSolver *> solvers;
        uint budget;
+        int result;
 };
 #endif
index c119597..a0fc1bc 100644 (file)
@@ -42,10 +42,10 @@ void TunableSetting::setDecision(int _low, int _high, int _default, int _selecti
 
 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) {
index eeba3a2..a57a601 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;
 }
+
+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 9edcd3c..fcc97be 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;
+
+const char* tunableParameterToString(Tunables tunable);
 #endif