static int btor_picosat_inc_max_var (BtorSATMgr * smgr) { return picosat_inc_max_var (smgr->solver); }
int main(int argc, char **argv) { int i,j,k,l,m; if (argc < 2) { fprintf(stderr, "usage: sudoku [puzzles]\n"); exit(1); } picosat_init(); /* picosat_enable_trace_generation(); */ mapFile = fopen("var-map.txt", "w"), assert(mapFile); cnfFile = fopen("general.cnf", "w"), assert(cnfFile); if (0 == strcmp(argv[1], "-") || argc <= 1) { inputFile = stdin; } else { inputFile = fopen(argv[1], "r"); } /* create vars */ for (j = 0; j < N; j++) { for (k = 0; k < N; k++) { for (i = 0; i < N; i++) { p[i][j][k] = picosat_inc_max_var(); fprintf(mapFile, "%d = p[%d][%d][%d]\n", p[i][j][k], i, j, k); } } } fprintf(stderr, "%d variables\n", picosat_variables()); /* each cell set to at least one value */ for (j = 0; j < N; j++) { for (k = 0; k < N; k++) { for (i = 0; i < N; i++) { picosat_add(p[i][j][k]); } picosat_add(0); } } /* each cell set to at most one value */ for (j = 0; j < N; j++) { for (k = 0; k < N; k++) { for (i = 0; i < N; i++) { for (l = 0; l < N; l++) { if (i != l) { /* pijk -> !pljk (when l!=i) */ picosat_add(-p[i][j][k]); picosat_add(-p[l][j][k]); picosat_add(0); } } } } } /* column: no cell has the same value */ LINE(i,0,N, j,0,N, k,0,N, { for (l = 0; l < N; l++) { if (l != j) { picosat_add(-p[i][j][k]); picosat_add(-p[i][l][k]); picosat_add(0); } } });