if (This->type != ELEMCONST) {
model_print("INFO: naive encoder is making the decision about element %p....\n", This);
}
- encoding->setElementEncodingType((ElementEncodingType)csolver->getTuner()->getVarTunable(This->getRange()->getType(), NAIVEENCODER, &NaiveEncodingDesc));
+ uint enc = csolver->getTuner()->getVarTunable(This->getRange()->getType(), NODEENCODING, &NodeEncodingDesc);
+ if (enc == ELEM_UNASSIGNED)
+ enc = csolver->getTuner()->getTunable(NAIVEENCODER, &NaiveEncodingDesc);
+ encoding->setElementEncodingType((ElementEncodingType)enc);
encoding->encodingArrayInitialization();
}
--- /dev/null
+#include "csolver.h"
+#include "multituner.h"
+#include "searchtuner.h"
+
+int main(int argc, char **argv) {
+ if (argc < 7) {
+ printf("You should specify %s budget rounds timeout problemfilenames - tunerfilenames", argv[0]);
+ exit(-1);
+ }
+ uint budget;
+ uint rounds;
+ uint timeout;
+ sscanf(argv[1], "%u", &budget);
+ sscanf(argv[2], "%u", &rounds);
+ sscanf(argv[3], "%u", &timeout);
+
+ MultiTuner *multituner = new MultiTuner(budget, rounds, timeout);
+ bool tunerfiles = false;
+ for (int i = 4; i < argc; i++) {
+ if (!tunerfiles) {
+ if (argv[i][0] == '-' && argv[i][1] == 0)
+ tunerfiles = true;
+ else
+ multituner->addProblem(argv[i]);
+ } else
+ multituner->addTuner(new SearchTuner(argv[i]));
+ }
+
+ if (!tunerfiles) {
+ printf("You should specify %s budget rounds timeout problemfilenames - tunerfilenames", argv[0]);
+ exit(-1);
+ }
+
+ multituner->tuneK();
+ delete multituner;
+ return 0;
+}
--- /dev/null
+#include "csolver.h"
+#include "searchtuner.h"
+#include "tunable.h"
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+ SearchTuner *elem_bin = new SearchTuner();
+ SearchTuner *elem_onehot = new SearchTuner();
+ SearchTuner *elem_unary = new SearchTuner();
+ elem_bin->setTunable(NAIVEENCODER, &NaiveEncodingDesc, BINARYINDEX);
+ elem_onehot->setTunable(NAIVEENCODER, &NaiveEncodingDesc, ONEHOT);
+ elem_unary->setTunable(NAIVEENCODER, &NaiveEncodingDesc, UNARY);
+
+ elem_bin->serialize("binarytuner.conf");
+ elem_onehot->serialize("onehottuner.conf");
+ elem_unary->serialize("unarytuner.conf");
+ delete elem_bin;
+ delete elem_onehot;
+ delete elem_unary;
+}
ranking.insertAt(j, tuner);
}
for (uint i = tuners.getSize(); i < ranking.getSize(); i++) {
- TunerRecord * tuner = ranking.get(i);
- for(uint j = 0; j < tunerV->getSize(); j++) {
- if (tunerV->get(j) == tuner)
- tunerV->removeAt(j);
- }
+ TunerRecord *tuner = ranking.get(i);
+ for (uint j = 0; j < tunerV->getSize(); j++) {
+ if (tunerV->get(j) == tuner)
+ tunerV->removeAt(j);
+ }
}
}
}
delete iterator;
}
+void SearchTuner::setTunable(TunableParam param, TunableDesc *descriptor, uint value) {
+ TunableSetting *result = new TunableSetting(param);
+ result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, value);
+ settings.add(result);
+ usedSettings.add(result);
+}
+
+void SearchTuner::setVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor, uint value) {
+ setVarTunable(vartype, 0, param, descriptor, value);
+}
+
+void SearchTuner::setVarTunable(VarType vartype1, VarType vartype2, TunableParam param, TunableDesc *descriptor, uint value) {
+ TunableSetting *result = new TunableSetting(vartype1, vartype2, param);
+ result->setDecision(descriptor->lowValue, descriptor->highValue, descriptor->defaultValue, value);
+ settings.add(result);
+ usedSettings.add(result);
+}
+
int SearchTuner::getTunable(TunableParam param, TunableDesc *descriptor) {
TunableSetting setting(param);
TunableSetting *result = usedSettings.get(&setting);
int getTunable(TunableParam param, TunableDesc *descriptor);
int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
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();}