@@ -38,7 +38,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
38
38
#include " core/Dimacs.h"
39
39
#include " core/Solver.h"
40
40
41
- using namespace Minisat ;
41
+ using namespace Glucose ;
42
42
43
43
// =================================================================================================
44
44
@@ -47,7 +47,7 @@ void printStats(Solver& solver)
47
47
{
48
48
double cpu_time = cpuTime ();
49
49
double mem_used = 0 ;// memUsedPeak();
50
- printf (" c restarts : %" PRIu64" (%" PRIu64" conflicts in avg)\n " , solver.starts ,solver.conflicts /solver.starts );
50
+ printf (" c restarts : %" PRIu64" (%" PRIu64" conflicts in avg)\n " , solver.starts ,( solver.starts > 0 ?solver. conflicts /solver.starts : 0 ) );
51
51
printf (" c blocked restarts : %" PRIu64" (multiple: %" PRIu64" ) \n " , solver.nbstopsrestarts ,solver.nbstopsrestartssame );
52
52
printf (" c last block at restart : %" PRIu64" \n " ,solver.lastblockatrestart );
53
53
printf (" c nb ReduceDB : %lld\n " , solver.nbReduceDB );
@@ -89,7 +89,7 @@ static void SIGINT_exit(int signum) {
89
89
90
90
int main (int argc, char ** argv)
91
91
{
92
- printf (" c\n c This is glucose 2.1 -- based on MiniSAT (Many thanks to MiniSAT team)\n c\n " );
92
+ printf (" c\n c This is glucose 3.0 -- based on MiniSAT (Many thanks to MiniSAT team)\n c\n " );
93
93
try {
94
94
setUsageHelp (" c USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n " );
95
95
// printf("This is MiniSat 2.0 beta\n");
@@ -102,17 +102,20 @@ int main(int argc, char** argv)
102
102
// Extra options:
103
103
//
104
104
IntOption verb (" MAIN" , " verb" , " Verbosity level (0=silent, 1=some, 2=more)." , 1 , IntRange (0 , 2 ));
105
+ BoolOption mod (" MAIN" , " model" , " show model." , false );
105
106
IntOption vv (" MAIN" , " vv" , " Verbosity every vv conflicts" , 10000 , IntRange (1 ,INT32_MAX));
106
107
IntOption cpu_lim (" MAIN" , " cpu-lim" ," Limit on CPU time allowed in seconds.\n " , INT32_MAX, IntRange (0 , INT32_MAX));
107
108
IntOption mem_lim (" MAIN" , " mem-lim" ," Limit on memory usage in megabytes.\n " , INT32_MAX, IntRange (0 , INT32_MAX));
108
109
110
+
109
111
parseOptions (argc, argv, true );
110
112
111
113
Solver S;
112
114
double initial_time = cpuTime ();
113
115
114
116
S.verbosity = verb;
115
117
S.verbEveryConflicts = vv;
118
+ S.showModel = mod;
116
119
solver = &S;
117
120
// Use signal handlers that forcibly quit until the solver will be able to respond to
118
121
// interrupts:
@@ -153,8 +156,11 @@ int main(int argc, char** argv)
153
156
154
157
parse_DIMACS (in, S);
155
158
gzclose (in);
156
- FILE* res = (argc >= 3 ) ? fopen (argv[2 ], " wb" ) : NULL ;
157
159
160
+
161
+
162
+ FILE* res = (argc >= 3 ) ? fopen (argv[argc-1 ], " wb" ) : NULL ;
163
+
158
164
if (S.verbosity > 0 ){
159
165
printf (" c | Number of variables: %12d |\n " , S.nVars ());
160
166
printf (" c | Number of clauses: %12d |\n " , S.nClauses ()); }
@@ -170,6 +176,7 @@ int main(int argc, char** argv)
170
176
// signal(SIGXCPU,SIGINT_interrupt);
171
177
172
178
if (!S.simplify ()){
179
+ if (S.certifiedOutput != NULL ) fprintf (S.certifiedOutput , " 0\n " ), fclose (S.certifiedOutput );
173
180
if (res != NULL ) fprintf (res, " UNSAT\n " ), fclose (res);
174
181
if (S.verbosity > 0 ){
175
182
printf (" c =========================================================================================================\n " );
@@ -179,35 +186,40 @@ int main(int argc, char** argv)
179
186
printf (" s UNSATISFIABLE\n " );
180
187
exit (20 );
181
188
}
182
-
189
+
183
190
vec<Lit> dummy;
184
191
lbool ret = S.solveLimited (dummy);
185
192
if (S.verbosity > 0 ){
186
193
printStats (S);
187
194
printf (" \n " ); }
188
- if (res != NULL ){
189
- if (ret == l_True){
190
- fprintf (res, " SAT\n " );
191
- for (int i = 0 ; i < S.nVars (); i++)
192
- if (S.model [i] != l_Undef)
193
- fprintf (res, " %s%s%d" , (i==0 )?" " :" " , (S.model [i]==l_True)?" " :" -" , i+1 );
194
- fprintf (res, " 0\n " );
195
- }else if (ret == l_False)
196
- fprintf (res, " UNSAT\n " );
197
- else
198
- fprintf (res, " INDET\n " );
199
- fclose (res);
200
- } else {
201
- printf (ret == l_True ? " s SATISFIABLE\n " : ret == l_False ? " s UNSATISFIABLE\n " : " s INDETERMINATE\n " );
202
- if (ret==l_True) {
195
+
196
+ // -------------- Result is put in a external file
197
+ if (res != NULL ){
198
+ if (ret == l_True){
199
+ fprintf (res, " SAT\n " );
200
+ for (int i = 0 ; i < S.nVars (); i++)
201
+ if (S.model [i] != l_Undef)
202
+ fprintf (res, " %s%s%d" , (i==0 )?" " :" " , (S.model [i]==l_True)?" " :" -" , i+1 );
203
+ fprintf (res, " 0\n " );
204
+ }else if (ret == l_False)
205
+ fprintf (res, " UNSAT\n " );
206
+ else
207
+ fprintf (res, " INDET\n " );
208
+ fclose (res);
209
+
210
+ // -------------- Want certified output
211
+ } else {
212
+ printf (ret == l_True ? " s SATISFIABLE\n " : ret == l_False ? " s UNSATISFIABLE\n " : " s INDETERMINATE\n " );
213
+ if (S.showModel && ret==l_True) {
203
214
printf (" v " );
204
215
for (int i = 0 ; i < S.nVars (); i++)
205
216
if (S.model [i] != l_Undef)
206
217
printf (" %s%s%d" , (i==0 )?" " :" " , (S.model [i]==l_True)?" " :" -" , i+1 );
207
218
printf (" 0\n " );
208
219
}
209
220
}
210
-
221
+
222
+
211
223
#ifdef NDEBUG
212
224
exit (ret == l_True ? 10 : ret == l_False ? 20 : 0 ); // (faster than "return", which will invoke the destructor for 'Solver')
213
225
#else
0 commit comments