def test_cycosat_simple(): sat = CoSAT() problem = [[1, -4], [1, -2], [1, 4], [-4, -2], [-4, 4], [-2, 4], [-1, 4, 2, -4]] sat.add_clauses(problem) assert sat.solve() == [1, -1, -1, -1]
def solve(self, cells): sat = CoSAT() sat.add_clauses(self.conditions) assumes = [self.bools[r, c, v-1] for (r, c), v in cells.iteritems()] solution = sat.assume_solve(assumes) if isinstance(solution, list): res = np.array(sat.solve()) mask = (res > 0).reshape(9, 9, 9) return (np.where(mask)[2]+1).reshape(9, 9) else: return None