X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=src%2FTuner%2Fbasictuner.cc;h=f3a00ea460aa1d78dd627805782993b73aa9bffd;hb=cb7331d3834636ca4af0357d272d082c047ec940;hp=889b543f07bab6299042f09874903e842a3d9ba9;hpb=e9ca288c7f0cf0f3bb9508c3cc9b212f557bcc40;p=satune.git diff --git a/src/Tuner/basictuner.cc b/src/Tuner/basictuner.cc index 889b543..f3a00ea 100644 --- a/src/Tuner/basictuner.cc +++ b/src/Tuner/basictuner.cc @@ -4,10 +4,10 @@ * and open the template in the editor. */ -/* +/* * File: basictuner.cc * Author: hamed - * + * * Created on December 17, 2018, 2:02 PM */ @@ -38,7 +38,7 @@ void TunerRecord::setTime(Problem *problem, long long time) { timetaken.put(problem, time); } -void TunerRecord::print(){ +void TunerRecord::print() { model_print("*************TUNER NUMBER=%d***********\n", tunernumber); tuner->print(); model_print("&&&&&&&&&&&&&USED SETTINGS &&&&&&&&&&&&\n"); @@ -46,7 +46,7 @@ void TunerRecord::print(){ model_print("\n"); } -void TunerRecord::printProblemsInfo(){ +void TunerRecord::printProblemsInfo() { for (uint j = 0; j < problems.getSize(); j++) { Problem *problem = problems.get(j); model_print("Problem %s\n", problem->getProblem()); @@ -70,7 +70,7 @@ TunerRecord *TunerRecord::changeTuner(SearchTuner *_newtuner) { BasicTuner::BasicTuner(uint _budget, uint _timeout) : - budget(_budget), timeout(_timeout), execnum(0){ + budget(_budget), timeout(_timeout), execnum(0) { } BasicTuner::~BasicTuner() { @@ -102,10 +102,10 @@ void BasicTuner::printData() { } } -bool BasicTuner::tunerExists(TunerRecord *tunerec){ +bool BasicTuner::tunerExists(TunerRecord *tunerec) { SearchTuner *tuner = tunerec->getTuner(); - for(uint i=0; i< explored.getSize(); i++){ - if(explored.get(i)->getTuner()->equalUsed(tuner)){ + for (uint i = 0; i < explored.getSize(); i++) { + if (explored.get(i)->getTuner()->equalUsed(tuner)) { model_print("************Tuner <%d> is replicate of Tuner <%d>\n", tunerec->getTunerNumber(), explored.get(i)->getTunerNumber()); return true; } @@ -157,9 +157,10 @@ long long BasicTuner::evaluate(Problem *problem, TunerRecord *tuner) { uint timeinsecs = problem->getBestTime() / NANOSEC; uint adaptive = (timeinsecs > 30) ? timeinsecs * 5 : 150; uint maxtime = (adaptive < timeout) ? adaptive : timeout; - + uint satuneTimeout = (2*maxtime < maxtime + 600)?2*maxtime: maxtime + 600; //Do run - snprintf(buffer, sizeof(buffer), "./run.sh deserializerun %s %u tuner%u result%u > log%u", problem->getProblem(), maxtime, execnum, execnum, execnum); + snprintf(buffer, sizeof(buffer), "timeout %u ./run.sh deserializerun %s %u tuner%u result%u > log%u", satuneTimeout, problem->getProblem(), maxtime, execnum, execnum, execnum); + model_print("Running: %s\n", buffer); int status = system(buffer); long long metric = -1; @@ -178,17 +179,23 @@ long long BasicTuner::evaluate(Problem *problem, TunerRecord *tuner) { myfile >> sat; myfile.close(); } - updateTimeout(problem, metric); + if(sat != IS_INDETER){ + updateTimeout(problem, metric); + } snprintf(buffer, sizeof(buffer), "tuner%uused", execnum); tuner->getTuner()->addUsed(buffer); + } else if (status == 124 << 8) {// timeout happens ... + tuner->getTuner()->copySettingstoUsedSettings(); } + //Increment execution count execnum++; if (problem->getResult() == TUNERUNSETVALUE && sat != IS_INDETER) { problem->setResult( sat ); } else if (problem->getResult() != sat && sat != IS_INDETER) { - model_print("******** Result has changed ********\n"); + model_print("******** Result has changed ******** Found a bug!!\n"); + ASSERT(0) } if (sat == IS_INDETER && metric != -1) {//The case when we have a timeout metric = -1; @@ -209,10 +216,10 @@ SearchTuner *BasicTuner::mutateTuner(SearchTuner *oldTuner, uint k) { return newTuner; } -int BasicTuner::subTunerIndex(SearchTuner *newTuner){ - for (uint i=0; i< explored.getSize(); i++){ +int BasicTuner::subTunerIndex(SearchTuner *newTuner) { + for (uint i = 0; i < explored.getSize(); i++) { SearchTuner *tuner = explored.get(i)->getTuner(); - if(tuner->isSubTunerof(newTuner)){ + if (tuner->isSubTunerof(newTuner)) { return i; } }