From: Hamed Gorjiara Date: Fri, 7 Sep 2018 20:26:09 +0000 (-0700) Subject: Making benchmarks as similar as possible to the original encoding X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5600505b297543ad8c1d63a20c9dd569bc315604;p=Benchmarks_CSolver.git Making benchmarks as similar as possible to the original encoding --- diff --git a/killerSudoku/csolversudoku.py b/killerSudoku/csolversudoku.py index 960fa7f8..6e60ea29 100644 --- a/killerSudoku/csolversudoku.py +++ b/killerSudoku/csolversudoku.py @@ -130,9 +130,12 @@ def generateKillerSudokuConstraints(N, killerRules, serialize): # for j, elem in enumerate(row): # csolverlb.mustHaveValue(solver, elem) - # ensure rows and columns have distinct values + # ensure rows have distinct values for i in range( N): valid(problem[:,i]) + + # ensure columns have distinct values + for i in range( N): valid(problem[i,:]) # ensure each block has distinct values diff --git a/killerSudoku/killerSolver.py b/killerSudoku/killerSolver.py index a6241477..c4775044 100644 --- a/killerSudoku/killerSolver.py +++ b/killerSudoku/killerSolver.py @@ -247,6 +247,7 @@ def encode_to_cnf(killerRules): #encode a problem (stored in matrix) as cnf for j in range(N): temp.append(getIndex(i,j,k)) cnf = cnf + exactly_one(temp) + #exactly once in each block sqrRootN = int(N**(0.5)) for block_i in range(sqrRootN):