Skip to content

Commit bee2b45

Browse files
committed
optionally throttle patch_basic_columns() especially useful in unsat cases
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
1 parent f6a1d87 commit bee2b45

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/math/lp/int_solver.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace lp {
4444
dioph_eq m_dio;
4545
int_gcd_test m_gcd;
4646
unsigned m_initial_dio_calls_period;
47+
unsigned m_patch_period = 1;
4748

4849
bool column_is_int_inf(unsigned j) const {
4950
return lra.column_is_int(j) && (!lia.value_is_int(j));
@@ -52,6 +53,7 @@ namespace lp {
5253
imp(int_solver& lia): lia(lia), lra(lia.lra), lrac(lia.lrac), m_hnf_cutter(lia), m_dio(lia), m_gcd(lia) {
5354
m_hnf_cut_period = settings().hnf_cut_period();
5455
m_initial_dio_calls_period = settings().dio_calls_period();
56+
m_patch_period = settings().m_int_patch_period;
5557
}
5658

5759
bool has_lower(unsigned j) const {
@@ -156,6 +158,11 @@ namespace lp {
156158
try_patch_column(v, c.var(), delta_plus);
157159
}
158160

161+
bool should_patch() {
162+
// period == 0 means no throttling (old behavior)
163+
return settings().m_int_patch_period == 0 || m_number_of_calls % m_patch_period == 0;
164+
}
165+
159166
lia_move patch_basic_columns() {
160167
lia.settings().stats().m_patches++;
161168
lra.remove_fixed_vars_from_base();
@@ -165,8 +172,12 @@ namespace lp {
165172
patch_basic_column(j);
166173
if (!lra.has_inf_int()) {
167174
lia.settings().stats().m_patches_success++;
175+
m_patch_period = std::max(1u, settings().m_int_patch_period);
168176
return lia_move::sat;
169177
}
178+
// Only throttle if enabled (period > 0)
179+
if (settings().m_int_patch_period > 0 && m_patch_period < 16)
180+
m_patch_period *= 2;
170181
return lia_move::undef;
171182
}
172183

@@ -244,7 +255,7 @@ namespace lp {
244255
return lia_move::undef;
245256

246257
++m_number_of_calls;
247-
if (r == lia_move::undef) r = patch_basic_columns();
258+
if (r == lia_move::undef && should_patch()) r = patch_basic_columns();
248259
if (r == lia_move::undef && should_find_cube()) r = int_cube(lia)();
249260
if (r == lia_move::undef) lra.move_non_basic_columns_to_bounds();
250261
if (r == lia_move::undef && should_hnf_cut()) r = hnf_cut();

src/math/lp/lp_params_helper.pyg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def_module_params(module_name='lp',
88
('dio_cuts_enable_hnf', BOOL, True, 'enable hnf cuts together with Diophantine cuts, only relevant when dioph_eq is true'),
99
('dio_ignore_big_nums', BOOL, True, 'Ignore the terms with big numbers in the Diophantine handler, only relevant when dioph_eq is true'),
1010
('dio_calls_period', UINT, 1, 'Period of calling the Diophantine handler in the final_check()'),
11-
('dio_run_gcd', BOOL, False, 'Run the GCD heuristic if dio is on, if dio is disabled the option is not used'),
11+
('dio_run_gcd', BOOL, False, 'Run the GCD heuristic if dio is on, if dio is disabled the option is not used'),
12+
('int_patch_period', UINT, 0, 'Period for patching integer columns (0 = no throttling, 1 = throttle adaptively)'),
1213
))
1314

src/math/lp/lp_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ void lp::lp_settings::updt_params(params_ref const& _p) {
4343
m_dio_ignore_big_nums = lp_p.dio_ignore_big_nums();
4444
m_dio_calls_period = lp_p.dio_calls_period();
4545
m_dio_run_gcd = lp_p.dio_run_gcd();
46+
m_int_patch_period = lp_p.int_patch_period();
4647
m_max_conflicts = p.max_conflicts();
4748
}

src/math/lp/lp_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ struct lp_settings {
239239
unsigned column_number_threshold_for_using_lu_in_lar_solver = 4000;
240240
unsigned m_int_gomory_cut_period = 4;
241241
unsigned m_int_find_cube_period = 4;
242+
unsigned m_int_patch_period = 0;
242243
private:
243244
unsigned m_hnf_cut_period = 4;
244245
bool m_int_run_gcd_test = true;

0 commit comments

Comments
 (0)