3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-23 06:13:40 +00:00

move to scoped intervals for memory management

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-03-13 15:12:46 -07:00 committed by Lev Nachmanson
parent 79fefe5fb3
commit a7158772ad
3 changed files with 21 additions and 19 deletions

View file

@ -31,35 +31,33 @@ class pdd_interval {
public: public:
pdd_interval(reslimit& lim): m_dep_intervals(lim) {} pdd_interval(reslimit& lim): m_dep_intervals(lim) {}
dep_intervals& m() { return m_dep_intervals; }
std::function<interval (unsigned, bool)>& var2interval() { return m_var2interval; } // setter std::function<interval (unsigned, bool)>& var2interval() { return m_var2interval; } // setter
const std::function<interval (unsigned, bool)>& var2interval() const { return m_var2interval; } // getter const std::function<interval (unsigned, bool)>& var2interval() const { return m_var2interval; } // getter
template <w_dep wd> template <w_dep wd>
interval get_interval(pdd const& p) { void get_interval(pdd const& p, scoped_dep_interval& ret) {
interval k;
if (p.is_val()) { if (p.is_val()) {
m_dep_intervals.set_interval_for_scalar(k, p.val()); m_dep_intervals.set_interval_for_scalar(ret.get(), p.val());
return k; return;
} }
bool deps = wd == w_dep::with_deps; bool deps = wd == w_dep::with_deps;
interval a = m_var2interval(p.var(), deps); interval a = m_var2interval(p.var(), deps);
interval hi = get_interval<wd>(p.hi()); scoped_dep_interval hi(m()), lo(m()), t(m());
interval la = get_interval<wd>(p.lo()); get_interval<wd>(p.hi(), hi);
interval t; get_interval<wd>(p.lo(), lo);
interval ret;
if (deps) { if (deps) {
interval_deps_combine_rule combine_rule; interval_deps_combine_rule combine_rule;
m_dep_intervals.mul(hi, a, t, combine_rule); m_dep_intervals.mul(hi, a, t, combine_rule);
m_dep_intervals.combine_deps(hi, a, combine_rule, t); m_dep_intervals.combine_deps(hi, a, combine_rule, t);
combine_rule.reset(); combine_rule.reset();
m_dep_intervals.add(t, la, ret, combine_rule); m_dep_intervals.add(t, lo, ret, combine_rule);
m_dep_intervals.combine_deps(t, la, combine_rule, ret); m_dep_intervals.combine_deps(t, lo, combine_rule, ret);
return ret;
} else { } else {
m_dep_intervals.mul(hi, a, t); m_dep_intervals.mul(hi, a, t);
m_dep_intervals.add(t, la, ret); m_dep_intervals.add(t, lo, ret);
return ret;
} }
} }
// f meant to be called when the separation happens // f meant to be called when the separation happens

View file

@ -296,6 +296,8 @@ public:
} }
void reset() { m_dep_manager.reset(); } void reset() { m_dep_manager.reset(); }
void del(interval& i) { m_imanager.del(i); }
template <enum with_deps_t wd> interval intersect(const interval& a, const interval& b) const { template <enum with_deps_t wd> interval intersect(const interval& a, const interval& b) const {
interval i; interval i;
@ -363,3 +365,5 @@ public:
copy_upper_bound<wd>(b, i); copy_upper_bound<wd>(b, i);
} }
}; };
typedef _scoped_interval<dep_intervals> scoped_dep_interval;

View file

@ -1494,16 +1494,16 @@ bool core::check_pdd_eq(const dd::solver::equation* e) {
else m_intervals.set_var_interval<dd::w_dep::without_deps>(j, a); else m_intervals.set_var_interval<dd::w_dep::without_deps>(j, a);
return a; return a;
}; };
auto i = eval.get_interval<dd::w_dep::without_deps>(e->poly()); scoped_dep_interval i(eval.m()), i_wd(eval.m());
dep_intervals di(m_reslim); eval.get_interval<dd::w_dep::without_deps>(e->poly(), i);
if (!di.separated_from_zero(i)) if (!eval.m().separated_from_zero(i))
return false; return false;
auto i_wd = eval.get_interval<dd::w_dep::with_deps>(e->poly()); eval.get_interval<dd::w_dep::with_deps>(e->poly(), i_wd);
std::function<void (const lp::explanation&)> f = [this](const lp::explanation& e) { std::function<void (const lp::explanation&)> f = [this](const lp::explanation& e) {
add_empty_lemma(); add_empty_lemma();
current_expl().add(e); current_expl().add(e);
}; };
if (di.check_interval_for_conflict_on_zero(i_wd, e->dep(), f)) { if (eval.m().check_interval_for_conflict_on_zero(i_wd, e->dep(), f)) {
lp_settings().stats().m_grobner_conflicts++; lp_settings().stats().m_grobner_conflicts++;
return true; return true;
} }