board_input.print_to_stdout()
csolverlb = ps.loadCSolver();
csolver = csolverlb.createCCSolver()
+ if len(sys.argv) > 2 and sys.argv[-1] == "--alloy":
+ csolverlb.setAlloyEncoder(csolver)
formulation = SAT_formulation_from_board_input(board_input, csolverlb, csolver)
print '=== Done! Calling CSolver solver now ==='
if len(sys.argv) > 2 and sys.argv[-1] == "--dump":
csolverlb.serialize(csolver)
- if len(sys.argv) > 2 and sys.argv[-1] == "--alloy":
- csolverlb.setAlloyEncoder(csolver)
+
# csolverlb.printConstraints(csolver)
if csolverlb.solve(csolver) != 1:
print '*** Got UNSAT result! ***'
def generateKillerSudokuConstraints(N, killerRules, solverOption):
csolverlb = ps.loadCSolver()
solver = csolverlb.createCCSolver()
+ if solverOption == Solver.ALLOY:
+ csolverlb.setAlloyEncoder(solver)
s1 = [ i for i in range(1, N+1)]
set1 = (c_long* len(s1))(*s1)
s1 = csolverlb.createSet(solver, c_uint(1), set1, c_uint(N))
valid([problem[i + k % root, j + k // root] for k in range(N)])
#Serializing the problem before solving it ....
+ print "Done with encoding ...."
if solverOption == Solver.SERIALISE:
csolverlb.serialize(solver)
- if solverOption == Solver.ALLOY:
- csolverlb.setAlloyEncoder(solver)
+
+ print "start solving the problem ..."
if csolverlb.solve(solver) != 1:
return None
result = [[0 for i in range(N)] for i in range(N)]
return;
}
CSolver *solver = new CSolver();
+ if(stype = ALLOY){
+ solver->setAlloyEncoder();
+ }
+
uint64_t domain[N];
for(int i=0; i<N; i++){
domain[i] = i;
// solver->printConstraints();
if(stype == DUMP){
solver->serialize();
- } else if(stype = ALLOY){
- solver->setAlloyEncoder();
- }
- if (solver->solve() != 1){
+ } if (solver->solve() != 1){
printf("Problem is Unsolvable ...\n");
}else {
int table[N*N];
def generateSudokuConstraints(N, sudoku = None, solverID = -1):
csolverlb = ps.loadCSolver()
solver = csolverlb.createCCSolver()
+ if solverID == Solver.ALLOY:
+ csolverlb.setAlloyEncoder(solver)
s1 = [ i for i in range(1, N+1)]
set1 = (c_long* len(s1))(*s1)
s1 = csolverlb.createSet(solver, c_uint(1), set1, c_uint(N))
#Serializing the problem before solving it ....
if solverID == Solver.SERIALISE:
csolverlb.serialize(solver)
- if solverID == Solver.ALLOY:
- csolverlb.setAlloyEncoder(solver)
+
if csolverlb.solve(solver) != 1:
print "Problem is unsolvable!"
sys.exit(1)