Serializing circuit encoding
[satune.git] / src / Tuner / staticautotuner.cc
1 #include "staticautotuner.h"
2 #include "csolver.h"
3 #include "staticsearchtuner.h"
4 #include <math.h>
5 #include <stdlib.h>
6 #include <float.h>
7
8 #define UNSETVALUE -1
9 #define TIMEOUTSEC 5000
10 StaticAutoTuner::StaticAutoTuner(uint _budget) : AutoTuner(_budget) {
11 }
12
13 StaticSearchTuner *StaticAutoTuner::mutateTuner(StaticSearchTuner *oldTuner) {
14         StaticSearchTuner *newTuner = oldTuner->copyUsed();
15         result = newTuner->nextStaticTuner();
16         if( result == EXIT_FAILURE) {
17                 return newTuner;
18         }else {
19                 delete newTuner;
20                 return NULL;
21         }
22 }
23
24 void StaticAutoTuner::tune() {
25         StaticSearchTuner *oldTuner = new StaticSearchTuner();
26         evaluateAll(oldTuner);
27         while (true) {
28                 StaticSearchTuner *newTuner = mutateTuner(oldTuner);
29                 if (newTuner == NULL){
30                         break;
31                 }
32                 double newScore = evaluateAll(newTuner);
33                 newTuner->printUsed();
34                 model_print("Received score %f\n", newScore);
35                 delete oldTuner;
36                 oldTuner = newTuner;
37         }
38         delete oldTuner;
39 }