mirror of
https://github.com/Z3Prover/z3
synced 2025-06-05 05:41:23 +00:00
na
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
d8e00bc02e
commit
cc394f0fe9
5 changed files with 25 additions and 21 deletions
|
@ -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) {
|
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)) {
|
if (is_base(j)) {
|
||||||
bool r = remove_from_basis(j);
|
VERIFY(remove_from_basis(j));
|
||||||
SASSERT(r);
|
|
||||||
(void)r;
|
|
||||||
}
|
}
|
||||||
impq ival(val);
|
impq ival(val);
|
||||||
if (!inside_bounds(j, ival))
|
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();
|
const mpq & a = c.coeff();
|
||||||
unsigned rj = m_mpq_lar_core_solver.m_r_basis[row_index];
|
unsigned rj = m_mpq_lar_core_solver.m_r_basis[row_index];
|
||||||
impq rj_new_val = a * delta + get_column_value(rj);
|
impq rj_new_val = a * delta + get_column_value(rj);
|
||||||
if (column_is_int(rj) && ! rj_new_val.is_int())
|
if (column_is_int(rj) && !rj_new_val.is_int())
|
||||||
return false;
|
return false;
|
||||||
if (!inside_bounds(rj, rj_new_val) || blocker(rj))
|
if (!inside_bounds(rj, rj_new_val) || blocker(rj))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_column_value(j, ival);
|
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);
|
m_mpq_lar_core_solver.m_r_solver.add_delta_to_x(rj, a * delta);
|
||||||
report_change(rj);
|
report_change(rj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
void core::update_to_refine_of_var(lpvar j) {
|
||||||
for (const monic & m : emons().get_use_list(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));
|
m_to_refine.erase(var(m));
|
||||||
else
|
else
|
||||||
m_to_refine.insert(var(m));
|
m_to_refine.insert(var(m));
|
||||||
}
|
}
|
||||||
if (is_monic_var(j)) {
|
if (is_monic_var(j)) {
|
||||||
const monic& m = emons()[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);
|
m_to_refine.erase(j);
|
||||||
else
|
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;
|
return;
|
||||||
if (!var_is_int(j) &&
|
if (!var_is_int(j) &&
|
||||||
!var_is_used_in_a_correct_monic(j)
|
!var_is_used_in_a_correct_monic(j)
|
||||||
&& try_to_patch(j, v)) {
|
&& try_to_patch(j, v)
|
||||||
|
) {
|
||||||
m_to_refine.erase(j);
|
m_to_refine.erase(j);
|
||||||
} else {
|
} else {
|
||||||
rational r = val(j) / v;
|
rational r = val(j) / v;
|
||||||
for (lpvar k: m.vars()) {
|
for (lpvar k: m.vars()) {
|
||||||
if (var_is_int(k)) continue;
|
if (!var_is_int(k) &&
|
||||||
if (var_is_used_in_a_correct_monic(k))
|
!var_is_used_in_a_correct_monic(k) &&
|
||||||
continue;
|
try_to_patch(k, r * val(k))) { // r * val(k) gives the right value of k
|
||||||
if (try_to_patch(k, r * val(k))) { // r * val(k) gives the right value of k
|
|
||||||
m_to_refine.erase(j);
|
m_to_refine.erase(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1394,7 +1393,7 @@ void core::patch_monomial_with_real_var(lpvar j) {
|
||||||
|
|
||||||
void core::patch_monomials_with_real_vars() {
|
void core::patch_monomials_with_real_vars() {
|
||||||
auto to_refine = m_to_refine.index();
|
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) {
|
for (lpvar j : to_refine) {
|
||||||
patch_monomial_with_real_var(j);
|
patch_monomial_with_real_var(j);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
m_index.resize(0);
|
m_index.resize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out) const {
|
std::ostream& display(std::ostream& out) const {
|
||||||
for (unsigned j : m_index) {
|
for (unsigned j : m_index) {
|
||||||
out << j << " ";
|
out << j << " ";
|
||||||
}
|
}
|
||||||
|
@ -105,4 +105,10 @@ public:
|
||||||
const unsigned * end() const { return m_index.end(); }
|
const unsigned * end() const { return m_index.end(); }
|
||||||
const unsigned_vector& index() { return m_index; }
|
const unsigned_vector& index() { return m_index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, lp::u_set const& s) {
|
||||||
|
return s.display(out);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
family_id fid = f->get_family_id();
|
family_id fid = f->get_family_id();
|
||||||
bool is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
|
bool is_uninterp = fid != null_family_id && m.get_plugin(fid)->is_considered_uninterpreted(f);
|
||||||
br_status st = BR_FAILED;
|
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);
|
expr * val = m_model.get_const_interp(f);
|
||||||
if (val != nullptr) {
|
if (val != nullptr) {
|
||||||
result = val;
|
result = val;
|
||||||
|
@ -168,7 +168,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
||||||
TRACE("model_evaluator", tout << result << "\n";);
|
TRACE("model_evaluator", tout << result << "\n";);
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
else if (m_model_completion) {
|
else if (m_model_completion && !m_ar.is_as_array(f)) {
|
||||||
sort * s = f->get_range();
|
sort * s = f->get_range();
|
||||||
expr * val = m_model.get_some_value(s);
|
expr * val = m_model.get_some_value(s);
|
||||||
m_model.register_decl(f, val);
|
m_model.register_decl(f, val);
|
||||||
|
|
|
@ -1561,8 +1561,8 @@ public:
|
||||||
|
|
||||||
void init_variable_values() {
|
void init_variable_values() {
|
||||||
reset_variable_values();
|
reset_variable_values();
|
||||||
if (!m.canceled() && m_solver.get() && th.get_num_vars() > 0) {
|
if (!m.canceled() && m_solver.get() && th.get_num_vars() > 0) {
|
||||||
TRACE("arith", tout << "update variable values\n";);
|
TRACE("arith", display(tout << "update variable values\n"););
|
||||||
lp().get_model(m_variable_values);
|
lp().get_model(m_variable_values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue