* Result: O(5,1)=0 O(1,4)=0 O(5,4)=0 O(1,5)=1 O(1111,5)=2
*/
int main(int numargs, char **argv) {
- if (numargs < 4) {
- printf("Requires the following arguments: numpoints numclauses maxclausesize randomseed\n");
- return -1;
- }
- int numpoints = atoi(argv[1]);
- int numclauses = atoi(argv[2]);
- int maxclause = atoi(argv[3]);
- srandom(atoi(argv[4]));
-
- CSolver *solver = new CSolver();
- Set *s =solver->createRangeSet(0, 0, numpoints);
- Order *order = solver->createOrder(SATC_TOTAL, s);
- BooleanEdge be[maxclause];
- for(int i = 0; i < numclauses; i++) {
- int numterms = (random() % (maxclause -1)) + 1;
-
- for(int j = 0; j < numterms; j++) {
- uint src = random() % (numpoints - 1);
- uint dst;
- do {
- dst = random() % numpoints;
- } while (src == dst || ((false) && (src > dst)));
-
- be[j] = solver->orderConstraint(order, src, dst);
- }
- solver->addConstraint(solver->applyLogicalOperation(SATC_OR, be, numterms));
- }
- solver->serialize();
- if (solver->solve() == 1) {
- printf("SAT\n");
- } else {
- printf("UNSAT\n");
- }
- delete solver;
+ if (numargs < 4) {
+ printf("Requires the following arguments: numpoints numclauses maxclausesize randomseed\n");
+ return -1;
+ }
+ int numpoints = atoi(argv[1]);
+ int numclauses = atoi(argv[2]);
+ int maxclause = atoi(argv[3]);
+ srandom(atoi(argv[4]));
+
+ CSolver *solver = new CSolver();
+ Set *s = solver->createRangeSet(0, 0, numpoints);
+ Order *order = solver->createOrder(SATC_TOTAL, s);
+ BooleanEdge be[maxclause];
+ for (int i = 0; i < numclauses; i++) {
+ int numterms = (random() % (maxclause - 1)) + 1;
+
+ for (int j = 0; j < numterms; j++) {
+ uint src = random() % (numpoints - 1);
+ uint dst;
+ do {
+ dst = random() % numpoints;
+ } while (src == dst || ((false) && (src > dst)));
+
+ be[j] = solver->orderConstraint(order, src, dst);
+ }
+ solver->addConstraint(solver->applyLogicalOperation(SATC_OR, be, numterms));
+ }
+ solver->serialize();
+ if (solver->solve() == 1) {
+ printf("SAT\n");
+ } else {
+ printf("UNSAT\n");
+ }
+ delete solver;
}
#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);
+ {
+ 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");
- elem_bin->setTunable(ENCODINGGRAPHOPT, &onoff, 1);
- elem_onehot->setTunable(ENCODINGGRAPHOPT, &onoff, 1);
- elem_unary->setTunable(ENCODINGGRAPHOPT, &onoff, 1);
- elem_bin->serialize("circuitbinarytuner.conf");
- elem_onehot->serialize("circuitonehottuner.conf");
- elem_unary->serialize("circuitunarytuner.conf");
- delete elem_bin;
- delete elem_onehot;
- delete elem_unary;
+ elem_bin->serialize("binarytuner.conf");
+ elem_onehot->serialize("onehottuner.conf");
+ elem_unary->serialize("unarytuner.conf");
+ elem_bin->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_onehot->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_unary->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_bin->serialize("circuitbinarytuner.conf");
+ elem_onehot->serialize("circuitonehottuner.conf");
+ elem_unary->serialize("circuitunarytuner.conf");
+ elem_bin->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_onehot->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_unary->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_bin->serialize("circuitbinarytunernodecompose.conf");
+ elem_onehot->serialize("circuitonehottunernodecompose.conf");
+ elem_unary->serialize("circuitunarytunernodecompose.conf");
+ delete elem_bin;
+ delete elem_onehot;
+ delete elem_unary;
+ }
+ {
+ 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->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_onehot->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_unary->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_bin->serialize("binarytunernodecompose.conf");
+ elem_onehot->serialize("onehottunernodecompose.conf");
+ elem_unary->serialize("unarytunernodecompose.conf");
+ delete elem_bin;
+ delete elem_onehot;
+ delete elem_unary;
+ }
+
+
+ {
+ 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->setTunable(ORDERINTEGERENCODING, &offon, 1);
+ elem_onehot->setTunable(ORDERINTEGERENCODING, &offon, 1);
+ elem_unary->setTunable(ORDERINTEGERENCODING, &offon, 1);
+
+ elem_bin->serialize("binarytunerint.conf");
+ elem_onehot->serialize("onehottunerint.conf");
+ elem_unary->serialize("unarytunerint.conf");
+ elem_bin->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_onehot->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_unary->setTunable(ENCODINGGRAPHOPT, &offon, 1);
+ elem_bin->serialize("circuitbinarytunerint.conf");
+ elem_onehot->serialize("circuitonehottunerint.conf");
+ elem_unary->serialize("circuitunarytunerint.conf");
+ elem_bin->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_onehot->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_unary->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_bin->serialize("circuitbinarytunernodecomposeint.conf");
+ elem_onehot->serialize("circuitonehottunernodecomposeint.conf");
+ elem_unary->serialize("circuitunarytunernodecomposeint.conf");
+ delete elem_bin;
+ delete elem_onehot;
+ delete elem_unary;
+ }
+ {
+ 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->setTunable(ORDERINTEGERENCODING, &offon, 1);
+ elem_onehot->setTunable(ORDERINTEGERENCODING, &offon, 1);
+ elem_unary->setTunable(ORDERINTEGERENCODING, &offon, 1);
+ elem_bin->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_onehot->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_unary->setTunable(DECOMPOSEORDER, &onoff, 0);
+ elem_bin->serialize("binarytunernodecomposeint.conf");
+ elem_onehot->serialize("onehottunernodecomposeint.conf");
+ elem_unary->serialize("unarytunernodecomposeint.conf");
+ delete elem_bin;
+ delete elem_onehot;
+ delete elem_unary;
+ }
}