@@ -84,6 +84,7 @@ vector<int> lits_to_ints(const vector<Lit>& lits) {
8484// LOTS of repairs, fast, but does not terminate: benchmarks-qdimacs/query01_query42_1344n.qdimacs.cnf
8585// many repairs, does finish: benchmarks-qdimacs/stmt32_329_378.qdimacs.cnf
8686// many-many repairs, does finish: benchmarks-qdimacs/sdlx-fixpoint-10.qdimacs.cnf
87+ // no repair, learning/mbve does it: rankfunc57_unsigned_64.qdimacs.cnf
8788
8889template <typename S>
8990void Manthan::inject_cnf (S& s, bool also_vars) const {
@@ -396,7 +397,7 @@ void Manthan::print_y_order_occur() const {
396397 for (const auto & y: y_order) {
397398 const uint32_t pos = occur_lit[Lit (y, false ).toInt ()];
398399 const uint32_t neg = occur_lit[Lit (y, true ).toInt ()];
399- verb_print (2 , " [y-order] var " << setw (4 ) << y+1
400+ verb_print (2 , " [manthan] y-order var " << setw (4 ) << y+1
400401 << " BW: " << backward_defined.count (y)
401402 << " pos occur " << setw (6 ) << pos
402403 << " -- neg occur " << setw (6 ) << neg);
@@ -578,22 +579,26 @@ void Manthan::bve_and_substitute() {
578579
579580 FHolder::Formula f;
580581 map<uint32_t , aig_ptr> transformed;
581- auto overall = aig_mng.new_const (false );
582582
583583 // For optimizing which side of the BVE to take
584- /* uint32_t num_pos = 0; */
585- /* uint32_t num_neg = 0; */
586- /* for(const auto& cl: cnf.get_clauses()) { */
587- /* for(const auto& l: cl) { */
588- /* if (l.var() == v) { */
589- /* if (l.sign()) num_neg++; */
590- /* else num_pos++; */
591- /* break; */
592- /* } */
593- /* } */
594- /* } */
595- /* bool sign = (num_pos >= num_neg); */
596- bool sign = false ;
584+ uint32_t num_pos = 0 ;
585+ uint32_t num_neg = 0 ;
586+ for (const auto & cl: cnf.get_clauses ()) {
587+ for (const auto & l: cl) {
588+ if (l.var () == v) {
589+ if (l.sign ()) num_neg++;
590+ else num_pos++;
591+ break ;
592+ }
593+ }
594+ }
595+ verb_print (2 , " [manthan] bve var " << setw (5 ) << v+1
596+ << " pos occur: " << setw (6 ) << num_pos
597+ << " neg occur: " << setw (6 ) << num_neg);
598+
599+ const bool sign = (num_pos >= num_neg);
600+ /* const bool sign = false; */
601+ aig_ptr overall = nullptr ;
597602 for (const auto & cl: cnf.get_clauses ()) {
598603 bool todo = false ;
599604 for (const auto & l: cl) {
@@ -622,9 +627,11 @@ void Manthan::bve_and_substitute() {
622627 }
623628 }
624629 }
625- overall = AIG::new_or ( overall, current) ;
626- if (sign) overall = AIG::new_not (overall);
630+ if ( overall == nullptr ) overall = current;
631+ else overall = AIG::new_or (overall, current );
627632 }
633+ if (overall == nullptr ) overall = aig_mng.new_const (true );
634+ if (sign) overall->flip ();
628635
629636 f.aig = AIG::simplify (overall);
630637 var_to_formula[v] = f;
0 commit comments