From 56b593b91cc693849e3b3b3de0666f6ec9a597f6 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 7 Jun 2013 14:37:33 +0200 Subject: Improved sat generator and sat_solve pass --- libs/ezsat/ezsat.cc | 4 ++++ libs/ezsat/ezsat.h | 3 ++- libs/ezsat/puzzle3d.cc | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'libs') diff --git a/libs/ezsat/ezsat.cc b/libs/ezsat/ezsat.cc index d6ebd678..cf9dd65b 100644 --- a/libs/ezsat/ezsat.cc +++ b/libs/ezsat/ezsat.cc @@ -34,6 +34,7 @@ ezSAT::ezSAT() cnfConsumed = false; cnfVariableCount = 0; + cnfClausesCount = 0; } ezSAT::~ezSAT() @@ -331,6 +332,7 @@ void ezSAT::clear() { cnfConsumed = false; cnfVariableCount = 0; + cnfClausesCount = 0; cnfLiteralVariables.clear(); cnfExpressionVariables.clear(); cnfClauses.clear(); @@ -342,11 +344,13 @@ void ezSAT::assume(int id) int idx = bind(id); cnfClauses.push_back(std::vector(1, idx)); cnfAssumptions.insert(id); + cnfClausesCount++; } void ezSAT::add_clause(const std::vector &args) { cnfClauses.push_back(args); + cnfClausesCount++; } void ezSAT::add_clause(const std::vector &args, bool argsPolarity, int a, int b, int c) diff --git a/libs/ezsat/ezsat.h b/libs/ezsat/ezsat.h index 29b7aca7..ea873a85 100644 --- a/libs/ezsat/ezsat.h +++ b/libs/ezsat/ezsat.h @@ -55,7 +55,7 @@ private: std::vector>> expressions; bool cnfConsumed; - int cnfVariableCount; + int cnfVariableCount, cnfClausesCount; std::vector cnfLiteralVariables, cnfExpressionVariables; std::vector> cnfClauses; std::set cnfAssumptions; @@ -137,6 +137,7 @@ public: int bound(int id) const; int numCnfVariables() const { return cnfVariableCount; } + int numCnfClauses() const { return cnfClausesCount; } const std::vector> &cnf() const { return cnfClauses; } void consumeCnf(); diff --git a/libs/ezsat/puzzle3d.cc b/libs/ezsat/puzzle3d.cc index 1655e697..56d29326 100644 --- a/libs/ezsat/puzzle3d.cc +++ b/libs/ezsat/puzzle3d.cc @@ -255,7 +255,7 @@ int main() ez.assume(ez.ordered(vecvec[0], vecvec[1])); printf("Found and eliminated %d spatial symmetries.\n", int(symmetries.size())); - printf("Generated %d clauses over %d variables.\n", ez.numCnfVariables(), int(ez.cnf().size())); + printf("Generated %d clauses over %d variables.\n", ez.numCnfClauses(), ez.numCnfVariables()); std::vector modelExpressions; std::vector modelValues; -- cgit v1.2.3