64{
65 try {
66 setUsageHelp(
"USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n");
67
68
69#if defined(__linux__)
70 fpu_control_t oldcw, newcw;
71 _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
72 printf("WARNING: for repeatability, setting FPU to use double precision\n");
73#endif
74
75
76 IntOption verb (
"MAIN",
"verb",
"Verbosity level (0=silent, 1=some, 2=more).", 1,
IntRange(0, 2));
77 BoolOption pre (
"MAIN",
"pre",
"Completely turn on/off any preprocessing.",
true);
78 StringOption dimacs (
"MAIN",
"dimacs",
"If given, stop after preprocessing and write the result to this file.");
81
83 return 1;
84
86 double initial_time = cpuTime();
87
88 if (!pre) S.eliminate(true);
89
90 S.verbosity = verb;
91
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 if (argc == 1)
121 {
122 printf("Reading from standard input... Use '--help' for help.\n");
123 return 1;
124 }
125
127 if (in == NULL)
128 printf(
"ERROR! Could not open file: %s\n", argc == 1 ?
"<stdin>" : argv[1]),
exit(1);
129
130 if (S.verbosity > 0){
131 printf("============================[ Problem Statistics ]=============================\n");
132 printf("| |\n"); }
133
134 parse_DIMACS(in, S);
136 FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
137
138 if (S.verbosity > 0){
139 printf("| Number of variables: %12d |\n", S.nVars());
140 printf("| Number of clauses: %12d |\n", S.nClauses()); }
141
142 double parsed_time = cpuTime();
143 if (S.verbosity > 0)
144 printf("| Parse time: %12.2f s |\n", parsed_time - initial_time);
145
146
147
148
149
150
151 S.eliminate(true);
152 double simplified_time = cpuTime();
153 if (S.verbosity > 0){
154 printf("| Simplification time: %12.2f s |\n", simplified_time - parsed_time);
155 printf("| |\n"); }
156
157 if (!S.okay()){
158 if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
159 if (S.verbosity > 0){
160 printf("===============================================================================\n");
161 printf("Solved by simplification\n");
163 printf("\n"); }
164 printf("UNSATISFIABLE\n");
166 }
167
168 if (dimacs){
169 if (S.verbosity > 0)
170 printf("==============================[ Writing DIMACS ]===============================\n");
171 S.toDimacs((const char*)dimacs);
172 if (S.verbosity > 0)
175 }
176
178 lbool ret = S.solveLimited(dummy);
179
180 if (S.verbosity > 0){
182 printf("\n"); }
183 printf(ret ==
l_True ?
"SATISFIABLE\n" : ret ==
l_False ?
"UNSATISFIABLE\n" :
"INDETERMINATE\n");
184 if (res != NULL){
186 fprintf(res, "SAT\n");
187 for (int i = 0; i < S.nVars(); i++)
189 fprintf(res,
"%s%s%d", (i==0)?
"":
" ", (S.model[i]==
l_True)?
"":
"-", i+1);
190 fprintf(res, " 0\n");
192 fprintf(res, "UNSAT\n");
193 else
194 fprintf(res, "INDET\n");
195 fclose(res);
196 }
197
198
199
200
202
204 printf("===============================================================================\n");
205 printf("INDETERMINATE\n");
207 }
208}
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)