73extern "C" int MainSat(
int argc,
char** argv)
76 setUsageHelp(
"USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n");
80 fpu_control_t oldcw, newcw;
81 _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
82 printf(
"WARNING: for repeatability, setting FPU to use double precision\n");
86 IntOption verb (
"MAIN",
"verb",
"Verbosity level (0=silent, 1=some, 2=more).", 1,
IntRange(0, 2));
94 double initial_time = cpuTime();
128 printf(
"Reading from standard input... Use '--help' for help.\n");
134 printf(
"ERROR! Could not open file: %s\n", argc == 1 ?
"<stdin>" : argv[1]),
exit(1);
136 if (S.verbosity > 0){
137 printf(
"============================[ Problem Statistics ]=============================\n");
142 FILE* res = (argc >= 3) ? fopen(argv[2],
"wb") : NULL;
144 if (S.verbosity > 0){
145 printf(
"| Number of variables: %12d |\n", S.nVars());
146 printf(
"| Number of clauses: %12d |\n", S.nClauses()); }
148 double parsed_time = cpuTime();
149 if (S.verbosity > 0){
150 printf(
"| Parse time: %12.2f s |\n", parsed_time - initial_time);
159 if (res != NULL) fprintf(res,
"UNSAT\n"), fclose(res);
160 if (S.verbosity > 0){
161 printf(
"===============================================================================\n");
162 printf(
"Solved by unit propagation\n");
165 printf(
"UNSATISFIABLE\n");
170 lbool ret = S.solveLimited(dummy);
171 if (S.verbosity > 0){
174 printf(ret ==
l_True ?
"SATISFIABLE\n" : ret ==
l_False ?
"UNSATISFIABLE\n" :
"INDETERMINATE\n");
177 fprintf(res,
"SAT\n");
178 for (
int i = 0; i < S.nVars(); i++)
180 fprintf(res,
"%s%s%d", (i==0)?
"":
" ", (S.model[i]==
l_True)?
"":
"-", i+1);
181 fprintf(res,
" 0\n");
183 fprintf(res,
"UNSAT\n");
185 fprintf(res,
"INDET\n");
195 printf(
"===============================================================================\n");
196 printf(
"INDETERMINATE\n");
int MainSat(int argc, char **argv)
void printStats(Solver &solver)