#include "preprocess.h"
#include "serializer.h"
#include "deserializer.h"
-#include "naiveencoder.h"
+#include "encodinggraph.h"
CSolver::CSolver() :
boolTrue(BooleanEdge(new BooleanConst(true))),
return set;
}
+VarType CSolver::getSetVarType(Set *set){
+ return set->getType();
+}
+
Element *CSolver::createRangeVar(VarType type, uint64_t lowrange, uint64_t highrange) {
Set *s = createRangeSet(type, lowrange, highrange);
return getElementVar(s);
return element;
}
+Set* CSolver::getElementRange (Element* element){
+ return element->getRange();
+}
+
+
Element *CSolver::getElementConst(VarType type, uint64_t value) {
uint64_t array[] = {value};
Set *set = new Set(type, array, 1);
}
bool CSolver::isTrue(BooleanEdge b) {
- return b.isNegated()?b->isFalse():b->isTrue();
+ return b.isNegated()?b->isFalse():b->isTrue();
}
bool CSolver::isFalse(BooleanEdge b) {
- return b.isNegated()?b->isTrue():b->isFalse();
+ return b.isNegated()?b->isTrue():b->isFalse();
}
BooleanEdge CSolver::applyLogicalOperation(LogicOp op, BooleanEdge arg1, BooleanEdge arg2) {
case SATC_IFF: {
for (uint i = 0; i < 2; i++) {
if (array[i]->type == BOOLCONST) {
- if (array[i]->isTrue()) {
+ if (isTrue(array[i])) { // It can be undefined
return array[1 - i];
- } else {
+ } else if(isFalse(array[i])) {
newarray[0] = array[1 - i];
return applyLogicalOperation(SATC_NOT, newarray, 1);
}
return rewriteLogicalOperation(op, array, asize);
}
if (b->type == BOOLCONST) {
- if (b->isTrue())
+ if (isTrue(b))
continue;
- else
+ else{
return boolFalse;
+ }
} else
newarray[newindex++] = b;
}
return BooleanEdge(boolean);
} else {
delete boolean;
- return BooleanEdge(b);
+ return BooleanEdge(boolean);
}
}
BooleanEdge CSolver::orderConstraint(Order *order, uint64_t first, uint64_t second) {
+ ASSERT(first != second);
Boolean *constraint = new BooleanOrder(order, first, second);
allBooleans.push(constraint);
return BooleanEdge(constraint);
}
void CSolver::addConstraint(BooleanEdge constraint) {
+ if(constraint.isNegated())
+ model_print("!");
+ constraint.getBoolean()->print();
if (isTrue(constraint))
return;
- else if (isFalse(constraint))
+ else if (isFalse(constraint)) {
+ int t=0;
setUnSAT();
+ }
else {
if (constraint->type == LOGICOP) {
BooleanLogic *b=(BooleanLogic *) constraint.getBoolean();
constraints.add(constraint);
Boolean *ptr=constraint.getBoolean();
- if (ptr->boolVal == BV_UNSAT)
+ if (ptr->boolVal == BV_UNSAT) {
setUnSAT();
+ }
replaceBooleanWithTrueNoRemove(constraint);
constraint->parents.clear();
IntegerEncodingTransform iet(this);
iet.doTransform();
+ EncodingGraph eg(this);
+ eg.buildGraph();
+ eg.encode();
+
naiveEncodingDecision(this);
satEncoder->encodeAllSATEncoder(this);
+ model_print("Is problem UNSAT after encoding: %d\n", unsat);
int result = unsat ? IS_UNSAT : satEncoder->solve();
+ model_print("Result Computed in CSolver: %d\n", result);
long long finishTime = getTimeNano();
elapsedTime = finishTime - startTime;
if (deleteTuner) {