@@ -435,6 +435,7 @@ int main(int argc, char* argv[])
435
435
void print_solution_cnf_style (const Solution& solution);
436
436
void check_solution (const ANF* anf, const Solution& solution);
437
437
void print_solution_anf_style (const Solution& solution);
438
+ void clear_solution_file ();
438
439
void write_solution_to_file_cnf_style (const Solution& solution);
439
440
void ban_solution (CMSat::SATSolver& solver, const Solution& solution);
440
441
@@ -455,6 +456,7 @@ void solve(Bosph::Bosphorus* mylib, CNF* cnf, ANF* anf) {
455
456
solver.add_clause (*cc2);
456
457
}
457
458
459
+ clear_solution_file ();
458
460
uint32_t number_of_solutions = 0 ;
459
461
while (true ) {
460
462
CMSat::lbool ret = solver.solve ();
@@ -470,9 +472,7 @@ void solve(Bosph::Bosphorus* mylib, CNF* cnf, ANF* anf) {
470
472
solution. ret = l_False;
471
473
}
472
474
print_solution_anf_style (solution);
473
- if (!solution_output_file.empty ()) {
474
- write_solution_to_file_cnf_style (solution);
475
- }
475
+ write_solution_to_file_cnf_style (solution);
476
476
if (ret == CMSat::l_True) {
477
477
check_solution (anf, solution);
478
478
}
@@ -488,15 +488,35 @@ void solve(Bosph::Bosphorus* mylib, CNF* cnf, ANF* anf) {
488
488
}
489
489
}
490
490
491
- void write_solution_to_file_cnf_style ( const Solution& solution )
491
+ void clear_solution_file ( )
492
492
{
493
+ if (solution_output_file.empty ()) {
494
+ return ;
495
+ }
496
+
493
497
std::ofstream ofs;
494
498
ofs.open (solution_output_file);
495
499
if (!ofs) {
496
500
std::cerr << " c Error opening file \" " << solution_output_file
497
501
<< " \" for writing\n " ;
498
502
exit (-1 );
499
503
}
504
+ ofs.close ();
505
+ }
506
+
507
+ void write_solution_to_file_cnf_style (const Solution& solution)
508
+ {
509
+ if (solution_output_file.empty ()) {
510
+ return ;
511
+ }
512
+
513
+ std::ofstream ofs;
514
+ ofs.open (solution_output_file, std::ios_base::app);
515
+ if (!ofs) {
516
+ std::cerr << " c Error opening file \" " << solution_output_file
517
+ << " \" for writing\n " ;
518
+ exit (-1 );
519
+ }
500
520
assert (solution.ret != l_Undef);
501
521
ofs << " Solution " ;
502
522
ofs << ((solution.ret == l_True) ? " SAT" : " UNSAT" ) << endl;
0 commit comments