From 49a903c8751b491fae68dfbb9a52645694b0e1f8 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Thu, 13 May 2021 17:23:55 -0700 Subject: [PATCH] na Signed-off-by: Nikolaj Bjorner --- src/math/interval/mod_interval.h | 1 + src/math/interval/mod_interval_def.h | 11 +++++++++++ src/math/polysat/fixplex_def.h | 9 ++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/math/interval/mod_interval.h b/src/math/interval/mod_interval.h index a23a7bdb1..fc0f05695 100644 --- a/src/math/interval/mod_interval.h +++ b/src/math/interval/mod_interval.h @@ -61,6 +61,7 @@ public: if (is_free()) return out << "free"; return out << "[" << pp(lo) << ", " << pp(hi) << "["; } + Numeral closest_value(Numeral const& n) const; }; template diff --git a/src/math/interval/mod_interval_def.h b/src/math/interval/mod_interval_def.h index 8062015f2..253dd7390 100644 --- a/src/math/interval/mod_interval_def.h +++ b/src/math/interval/mod_interval_def.h @@ -109,3 +109,14 @@ mod_interval mod_interval::operator&(mod_interval const& other return mod_interval::empty(); return mod_interval(l, h); } + +template +Numeral mod_interval::closest_value(Numeral const& n) const { + if (contains(n)) + return n; + if (is_empty()) + return n; + if (lo - n < n - hi) + return lo; + return hi - 1; +} diff --git a/src/math/polysat/fixplex_def.h b/src/math/polysat/fixplex_def.h index e79e091c1..5bfa79687 100644 --- a/src/math/polysat/fixplex_def.h +++ b/src/math/polysat/fixplex_def.h @@ -157,8 +157,7 @@ namespace polysat { m_var_eqs.reset(); var_t var = row2base(r); m_vars[var].m_is_base = false; - m_vars[var].lo = 0; - m_vars[var].hi = 0; + m_vars[var].set_free(); m_rows[r.id()].m_base = null_var; M.del(r); SASSERT(M.col_begin(var) == M.col_end(var)); @@ -248,8 +247,9 @@ namespace polysat { lbool fixplex::make_var_feasible(var_t x) { if (in_bounds(x)) return l_true; - auto val = value(x); - numeral new_value = (lo(x) - val < val - hi(x)) ? lo(x) : hi(x) - 1; + if (m_vars[x].is_empty()) + return l_false; + numeral new_value = m_vars[x].closest_value(value(x)); numeral b; var_t y = select_pivot_core(x, new_value, b); @@ -418,7 +418,6 @@ namespace polysat { return value - hi(v) - 1; } - /** * The the bounds of variable v. * If the current value of v, value(v), is in bounds, no further updates are made.