Merge branch 'encoding'
[satune.git] / src / csolver.cc
index 62f76ab2223065363a8fcbdcfccdba0cb2e5b862..0eebb1759e8fde28ae529b403e853ad8e0f3202d 100644 (file)
@@ -18,6 +18,9 @@
 #include "orderresolver.h"
 #include "integerencoding.h"
 #include "qsort.h"
+#include "preprocess.h"
+#include "serializer.h"
+#include "deserializer.h"
 
 CSolver::CSolver() :
        boolTrue(BooleanEdge(new BooleanConst(true))),
@@ -83,6 +86,25 @@ CSolver *CSolver::clone() {
        return copy;
 }
 
+void CSolver::serialize() {
+       model_print("serializing ...\n");
+       {
+               Serializer serializer("dump");
+               SetIteratorBooleanEdge *it = getConstraints();
+               while (it->hasNext()) {
+                       BooleanEdge b = it->next();
+                       serializeBooleanEdge(&serializer, b);
+               }
+               delete it;
+       }
+       model_print("deserializing ...\n");
+       {
+               Deserializer deserializer("dump");
+               deserializer.deserialize();
+       }
+       
+}
+
 Set *CSolver::createSet(VarType type, uint64_t *elements, uint numelements) {
        Set *set = new Set(type, elements, numelements);
        allSets.push(set);
@@ -125,7 +147,7 @@ Element *CSolver::getElementVar(Set *set) {
 Element *CSolver::getElementConst(VarType type, uint64_t value) {
        uint64_t array[] = {value};
        Set *set = new Set(type, array, 1);
-       Element *element = new ElementConst(value, type, set);
+       Element *element = new ElementConst(value, set);
        Element *e = elemMap.get(element);
        if (e == NULL) {
                allSets.push(set);
@@ -206,7 +228,7 @@ BooleanEdge CSolver::getBooleanFalse() {
 }
 
 BooleanEdge CSolver::applyPredicate(Predicate *predicate, Element **inputs, uint numInputs) {
-       return applyPredicateTable(predicate, inputs, numInputs, NULL);
+       return applyPredicateTable(predicate, inputs, numInputs, BooleanEdge(NULL));
 }
 
 BooleanEdge CSolver::applyPredicateTable(Predicate *predicate, Element **inputs, uint numInputs, BooleanEdge undefinedStatus) {
@@ -403,6 +425,9 @@ int CSolver::solve() {
        long long startTime = getTimeNano();
        computePolarities(this);
 
+       Preprocess pp(this);
+       pp.doTransform();
+       
        DecomposeOrderTransform dot(this);
        dot.doTransform();