CNF *createCNF() {
CNF *cnf = (CNF *) ourmalloc(sizeof(CNF));
cnf->varcount = 1;
+ cnf->clausecount = 0;
cnf->solver = allocIncrementalSolver();
cnf->solveTime = 0;
cnf->encodeTime = 0;
void resetCNF(CNF *cnf) {
resetSolver(cnf->solver);
cnf->varcount = 1;
+ cnf->clausecount = 0;
cnf->solveTime = 0;
cnf->encodeTime = 0;
cnf->unsat = false;
}
}
+void addClause(CNF *cnf, uint numliterals, int *literals){
+ cnf->clausecount++;
+ addArrayClauseLiteral(cnf->solver, numliterals, literals);
+}
+
void outputCNFOR(CNF *cnf, Edge cnfform, Edge eorvar) {
Node *andNode = cnfform.node_ptr;
int orvar = getEdgeVar(eorvar);
if (edgeIsVarConst(e)) {
int array[2] = {getEdgeVar(e), orvar};
ASSERT(array[0] != 0);
- addArrayClauseLiteral(cnf->solver, 2, array);
+ addClause(cnf, 2, array);
} else {
Node *clause = e.node_ptr;
uint cnumEdges = clause->numEdges + 1;
ASSERT(array[j] != 0);
}
array[cnumEdges - 1] = orvar;
- addArrayClauseLiteral(cnf->solver, cnumEdges, array);
+ addClause(cnf, cnumEdges, array);
}
}
}
if (edgeIsVarConst(e)) {
int array[1] = {getEdgeVar(e)};
ASSERT(array[0] != 0);
- addArrayClauseLiteral(cnf->solver, 1, array);
+ addClause(cnf, 1, array);
} else {
Node *clause = e.node_ptr;
uint cnumEdges = clause->numEdges;
array[j] = getEdgeVar(clause->edges[j]);
ASSERT(array[j] != 0);
}
- addArrayClauseLiteral(cnf->solver, cnumEdges, array);
+ addClause(cnf, cnumEdges, array);
}
}
}
long long startTime = getTimeNano();
finishedClauses(cnf->solver);
long long startSolve = getTimeNano();
+ model_print("#Clauses = %u\t#Vars = %u\n", cnf->clausecount, cnf->varcount);
int result = cnf->unsat ? IS_UNSAT : solve(cnf->solver);
long long finishTime = getTimeNano();
cnf->encodeTime = startSolve - startTime;
struct CNF {
uint varcount;
+ uint clausecount;
uint asize;
IncrementalSolver *solver;
int *array;
void outputCNF(CNF *cnf, Edge cnfform);
void outputCNFOR(CNF *cnf, Edge cnfform, Edge eorvar);
void generateProxy(CNF *cnf, Edge expression, Edge proxy, Polarity p);
-
+void addClause(CNF *cnf, uint numliterals, int *literals);
Edge generateBinaryConstraint(CNF *cnf, uint numvars, Edge *vars, uint value);
Edge generateLTValueConstraint(CNF *cnf, uint numvars, Edge *vars, uint value);
Edge generateEquivNVConstraint(CNF *cnf, uint numvars, Edge *var1, Edge *var2);