Skip to content

Commit

Permalink
throttle monomial unit prop and and nl params
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Sep 25, 2023
1 parent 896aba3 commit 6ff4856
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
31 changes: 30 additions & 1 deletion src/math/lp/nla_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,10 @@ void core::add_lower_bound_monic(lpvar j, const lp::mpq& v, bool is_strict, std:
}

void core::propagate_monic_with_non_fixed(lpvar monic_var, const svector<lpvar>& vars, lpvar non_fixed, const rational& k) {
if (params().arith_nl_use_lemmas_in_unit_prop()) {
propagate_monic_non_fixed_with_lemma(monic_var, vars, non_fixed, k);
return;
}
lp::impq bound_value;
bool is_strict;
auto& lps = lra;
Expand Down Expand Up @@ -2002,13 +2006,38 @@ void core::add_lower_bound_monic(lpvar j, const lp::mpq& v, bool is_strict, std:
add_lower_bound_monic(monic_var, lp::mpq(0), false, lambda);
add_upper_bound_monic(monic_var, lp::mpq(0), false, lambda);
}

void core::propagate_monic_non_fixed_with_lemma(lpvar monic_var, const svector<lpvar>& vars, lpvar non_fixed, const rational& k) {
lp::impq bound_value;
new_lemma lemma(*this, "propagate monic with non fixed");
// using += to not assert thath the inequality does not hold
lemma += ineq(term(rational(1), monic_var, -k, non_fixed), llc::EQ, 0);
lp::explanation exp;
for (auto v : m_emons[monic_var].vars()) {
if (v == non_fixed) continue;
u_dependency* dep = lra.get_column_lower_bound_witness(v);
for (auto ci : lra.flatten(dep)) {
exp.push_back(ci);
}
dep = lra.get_column_upper_bound_witness(v);
for (auto ci : lra.flatten(dep)) {
exp.push_back(ci);
}
}
lemma &= exp;
}

void core::calculate_implied_bounds_for_monic(lp::lpvar monic_var) {
m_propagated.reserve(monic_var + 1, false);
bool throttle = params().arith_nl_throttle_unit_prop();
if (throttle && m_propagated[monic_var])
return;
lpvar non_fixed, zero_var;
const auto& vars = m_emons[monic_var].vars();
if (!is_linear(vars, zero_var, non_fixed))
return;

if (throttle)
trail().push(set_bitvector_trail(m_propagated, monic_var));
if (zero_var != null_lpvar)
add_bounds_for_zero_var(monic_var, zero_var);
else {
Expand Down
3 changes: 2 additions & 1 deletion src/math/lp/nla_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class core {
bool m_cautious_patching = true;
lpvar m_patched_var = 0;
monic const* m_patched_monic = nullptr;

bool_vector m_propagated;
void check_weighted(unsigned sz, std::pair<unsigned, std::function<void(void)>>* checks);
void add_bounds();
std_vector<lp::implied_bound> & m_implied_bounds;
Expand Down Expand Up @@ -438,6 +438,7 @@ class core {
bool is_linear(const svector<lpvar>& m, lpvar& zero_var, lpvar& non_fixed);
void add_bounds_for_zero_var(lpvar monic_var, lpvar zero_var);
void propagate_monic_with_non_fixed(lpvar monic_var, const svector<lpvar>& vars, lpvar non_fixed, const rational& k);
void core::propagate_monic_non_fixed_with_lemma(lpvar monic_var, const svector<lpvar>& vars, lpvar non_fixed, const rational& k);
void propagate_monic_with_all_fixed(lpvar monic_var, const svector<lpvar>& vars, const rational& k);
void add_lower_bound_monic(lpvar j, const lp::mpq& v, bool is_strict, std::function<u_dependency*()> explain_dep);
void add_upper_bound_monic(lpvar j, const lp::mpq& v, bool is_strict, std::function<u_dependency*()> explain_dep);
Expand Down
2 changes: 2 additions & 0 deletions src/smt/params/smt_params_helper.pyg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def_module_params(module_name='smt',
('arith.nl.grobner_row_length_limit', UINT, 10, 'row is disregarded by the heuristic if its length is longer than the value'),
('arith.nl.grobner_frequency', UINT, 4, 'grobner\'s call frequency'),
('arith.nl.grobner', BOOL, True, 'run grobner\'s basis heuristic'),
('arith.nl.use_lemmas_in_unit_prop', BOOL, False, 'use lemmas in monomial unit propagation'),
('arith.nl.throttle_unit_prop', BOOL, True, 'unit propogate a monomial only once per scope'),
('arith.nl.grobner_eqs_growth', UINT, 10, 'grobner\'s number of equalities growth '),
('arith.nl.grobner_expr_size_growth', UINT, 2, 'grobner\'s maximum expr size growth'),
('arith.nl.grobner_expr_degree_growth', UINT, 2, 'grobner\'s maximum expr degree growth'),
Expand Down
2 changes: 1 addition & 1 deletion src/smt/theory_lra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ class theory_lra::imp {
svector<enode_pair> m_eqs;
vector<parameter> m_params;

void reset_evidence() {
void reset_evidence() {
m_core.reset();
m_eqs.reset();
m_params.reset();
Expand Down

0 comments on commit 6ff4856

Please sign in to comment.