diff --git a/src/math/lp/dioph_eq.cpp b/src/math/lp/dioph_eq.cpp index fa98f101d..3667b207d 100644 --- a/src/math/lp/dioph_eq.cpp +++ b/src/math/lp/dioph_eq.cpp @@ -561,7 +561,7 @@ public: return lia_move::conflict; } rewrite_eqs(); - if (m_conflict_index != -1) { + if (m_conflict_index != UINT_MAX) { lra.settings().stats().m_dio_conflicts++; return lia_move::conflict; } @@ -777,7 +777,7 @@ public: unsigned h = -1; auto it = m_f.begin(); while (it != m_f.end()) { - if (m_e_matrix.m_rows[m_eprime[*it].m_row_index].size() == 0) + if (m_e_matrix.m_rows[m_eprime[*it].m_row_index].size() == 0) { if (m_eprime[*it].m_c.is_zero()) { it = m_f.erase(it); continue; @@ -785,10 +785,11 @@ public: m_conflict_index = *it; return; } + } h = *it; break; } - if (h == -1) return; + if (h == UINT_MAX) return; auto& eprime_entry = m_eprime[h]; TRACE("dioph_eq", print_eprime_entry(h, tout);); auto [ahk, k, k_sign] = find_minimal_abs_coeff(eprime_entry.m_row_index); diff --git a/src/math/lp/int_solver.cpp b/src/math/lp/int_solver.cpp index 216ad1026..79526348e 100644 --- a/src/math/lp/int_solver.cpp +++ b/src/math/lp/int_solver.cpp @@ -41,13 +41,17 @@ namespace lp { mpq m_k; // the right side of the cut hnf_cutter m_hnf_cutter; unsigned m_hnf_cut_period; + unsigned m_dioph_eq_period; int_gcd_test m_gcd; bool column_is_int_inf(unsigned j) const { return lra.column_is_int(j) && (!lia.value_is_int(j)); } - imp(int_solver& lia): lia(lia), lra(lia.lra), lrac(lia.lrac), m_hnf_cutter(lia), m_gcd(lia) {} + imp(int_solver& lia): lia(lia), lra(lia.lra), lrac(lia.lrac), m_hnf_cutter(lia), m_gcd(lia) { + m_hnf_cut_period = settings().hnf_cut_period(); + m_dioph_eq_period = settings().m_dioph_eq_period; + } bool has_lower(unsigned j) const { switch (lrac.m_column_types()[j]) { @@ -170,11 +174,14 @@ namespace lp { if (r == lia_move::conflict) { de.explain(*this->m_ex); + m_dioph_eq_period = settings().m_dioph_eq_period; return lia_move::conflict; } else if (r == lia_move::branch) { + m_dioph_eq_period = settings().m_dioph_eq_period; return lia_move::branch; } + m_dioph_eq_period *= 2; // the overflow is fine, maybe to try again return lia_move::undef; } @@ -190,7 +197,7 @@ namespace lp { } bool should_solve_dioph_eq() { - return lia.settings().dio_eqs() && m_number_of_calls % settings().m_dioph_eq_period == 0; + return lia.settings().dio_eqs() && m_number_of_calls % m_dioph_eq_period == 0; } bool should_hnf_cut() { diff --git a/src/math/lp/lp_settings.h b/src/math/lp/lp_settings.h index 5a5dd6cda..0c96d59fd 100644 --- a/src/math/lp/lp_settings.h +++ b/src/math/lp/lp_settings.h @@ -219,7 +219,7 @@ public: unsigned column_number_threshold_for_using_lu_in_lar_solver = 4000; unsigned m_int_gomory_cut_period = 4; unsigned m_int_find_cube_period = 4; - unsigned m_dioph_eq_period = 4; + unsigned m_dioph_eq_period = 1; private: unsigned m_hnf_cut_period = 4; bool m_int_run_gcd_test = true;