Overview: Implement either DPLL (referred to as “DP” in the textbook) or Walksat. Evaluate its scaling (run time) on randomly generated 3CNF formulas. Due by Blackboard turn-in by 11:59pm Tuesday Oct 26.
If P is indeed chosen to flipped to a new value, then where L is the original value of P, step through the clauses in C[L] and add any that have become false to U, and step through the clauses in C[-L] and remove any that used to be false and after the flip are true from U.count = 0; L = (S[P] > 0) ? P : -P; for each clause c in C[L] if L is the only true literal in c then count ++; return count
dpll LIMIT INFILE OUTFILEwhere
LIMIT is an integer specifying the maximum number of recursive calls of DPLL that are to be permitted;or
INFILE is a CNF formula in DIMACS format (see below)
OUTFILE is a satisfying assignment, also in DIMACS format, if one exists
walksat LIMIT INFILE OUTFILEwhere
LIMIT is an integer specifying the maximum of number of flips that are to be permitted, and
INFILE and OUTFILE are as above.
p cnf NUMBER_VARIABLE NUMBER_CLAUSES
3 -5 17 0
c This is a test example
p cnf 3 4
-1 3 0
1 -2 0
2 1 0
3 -2 1 0
SAT
1 -2 3 -4 0
time dpll 100000 f100.cnf f100.sol
Variables Answer Average Time (Seconds) 10 SAT 0.00001 10 UNSAT 0.00002 20 SAT 0.00002 20 UNSAT 0.00003
... ... ... 80 SAT 250.2400 80 UNSAT TIMEOUT on instances 3, 6, 9