3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +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:
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
const std::function<interval (unsigned, bool)>& var2interval() const { return m_var2interval; } // getter
template <w_dep wd>
interval get_interval(pdd const& p) {
interval k;
void get_interval(pdd const& p, scoped_dep_interval& ret) {
if (p.is_val()) {
m_dep_intervals.set_interval_for_scalar(k, p.val());
return k;
m_dep_intervals.set_interval_for_scalar(ret.get(), p.val());
return;
}
bool deps = wd == w_dep::with_deps;
interval a = m_var2interval(p.var(), deps);
interval hi = get_interval<wd>(p.hi());
interval la = get_interval<wd>(p.lo());
interval t;
interval ret;
scoped_dep_interval hi(m()), lo(m()), t(m());
get_interval<wd>(p.hi(), hi);
get_interval<wd>(p.lo(), lo);
if (deps) {
interval_deps_combine_rule combine_rule;
m_dep_intervals.mul(hi, a, t, combine_rule);
m_dep_intervals.combine_deps(hi, a, combine_rule, t);
combine_rule.reset();
m_dep_intervals.add(t, la, ret, combine_rule);
m_dep_intervals.combine_deps(t, la, combine_rule, ret);
return ret;
m_dep_intervals.add(t, lo, ret, combine_rule);
m_dep_intervals.combine_deps(t, lo, combine_rule, ret);
} else {
m_dep_intervals.mul(hi, a, t);
m_dep_intervals.add(t, la, ret);
return ret;
m_dep_intervals.add(t, lo, ret);
}
}
// f meant to be called when the separation happens

View file

@ -296,6 +296,8 @@ public:
}
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 {
interval i;
@ -363,3 +365,5 @@ public:
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);
return a;
};
auto i = eval.get_interval<dd::w_dep::without_deps>(e->poly());
dep_intervals di(m_reslim);
if (!di.separated_from_zero(i))
scoped_dep_interval i(eval.m()), i_wd(eval.m());
eval.get_interval<dd::w_dep::without_deps>(e->poly(), i);
if (!eval.m().separated_from_zero(i))
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) {
add_empty_lemma();
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++;
return true;
}