Adding SMT Interpreters
[satune.git] / src / Test / runmultituner.cc
1 #include "csolver.h"
2 #include "searchtuner.h"
3 #include "kmeanstuner.h"
4 #include "satuner.h"
5 #include "comptuner.h"
6 #include "randomtuner.h"
7
8 void printKnownTunerTypes(){
9         printf("Known Tuner Types:\nRandom Tuner=1\nComp Tuner=2\nKmeans Tuner=3\nSimulated Annealing Tuner=4\n");
10 }
11
12 BasicTuner *createTuner(uint tunertype, uint budget, uint rounds, uint timeout){
13         switch(tunertype){
14                 case 1: return new RandomTuner(budget, timeout);
15                 case 2: return new CompTuner(budget, timeout);
16                 case 3: return new KMeansTuner(budget, rounds, timeout);
17                 case 4: return new SATuner(budget, timeout);
18                 default:
19                         printf("Tuner type %u is unknown\n", tunertype);
20                         printKnownTunerTypes();
21                         exit(-1);
22         }
23
24 }
25
26 int main(int argc, char **argv) {
27         if (argc < 8) {
28                 printf("You should specify: %s TunerType budget rounds timeout problemfilenames - tunerfilenames\n", argv[0]);
29                 printKnownTunerTypes();
30                 exit(-1);
31         }
32         uint tunertype;
33         uint budget;
34         uint rounds;
35         uint timeout;
36         sscanf(argv[1], "%u", &tunertype);
37         sscanf(argv[2], "%u", &budget);
38         sscanf(argv[3], "%u", &rounds);
39         sscanf(argv[4], "%u", &timeout);
40
41         BasicTuner *multituner = createTuner(tunertype, budget, rounds, timeout);
42         bool tunerfiles = false;
43         for (int i = 5; i < argc; i++) {
44                 if (!tunerfiles) {
45                         if (argv[i][0] == '-' && argv[i][1] == 0)
46                                 tunerfiles = true;
47                         else
48                                 multituner->addProblem(argv[i]);
49                 } else
50                         multituner->addTuner(new SearchTuner(argv[i], true )); //add settings to usedsettigs
51         }
52
53         if (!tunerfiles) {
54                 printf("You should specify %s budget rounds timeout problemfilenames - tunerfilenames", argv[0]);
55                 exit(-1);
56         }
57
58         multituner->tune();
59         delete multituner;
60         return 0;
61 }