fix up serialization a bit more
[satune.git] / src / Tuner / searchtuner.h
index bf96b299529c40c58a8527313e5980b4d9511275..2cd3118bda41514bf9939d94a86fbd85f8175c38 100644 (file)
@@ -3,17 +3,23 @@
 #include "classlist.h"
 #include "tunable.h"
 #include "structs.h"
+#include <ostream>
+using namespace std;
 
 class TunableSetting {
- public:
-       TunableSetting(VarType type, TunableParam param);       
+public:
+       TunableSetting(VarType type, TunableParam param);
+       TunableSetting(VarType type1, VarType type2, TunableParam param);
        TunableSetting(TunableParam param);
-       TunableSetting(TunableSetting * ts);
+       TunableSetting(TunableSetting *ts);
        void setDecision(int _low, int _high, int _default, int _selection);
-       MEMALLOC;
- private:
+       void print();
+       friend std ::ostream &operator<< (std::ostream &stream, const TunableSetting &matrix);
+       CMEMALLOC;
+private:
        bool hasVar;
-       VarType type;
+       VarType type1;
+       VarType type2;
        TunableParam param;
        int lowValue;
        int highValue;
@@ -22,31 +28,43 @@ class TunableSetting {
        friend unsigned int tunableSettingHash(TunableSetting *setting);
        friend bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
        friend class SearchTuner;
+       friend class StaticSearchTuner;
 };
 
 unsigned int tunableSettingHash(TunableSetting *setting);
 bool tunableSettingEquals(TunableSetting *setting1, TunableSetting *setting2);
 
-typedef HashSet<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HashSetTunableSetting;
-typedef HSIterator<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HSIteratorTunableSetting;
+typedef Hashset<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> HashsetTunableSetting;
+typedef SetIterator<TunableSetting *, uintptr_t, 4, tunableSettingHash, tunableSettingEquals> SetIteratorTunableSetting;
 
 class SearchTuner : public Tuner {
- public:
+public:
        SearchTuner();
+       SearchTuner(const char *filename);
        ~SearchTuner();
        int getTunable(TunableParam param, TunableDesc *descriptor);
        int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
-       SearchTuner * copyUsed();
+       int getVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor);
+       void setTunable(TunableParam param, TunableDesc *descriptor, uint value);
+       void setVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor, uint value);
+       void setVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor, uint value);
+       SearchTuner *copyUsed();
        void randomMutate();
        uint getSize() { return usedSettings.getSize();}
-       
-       MEMALLOC;
- private:
+       void print();
+       void printUsed();
+       void serialize(const char *file);
+       void serializeUsed(const char *file);
+       void addUsed(const char *file);
+
+       CMEMALLOC;
+protected:
        /** 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;
+          the example. Mutating settings may cause the Constraint Compiler
+          not to query other settings.*/
+       HashsetTunableSetting usedSettings;
        /** Settings contains all settings. */
-       HashSetTunableSetting settings;
+       HashsetTunableSetting settings;
 };
+
 #endif