3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-25 21:57:00 +00:00

separate linear update

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2024-08-24 18:13:16 -07:00
parent ebbcfafd81
commit ab66239c11
2 changed files with 28 additions and 16 deletions

View file

@ -533,16 +533,33 @@ namespace sls {
return false; return false;
} }
template<typename num_t>
bool arith_base<num_t>::find_lin_moves(sat::literal lit) {
m_updates.reset();
auto* ineq = atom(lit.var());
num_t a, b;
if (!ineq)
return false;
if (!ineq->m_is_linear) {
for (auto const& [coeff, x] : ineq->m_args) {
if (is_fixed(x))
continue;
find_linear_moves(*ineq, x, coeff, ineq->m_args_value);
}
}
return apply_update();
}
template<typename num_t> template<typename num_t>
bool arith_base<num_t>::repair(sat::literal lit) { bool arith_base<num_t>::repair(sat::literal lit) {
//verbose_stream() << "repair " << lit << " " << (ctx.is_unit(lit)?"unit":"") << "\n"; //verbose_stream() << "repair " << lit << " " << (ctx.is_unit(lit)?"unit":"") << "\n";
if (ctx.rand(20) != 0) { m_last_literal = lit;
m_last_literal = lit; if (ctx.rand(20) != 0 && find_nl_moves(lit))
find_moves(lit); return true;
if (apply_update())
return true; if (find_lin_moves(lit))
} return true;
flet<bool> _tabu(m_use_tabu, false); flet<bool> _tabu(m_use_tabu, false);
@ -1741,12 +1758,12 @@ namespace sls {
} }
template<typename num_t> template<typename num_t>
void arith_base<num_t>::find_moves(sat::literal lit) { bool arith_base<num_t>::find_nl_moves(sat::literal lit) {
m_updates.reset(); m_updates.reset();
auto* ineq = atom(lit.var()); auto* ineq = atom(lit.var());
num_t a, b; num_t a, b;
if (!ineq) if (!ineq)
return; return false;
for (auto const& [x, nl] : ineq->m_nonlinear) { for (auto const& [x, nl] : ineq->m_nonlinear) {
if (is_fixed(x)) if (is_fixed(x))
continue; continue;
@ -1757,13 +1774,7 @@ namespace sls {
else else
; ;
} }
if (false && !ineq->m_is_linear) { return apply_update();
for (auto const& [coeff, x] : ineq->m_args) {
if (is_fixed(x))
continue;
find_linear_moves(*ineq, x, coeff, ineq->m_args_value);
}
}
} }
template<typename num_t> template<typename num_t>

View file

@ -217,7 +217,8 @@ namespace sls {
bool update(var_t v, num_t const& new_value); bool update(var_t v, num_t const& new_value);
bool apply_update(); bool apply_update();
void find_moves(sat::literal lit); bool find_nl_moves(sat::literal lit);
bool find_lin_moves(sat::literal lit);
void find_reset_moves(sat::literal lit); void find_reset_moves(sat::literal lit);
void add_reset_update(var_t v); void add_reset_update(var_t v);
void find_linear_moves(ineq const& i, var_t x, num_t const& coeff, num_t const& sum); void find_linear_moves(ineq const& i, var_t x, num_t const& coeff, num_t const& sum);