Skip to content

Commit

Permalink
add hook for in-processing simplification for NLA
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Oct 25, 2023
1 parent 6ba1515 commit e2db2b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
29 changes: 4 additions & 25 deletions src/math/lp/nla_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,9 +1556,6 @@ lbool core::check() {

if (no_effect())
m_monomial_bounds.propagate();

if (no_effect() && improve_bounds())
return l_false;

{
std::function<void(void)> check1 = [&]() { if (no_effect() && run_horner) m_horner.horner_lemmas(); };
Expand Down Expand Up @@ -1793,35 +1790,17 @@ void core::set_use_nra_model(bool m) {

void core::collect_statistics(::statistics & st) {
}

bool core::improve_bounds() {
return false;

uint_set seen;
bool bounds_improved = false;
auto insert = [&](lpvar v) {
if (seen.contains(v))
return;
seen.insert(v);
if (lra.improve_bound(v, false))
bounds_improved = true, lp_settings().stats().m_nla_bounds_improvements++;
if (lra.improve_bound(v, true))
bounds_improved = true, lp_settings().stats().m_nla_bounds_improvements++;
};
for (auto & m : m_emons) {
insert(m.var());
for (auto v : m.vars())
insert(v);
}
return bounds_improved;
}

void core::propagate() {
clear();
m_monomial_bounds.unit_propagate();
m_monics_with_changed_bounds.reset();
}

void core::simplify() {
// in-processing simplifiation can go here, such as bounds improvements.
}



} // end of nla
Expand Down
4 changes: 2 additions & 2 deletions src/math/lp/nla_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ class core {

void check_weighted(unsigned sz, std::pair<unsigned, std::function<void(void)>>* checks);
void add_bounds();
// try to improve bounds for variables in monomials.
bool improve_bounds();

public:
// constructor
Expand Down Expand Up @@ -386,6 +384,8 @@ class core {
bool no_lemmas_hold() const;

void propagate();

void simplify();

lbool test_check();
lpvar map_to_root(lpvar) const;
Expand Down
1 change: 1 addition & 0 deletions src/math/lp/nla_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace nla {
bool need_check();
lbool check();
void propagate();
void simplify() { m_core->simplify(); }
lbool check_power(lpvar r, lpvar x, lpvar y);
bool is_monic_var(lpvar) const;
bool influences_nl_var(lpvar) const;
Expand Down
2 changes: 2 additions & 0 deletions src/smt/theory_lra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ class theory_lra::imp {

void restart_eh() {
m_arith_eq_adapter.restart_eh();
if (m_nla)
m_nla->simplify();
}

void relevant_eh(app* n) {
Expand Down

0 comments on commit e2db2b8

Please sign in to comment.