Skip to content

Commit 392c24a

Browse files
committed
throttle dioph equalities
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent 128d5b4 commit 392c24a

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/math/lp/dioph_eq.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ namespace lp {
561561
return lia_move::conflict;
562562
}
563563
rewrite_eqs();
564-
if (m_conflict_index != -1) {
564+
if (m_conflict_index != UINT_MAX) {
565565
lra.settings().stats().m_dio_conflicts++;
566566
return lia_move::conflict;
567567
}
@@ -777,18 +777,19 @@ namespace lp {
777777
unsigned h = -1;
778778
auto it = m_f.begin();
779779
while (it != m_f.end()) {
780-
if (m_e_matrix.m_rows[m_eprime[*it].m_row_index].size() == 0)
780+
if (m_e_matrix.m_rows[m_eprime[*it].m_row_index].size() == 0) {
781781
if (m_eprime[*it].m_c.is_zero()) {
782782
it = m_f.erase(it);
783783
continue;
784784
} else {
785785
m_conflict_index = *it;
786786
return;
787787
}
788+
}
788789
h = *it;
789790
break;
790791
}
791-
if (h == -1) return;
792+
if (h == UINT_MAX) return;
792793
auto& eprime_entry = m_eprime[h];
793794
TRACE("dioph_eq", print_eprime_entry(h, tout););
794795
auto [ahk, k, k_sign] = find_minimal_abs_coeff(eprime_entry.m_row_index);

src/math/lp/int_solver.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ namespace lp {
4141
mpq m_k; // the right side of the cut
4242
hnf_cutter m_hnf_cutter;
4343
unsigned m_hnf_cut_period;
44+
unsigned m_dioph_eq_period;
4445
int_gcd_test m_gcd;
4546

4647
bool column_is_int_inf(unsigned j) const {
4748
return lra.column_is_int(j) && (!lia.value_is_int(j));
4849
}
4950

50-
imp(int_solver& lia): lia(lia), lra(lia.lra), lrac(lia.lrac), m_hnf_cutter(lia), m_gcd(lia) {}
51+
imp(int_solver& lia): lia(lia), lra(lia.lra), lrac(lia.lrac), m_hnf_cutter(lia), m_gcd(lia) {
52+
m_hnf_cut_period = settings().hnf_cut_period();
53+
m_dioph_eq_period = settings().m_dioph_eq_period;
54+
}
5155

5256
bool has_lower(unsigned j) const {
5357
switch (lrac.m_column_types()[j]) {
@@ -170,11 +174,14 @@ namespace lp {
170174

171175
if (r == lia_move::conflict) {
172176
de.explain(*this->m_ex);
177+
m_dioph_eq_period = settings().m_dioph_eq_period;
173178
return lia_move::conflict;
174179
} else if (r == lia_move::branch) {
180+
m_dioph_eq_period = settings().m_dioph_eq_period;
175181
return lia_move::branch;
176182
}
177183

184+
m_dioph_eq_period *= 2; // the overflow is fine, maybe to try again
178185
return lia_move::undef;
179186
}
180187

@@ -190,7 +197,7 @@ namespace lp {
190197
}
191198

192199
bool should_solve_dioph_eq() {
193-
return lia.settings().dio_eqs() && m_number_of_calls % settings().m_dioph_eq_period == 0;
200+
return lia.settings().dio_eqs() && m_number_of_calls % m_dioph_eq_period == 0;
194201
}
195202

196203
bool should_hnf_cut() {

src/math/lp/lp_settings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ struct lp_settings {
219219
unsigned column_number_threshold_for_using_lu_in_lar_solver = 4000;
220220
unsigned m_int_gomory_cut_period = 4;
221221
unsigned m_int_find_cube_period = 4;
222-
unsigned m_dioph_eq_period = 4;
222+
unsigned m_dioph_eq_period = 1;
223223
private:
224224
unsigned m_hnf_cut_period = 4;
225225
bool m_int_run_gcd_test = true;

0 commit comments

Comments
 (0)