3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-27 02:45:51 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-01 03:42:13 -07:00
parent d8e00bc02e
commit cc394f0fe9
5 changed files with 25 additions and 21 deletions

View file

@ -2395,9 +2395,7 @@ bool lar_solver::inside_bounds(lpvar j, const impq& val) const {
bool lar_solver::try_to_patch(lpvar j, const mpq& val, const std::function<bool (lpvar)>& blocker, const std::function<void (lpvar)>& report_change) {
if (is_base(j)) {
bool r = remove_from_basis(j);
SASSERT(r);
(void)r;
VERIFY(remove_from_basis(j));
}
impq ival(val);
if (!inside_bounds(j, ival))
@ -2409,10 +2407,10 @@ bool lar_solver::try_to_patch(lpvar j, const mpq& val, const std::function<bool
const mpq & a = c.coeff();
unsigned rj = m_mpq_lar_core_solver.m_r_basis[row_index];
impq rj_new_val = a * delta + get_column_value(rj);
if (column_is_int(rj) && ! rj_new_val.is_int())
return false;
if (column_is_int(rj) && !rj_new_val.is_int())
return false;
if (!inside_bounds(rj, rj_new_val) || blocker(rj))
return false;
return false;
}
set_column_value(j, ival);
@ -2423,6 +2421,7 @@ bool lar_solver::try_to_patch(lpvar j, const mpq& val, const std::function<bool
m_mpq_lar_core_solver.m_r_solver.add_delta_to_x(rj, a * delta);
report_change(rj);
}
return true;
}

View file

@ -1342,18 +1342,17 @@ bool core::var_is_used_in_a_correct_monic(lpvar j) const {
void core::update_to_refine_of_var(lpvar j) {
for (const monic & m : emons().get_use_list(j)) {
if (val(var(m)) == mul_val(m))
if (var_val(m) == mul_val(m))
m_to_refine.erase(var(m));
else
m_to_refine.insert(var(m));
}
if (is_monic_var(j)) {
const monic& m = emons()[j];
if (val(var(m)) == mul_val(m))
if (var_val(m) == mul_val(m))
m_to_refine.erase(j);
else
m_to_refine.insert(j);
m_to_refine.insert(j);
}
}
@ -1373,15 +1372,15 @@ void core::patch_monomial_with_real_var(lpvar j) {
return;
if (!var_is_int(j) &&
!var_is_used_in_a_correct_monic(j)
&& try_to_patch(j, v)) {
&& try_to_patch(j, v)
) {
m_to_refine.erase(j);
} else {
rational r = val(j) / v;
for (lpvar k: m.vars()) {
if (var_is_int(k)) continue;
if (var_is_used_in_a_correct_monic(k))
continue;
if (try_to_patch(k, r * val(k))) { // r * val(k) gives the right value of k
if (!var_is_int(k) &&
!var_is_used_in_a_correct_monic(k) &&
try_to_patch(k, r * val(k))) { // r * val(k) gives the right value of k
m_to_refine.erase(j);
break;
}
@ -1394,7 +1393,7 @@ void core::patch_monomial_with_real_var(lpvar j) {
void core::patch_monomials_with_real_vars() {
auto to_refine = m_to_refine.index();
// the rest of the function might change m_to_refine, so have to copy
// the rest of the function might change m_to_refine, so have to copy
for (lpvar j : to_refine) {
patch_monomial_with_real_var(j);
}

View file

@ -94,7 +94,7 @@ public:
m_index.resize(0);
}
std::ostream& operator<<(std::ostream& out) const {
std::ostream& display(std::ostream& out) const {
for (unsigned j : m_index) {
out << j << " ";
}
@ -105,4 +105,10 @@ public:
const unsigned * end() const { return m_index.end(); }
const unsigned_vector& index() { return m_index; }
};
}
inline std::ostream& operator<<(std::ostream& out, lp::u_set const& s) {
return s.display(out);
}

View file

@ -160,7 +160,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
family_id fid = f->get_family_id();
bool is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
br_status st = BR_FAILED;
if (num == 0 && (fid == null_family_id || is_uninterp)) { // || m_ar.is_as_array(f)
if (num == 0 && (fid == null_family_id || is_uninterp)) { // || m_ar.is_as_array(f)) {
expr * val = m_model.get_const_interp(f);
if (val != nullptr) {
result = val;
@ -168,7 +168,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
TRACE("model_evaluator", tout << result << "\n";);
return st;
}
else if (m_model_completion) {
else if (m_model_completion && !m_ar.is_as_array(f)) {
sort * s = f->get_range();
expr * val = m_model.get_some_value(s);
m_model.register_decl(f, val);

View file

@ -1561,8 +1561,8 @@ public:
void init_variable_values() {
reset_variable_values();
if (!m.canceled() && m_solver.get() && th.get_num_vars() > 0) {
TRACE("arith", tout << "update variable values\n";);
if (!m.canceled() && m_solver.get() && th.get_num_vars() > 0) {
TRACE("arith", display(tout << "update variable values\n"););
lp().get_model(m_variable_values);
}
}