Merge branch 'encoding'
[satune.git] / src / csolver.cc
index 3c6767f585078bba9c0037afa6b259acb02282c2..0eebb1759e8fde28ae529b403e853ad8e0f3202d 100644 (file)
@@ -19,6 +19,8 @@
 #include "integerencoding.h"
 #include "qsort.h"
 #include "preprocess.h"
+#include "serializer.h"
+#include "deserializer.h"
 
 CSolver::CSolver() :
        boolTrue(BooleanEdge(new BooleanConst(true))),
@@ -84,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);
@@ -207,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) {