@@ -447,26 +447,13 @@ namespace lp {
447447 }
448448
449449 lia_move tighten_with_S () {
450- int change = 0 ;
451450 for (unsigned j = 0 ; j < lra.column_count (); j++) {
452451 if (!lra.column_has_term (j) || lra.column_is_free (j) ||
453452 lra.column_is_fixed (j) || !lia.column_is_int (j)) continue ;
454- if (tighten_bounds_for_term_column (j)) {
455- change++;
456- }
457- if (!m_infeas_explanation.empty ()) {
453+ if (tighten_bounds_for_term_column (j))
458454 return lia_move::conflict;
459- }
460- }
461- TRACE (" dioph_eq" , tout << " change:" << change << " \n " ;);
462- if (!change)
463- return lia_move::undef;
464-
465- auto st = lra.find_feasible_solution ();
466- if (st != lp::lp_status::FEASIBLE && st != lp::lp_status::OPTIMAL && st != lp::lp_status::CANCELLED) {
467- lra.get_infeasibility_explanation (m_infeas_explanation);
468- return lia_move::conflict;
469- }
455+ }
456+
470457 return lia_move::undef;
471458 }
472459
@@ -503,7 +490,7 @@ namespace lp {
503490
504491 }
505492 // j is the index of the column representing a term
506- // return true if a new tighter bound was set on j
493+ // return true if a conflict was found
507494 bool tighten_bounds_for_term_column (unsigned j) {
508495 term_o term_to_tighten = lra.get_term (j); // copy the term aside
509496 std::queue<unsigned > q;
@@ -534,18 +521,15 @@ namespace lp {
534521 TRACE (" dioph_eq" , tout << " after process_q_with_S\n t:" ; print_term_o (create_term_from_ind_c (), tout) << std::endl;
535522 tout << " g:" << g << std::endl; /* tout << "dep:"; print_dep(tout, m_tmp_l) << std::endl;*/ );
536523
537- if (g.is_one ()) {
538- TRACE (" dioph_eq" , tout << " g is one" << std::endl;);
539- return false ;
540- } else if (g.is_zero ()) {
524+ if (g.is_one ()) return false ;
525+ if (g.is_zero ()) {
541526 handle_constant_term (j);
542- if (!m_infeas_explanation.empty ())
543- return true ;
544- return false ;
527+ return !m_infeas_explanation.empty ();
545528 }
546529 // g is not trivial, trying to tighten the bounds
547- // by using bitwise to explore both bounds
548- return tighten_bounds_for_term (g, j, true ) | tighten_bounds_for_term (g, j, false );
530+ return tighten_bounds_for_non_trivial_gcd (g, j, true )
531+ ||
532+ tighten_bounds_for_non_trivial_gcd (g, j, false );
549533 }
550534
551535 void get_expl_from_meta_term (const lar_term& t, explanation& ex) {
@@ -586,7 +570,8 @@ namespace lp {
586570 // m_indexed_work_vector contains the coefficients of the term
587571 // m_c contains the constant term
588572 // m_tmp_l is the linear combination of the equations that removs the substituted variablse
589- bool tighten_bounds_for_term (const mpq& g, unsigned j, bool is_upper) {
573+ // returns true iff the conflict is found
574+ bool tighten_bounds_for_non_trivial_gcd (const mpq& g, unsigned j, bool is_upper) {
590575 mpq rs;
591576 bool is_strict;
592577 u_dependency *b_dep = nullptr ;
@@ -597,14 +582,14 @@ namespace lp {
597582 rs = (rs - m_c) / g;
598583 TRACE (" dioph_eq" , tout << " (rs - m_c) / g:" << rs << std::endl;);
599584 if (!rs.is_int ()) {
600- tighten_bound_for_term_for_bound_kind ( g, j, rs, is_upper, b_dep);
601- return true ;
585+ if ( tighten_bound_kind ( g, j, rs, is_upper, b_dep))
586+ return true ;
602587 }
603588 }
604589 return false ;
605590 }
606591
607- void tighten_bound_for_term_for_bound_kind ( const mpq& g, unsigned j, const mpq & ub, bool upper, u_dependency* prev_dep) {
592+ bool tighten_bound_kind ( const mpq& g, unsigned j, const mpq & ub, bool upper, u_dependency* prev_dep) {
608593 // ub = (upper_bound(j) - m_c)/g.
609594 // we have x[j] = t = g*t_+ m_c <= upper_bound(j), then
610595 // t_ <= floor((upper_bound(j) - m_c)/g) = floor(ub)
@@ -627,6 +612,12 @@ namespace lp {
627612 TRACE (" dioph_eq" , tout << " jterm:" ; print_lar_term_L (lra.get_term (j), tout) << " \n dep:" ; print_dep (tout, dep) << std::endl;
628613 );
629614 lra.update_column_type_and_bound (j, kind, bound, dep);
615+ auto st = lra.find_feasible_solution ();
616+ if (st != lp::lp_status::FEASIBLE && st != lp::lp_status::OPTIMAL && st != lp::lp_status::CANCELLED) {
617+ lra.get_infeasibility_explanation (m_infeas_explanation);
618+ return true ;
619+ }
620+ return false ;
630621 }
631622
632623 u_dependency* explain_fixed_in_meta_term (const lar_term& t) {
0 commit comments