@@ -38,7 +38,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
3838#include " core/Dimacs.h"
3939#include " core/Solver.h"
4040
41- using namespace Minisat ;
41+ using namespace Glucose ;
4242
4343// =================================================================================================
4444
@@ -47,7 +47,7 @@ void printStats(Solver& solver)
4747{
4848 double cpu_time = cpuTime ();
4949 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 ) );
5151 printf (" c blocked restarts : %" PRIu64" (multiple: %" PRIu64" ) \n " , solver.nbstopsrestarts ,solver.nbstopsrestartssame );
5252 printf (" c last block at restart : %" PRIu64" \n " ,solver.lastblockatrestart );
5353 printf (" c nb ReduceDB : %lld\n " , solver.nbReduceDB );
@@ -89,7 +89,7 @@ static void SIGINT_exit(int signum) {
8989
9090int main (int argc, char ** argv)
9191{
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 " );
9393 try {
9494 setUsageHelp (" c USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n " );
9595 // printf("This is MiniSat 2.0 beta\n");
@@ -102,17 +102,20 @@ int main(int argc, char** argv)
102102 // Extra options:
103103 //
104104 IntOption verb (" MAIN" , " verb" , " Verbosity level (0=silent, 1=some, 2=more)." , 1 , IntRange (0 , 2 ));
105+ BoolOption mod (" MAIN" , " model" , " show model." , false );
105106 IntOption vv (" MAIN" , " vv" , " Verbosity every vv conflicts" , 10000 , IntRange (1 ,INT32_MAX));
106107 IntOption cpu_lim (" MAIN" , " cpu-lim" ," Limit on CPU time allowed in seconds.\n " , INT32_MAX, IntRange (0 , INT32_MAX));
107108 IntOption mem_lim (" MAIN" , " mem-lim" ," Limit on memory usage in megabytes.\n " , INT32_MAX, IntRange (0 , INT32_MAX));
108109
110+
109111 parseOptions (argc, argv, true );
110112
111113 Solver S;
112114 double initial_time = cpuTime ();
113115
114116 S.verbosity = verb;
115117 S.verbEveryConflicts = vv;
118+ S.showModel = mod;
116119 solver = &S;
117120 // Use signal handlers that forcibly quit until the solver will be able to respond to
118121 // interrupts:
@@ -153,8 +156,11 @@ int main(int argc, char** argv)
153156
154157 parse_DIMACS (in, S);
155158 gzclose (in);
156- FILE* res = (argc >= 3 ) ? fopen (argv[2 ], " wb" ) : NULL ;
157159
160+
161+
162+ FILE* res = (argc >= 3 ) ? fopen (argv[argc-1 ], " wb" ) : NULL ;
163+
158164 if (S.verbosity > 0 ){
159165 printf (" c | Number of variables: %12d |\n " , S.nVars ());
160166 printf (" c | Number of clauses: %12d |\n " , S.nClauses ()); }
@@ -170,6 +176,7 @@ int main(int argc, char** argv)
170176 // signal(SIGXCPU,SIGINT_interrupt);
171177
172178 if (!S.simplify ()){
179+ if (S.certifiedOutput != NULL ) fprintf (S.certifiedOutput , " 0\n " ), fclose (S.certifiedOutput );
173180 if (res != NULL ) fprintf (res, " UNSAT\n " ), fclose (res);
174181 if (S.verbosity > 0 ){
175182 printf (" c =========================================================================================================\n " );
@@ -179,35 +186,40 @@ int main(int argc, char** argv)
179186 printf (" s UNSATISFIABLE\n " );
180187 exit (20 );
181188 }
182-
189+
183190 vec<Lit> dummy;
184191 lbool ret = S.solveLimited (dummy);
185192 if (S.verbosity > 0 ){
186193 printStats (S);
187194 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) {
203214 printf (" v " );
204215 for (int i = 0 ; i < S.nVars (); i++)
205216 if (S.model [i] != l_Undef)
206217 printf (" %s%s%d" , (i==0 )?" " :" " , (S.model [i]==l_True)?" " :" -" , i+1 );
207218 printf (" 0\n " );
208219 }
209220 }
210-
221+
222+
211223#ifdef NDEBUG
212224 exit (ret == l_True ? 10 : ret == l_False ? 20 : 0 ); // (faster than "return", which will invoke the destructor for 'Solver')
213225#else
0 commit comments