74{
75 try {
76 setUsageHelp(
"USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n");
77
78
79#if defined(__linux__)
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");
83#endif
84
85
86 IntOption verb (
"MAIN",
"verb",
"Verbosity level (0=silent, 1=some, 2=more).", 1,
IntRange(0, 2));
89
91 return 1;
92
94 double initial_time = cpuTime();
95
96 S.verbosity = verb;
97
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126 if (argc == 1)
127 {
128 printf("Reading from standard input... Use '--help' for help.\n");
129 return 1;
130 }
131
133 if (in == NULL)
134 printf(
"ERROR! Could not open file: %s\n", argc == 1 ?
"<stdin>" : argv[1]),
exit(1);
135
136 if (S.verbosity > 0){
137 printf("============================[ Problem Statistics ]=============================\n");
138 printf("| |\n"); }
139
140 parse_DIMACS(in, S);
142 FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
143
144 if (S.verbosity > 0){
145 printf("| Number of variables: %12d |\n", S.nVars());
146 printf("| Number of clauses: %12d |\n", S.nClauses()); }
147
148 double parsed_time = cpuTime();
149 if (S.verbosity > 0){
150 printf("| Parse time: %12.2f s |\n", parsed_time - initial_time);
151 printf("| |\n"); }
152
153
154
155
156
157
158 if (!S.simplify()){
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");
164 printf("\n"); }
165 printf("UNSATISFIABLE\n");
167 }
168
170 lbool ret = S.solveLimited(dummy);
171 if (S.verbosity > 0){
173 printf("\n"); }
174 printf(ret ==
l_True ?
"SATISFIABLE\n" : ret ==
l_False ?
"UNSATISFIABLE\n" :
"INDETERMINATE\n");
175 if (res != NULL){
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");
184 else
185 fprintf(res, "INDET\n");
186 fclose(res);
187 }
188
189
190
191
193
195 printf("===============================================================================\n");
196 printf("INDETERMINATE\n");
198 }
199}
void printStats(Solver &solver)
ABC_NAMESPACE_IMPL_START int ZEXPORT gzclose(gzFile file)
gzFile ZEXPORT gzdopen(int fd, const char *mode)
gzFile ZEXPORT gzopen(const char *path, const char *mode)
void setUsageHelp(const char *str)
int parseOptions(int &argc, char **argv, bool strict=false)