Now the Tuner decides about creating proxy variables
[satune.git] / src / Tuner / searchtuner.h
index 2d0facd7b10177a6e67a8ce596d2ae601de4af02..1464849e520f2b905a1627071af6760f3f7ea23c 100644 (file)
@@ -2,36 +2,57 @@
 #define SEARCHTUNER_H
 #include "classlist.h"
 #include "tunable.h"
+#include "structs.h"
 
-class SearchTuner : public Tuner {
- public:
-       SearchTuner();
-       int getTunable(TunableParam param, TunableDesc *descriptor);
-       int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
-       MEMALLOC;
- private:
-};
-
-class TunableParameter {
- public:
-       TunableParameter(VarType type, TunableParam param);     
-       TunableParameter(TunableParam param);
-       MEMALLOC;
- private:
+class TunableSetting {
+public:
+       TunableSetting(VarType type, TunableParam param);
+       TunableSetting(VarType type1, VarType type2, TunableParam param);
+       TunableSetting(TunableParam param);
+       TunableSetting(TunableSetting *ts);
+       void setDecision(int _low, int _high, int _default, int _selection);
+       void print();
+       CMEMALLOC;
+private:
        bool hasVar;
-       VarType type;
+       VarType type1;
+       VarType type2;
        TunableParam param;
-};
-
-class TunableDecision {
- public:
-       TunableDecision(int _low, int _high, int _default, int _selection);
-       MEMALLOC;
- private:
        int lowValue;
        int highValue;
        int defaultValue;
        int selectedValue;
+       friend unsigned int tunableSettingHash(TunableSetting *setting);
+       friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
+       friend class SearchTuner;
 };
 
+unsigned int tunableSettingHash(TunableSetting *setting);
+bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
+
+typedef Hashset<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HashsetTunableSetting;
+typedef SetIterator<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> SetIteratorTunableSetting;
+
+class SearchTuner : public Tuner {
+public:
+       SearchTuner();
+       ~SearchTuner();
+       int getTunable(TunableParam param, TunableDesc *descriptor);
+       int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
+       int getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor);
+       SearchTuner *copyUsed();
+       void randomMutate();
+       uint getSize() { return usedSettings.getSize();}
+       void print();
+       void printUsed();
+
+       CMEMALLOC;
+private:
+       /** Used Settings keeps track of settings that were actually used by
+          the example. Mutating settings may cause the Constraint Compiler
+          not to query other settings.*/
+       HashsetTunableSetting usedSettings;
+       /** Settings contains all settings. */
+       HashsetTunableSetting settings;
+};
 #endif