Bug fix: typos
[satune.git] / src / Tuner / searchtuner.h
1 #ifndef SEARCHTUNER_H
2 #define SEARCHTUNER_H
3 #include "classlist.h"
4 #include "tunable.h"
5 #include "structs.h"
6 #include <ostream>
7 using namespace std;
8
9 class TunableSetting {
10 public:
11         TunableSetting(VarType type, TunableParam param);
12         TunableSetting(VarType type1, VarType type2, TunableParam param);
13         TunableSetting(TunableParam param);
14         TunableSetting(TunableSetting *ts);
15         void setDecision(int _low, int _high, int _default, int _selection);
16         void print();
17         friend std ::ostream &operator<< (std::ostream &stream, const TunableSetting &matrix);
18         CMEMALLOC;
19 private:
20         bool hasVar;
21         VarType type1;
22         VarType type2;
23         TunableParam param;
24         int lowValue;
25         int highValue;
26         int defaultValue;
27         int selectedValue;
28         friend unsigned int tunableSettingHash(TunableSetting *setting);
29         friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
30         friend class SearchTuner;
31         friend class SerializeTuner;
32 };
33
34 class SearchTuner : public Tuner {
35 public:
36         SearchTuner();
37         SearchTuner(const char *filename, bool addused = false);
38         ~SearchTuner();
39         virtual int getTunable(TunableParam param, TunableDesc *descriptor);
40         int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
41         virtual int getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor);
42         void setTunable(TunableParam param, TunableDesc *descriptor, uint value);
43         void setVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor, uint value);
44         void setVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor, uint value);
45         SearchTuner *copyUsed();
46         void copySettingstoUsedSettings();
47         bool isSubTunerof(SearchTuner *newTuner);
48         void randomMutate();
49         uint getSize() { return usedSettings.getSize();}
50         void print();
51         void printUsed();
52         void serialize(const char *file);
53         void serializeUsed(const char *file);
54         void addUsed(const char *file);
55         bool equalUsed(SearchTuner *tuner);
56         CMEMALLOC;
57 protected:
58         /** Used Settings keeps track of settings that were actually used by
59            the example. Mutating settings may cause the Constraint Compiler
60            not to query other settings.*/
61         HashsetTunableSetting usedSettings;
62         /** Settings contains all settings. */
63         HashsetTunableSetting settings;
64 };
65
66 #endif