mirror of
https://github.com/Z3Prover/z3
synced 2026-02-22 00:07:36 +00:00
deal with compiler warnings and include value exchange prior to final check.
This commit is contained in:
parent
ce615ee116
commit
0e8969ce60
15 changed files with 132 additions and 146 deletions
|
|
@ -121,22 +121,14 @@ namespace sls {
|
|||
template<typename num_t>
|
||||
void arith_clausal<num_t>::add_lookahead_on_unsat_vars() {
|
||||
a.m_updates.reset();
|
||||
a.m_fixed_atoms.reset();
|
||||
TRACE("arith_verbose", tout << "unsat-vars ";
|
||||
for (auto v : ctx.unsat_vars())
|
||||
if (a.get_ineq(v)) tout << mk_bounded_pp(ctx.atom(v), a.m) << " ";
|
||||
tout << "\n";);
|
||||
|
||||
for (auto v : ctx.unsat_vars()) {
|
||||
auto* ineq = a.get_ineq(v);
|
||||
if (!ineq)
|
||||
continue;
|
||||
auto e = ctx.atom(v);
|
||||
auto& i = a.get_bool_info(e);
|
||||
auto const& vars = a.get_fixable_exprs(e);
|
||||
for (auto v : vars)
|
||||
a.add_lookahead(i, v);
|
||||
}
|
||||
for (auto v : ctx.unsat_vars())
|
||||
a.add_lookahead(v);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,7 +138,6 @@ namespace sls {
|
|||
template<typename num_t>
|
||||
void arith_clausal<num_t>::add_lookahead_on_false_literals() {
|
||||
a.m_updates.reset();
|
||||
a.m_fixed_atoms.reset();
|
||||
|
||||
unsigned sz = a.m_bool_var_atoms.size();
|
||||
bool is_big = sz > 45u;
|
||||
|
|
@ -164,47 +155,25 @@ namespace sls {
|
|||
};
|
||||
|
||||
unsigned idx = 0;
|
||||
//unsigned num_sampled = 0;
|
||||
for (unsigned i = std::min(sz, 45u); i-- > 0;) {
|
||||
if (is_big) {
|
||||
if (is_big) {
|
||||
for (unsigned i = 45, j = 90; j-- > 0 && i-- > 0 && sz > 0;) {
|
||||
idx = ctx.rand(sz);
|
||||
bv = a.m_bool_var_atoms[idx];
|
||||
}
|
||||
else
|
||||
bv = a.m_bool_var_atoms[i];
|
||||
|
||||
if (occurs_negative(bv)) {
|
||||
auto e = ctx.atom(bv);
|
||||
auto& i = a.get_bool_info(e);
|
||||
a.add_lookahead(i, bv);
|
||||
//++num_sampled;
|
||||
}
|
||||
|
||||
if (is_big) {
|
||||
--sz;
|
||||
a.m_bool_var_atoms.swap_elems(idx, sz);
|
||||
if (occurs_negative(bv))
|
||||
a.add_lookahead(bv);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (auto bv : a.m_bool_var_atoms) {
|
||||
if (ctx.unsat_vars().contains(bv))
|
||||
continue;
|
||||
auto* ineq = a.get_ineq(bv);
|
||||
if (!ineq)
|
||||
continue;
|
||||
sat::literal lit(bv, !ineq->is_true());
|
||||
auto const& ul = ctx.get_use_list(~lit);
|
||||
if (ul.begin() == ul.end())
|
||||
continue;
|
||||
// literal is false in some clause but none of the clauses where it occurs false are unsat.
|
||||
|
||||
auto e = ctx.atom(bv);
|
||||
auto& i = a.get_bool_info(e);
|
||||
|
||||
a.add_lookahead(i, bv);
|
||||
else {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
bv = a.m_bool_var_atoms[i];
|
||||
if (occurs_negative(bv))
|
||||
a.add_lookahead(bv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename num_t>
|
||||
|
|
@ -300,50 +269,38 @@ namespace sls {
|
|||
if (!a.update_num(v, delta))
|
||||
return -1;
|
||||
double score = 0;
|
||||
m_tmp_nat_set.reset();
|
||||
m_tmp_nat_set.assure_domain(ctx.clauses().size() + 1);
|
||||
for (auto bv : vi.m_bool_vars_of) {
|
||||
for (auto lit : { sat::literal(bv, false), sat::literal(bv, true) }) {
|
||||
for (auto ci : ctx.get_use_list(lit)) {
|
||||
if (m_tmp_nat_set.contains(ci)) {
|
||||
continue;
|
||||
}
|
||||
m_tmp_nat_set.insert(ci);
|
||||
|
||||
auto const& c = ctx.get_clause(ci);
|
||||
unsigned num_true = 0;
|
||||
for (auto lit : c) {
|
||||
auto bv = lit.var();
|
||||
auto ineq = a.get_ineq(bv);
|
||||
if (ineq) {
|
||||
if (ineq->is_true() != lit.sign())
|
||||
++num_true;
|
||||
}
|
||||
else if (ctx.is_true(lit))
|
||||
++num_true;
|
||||
}
|
||||
|
||||
CTRACE("arith_verbose", c.m_num_trues != num_true && (c.m_num_trues == 0 || num_true == 0),
|
||||
tout << "clause: " << c
|
||||
<< " v" << v << " += " << delta
|
||||
<< " new-true lits: " << num_true
|
||||
<< " old-true lits: " << c.m_num_trues
|
||||
<< " w: " << c.m_weight << "\n";
|
||||
for (auto lit : c)
|
||||
if (a.get_ineq(lit.var()))
|
||||
tout << lit << " " << *a.get_ineq(lit.var()) << "\n";);
|
||||
if (c.m_num_trues > 0 && num_true == 0)
|
||||
score -= c.m_weight;
|
||||
else if (c.m_num_trues == 0 && num_true > 0)
|
||||
score += c.m_weight;
|
||||
for (auto ci : vi.m_clauses_of) {
|
||||
auto const& c = ctx.get_clause(ci);
|
||||
unsigned num_true = 0;
|
||||
for (auto lit : c) {
|
||||
auto bv = lit.var();
|
||||
auto ineq = a.get_ineq(bv);
|
||||
if (ineq) {
|
||||
if (ineq->is_true() != lit.sign())
|
||||
++num_true;
|
||||
}
|
||||
else if (ctx.is_true(lit))
|
||||
++num_true;
|
||||
}
|
||||
|
||||
|
||||
CTRACE("arith_verbose", c.m_num_trues != num_true && (c.m_num_trues == 0 || num_true == 0),
|
||||
tout << "clause: " << c
|
||||
<< " v" << v << " += " << delta
|
||||
<< " new-true lits: " << num_true
|
||||
<< " old-true lits: " << c.m_num_trues
|
||||
<< " w: " << c.m_weight << "\n";
|
||||
for (auto lit : c)
|
||||
if (a.get_ineq(lit.var()))
|
||||
tout << lit << " " << *a.get_ineq(lit.var()) << "\n";);
|
||||
if (c.m_num_trues > 0 && num_true == 0)
|
||||
score -= c.m_weight;
|
||||
else if (c.m_num_trues == 0 && num_true > 0)
|
||||
score += c.m_weight;
|
||||
}
|
||||
|
||||
// verbose_stream() << num_clauses << " " << num_dup << "\n";
|
||||
// revert the update
|
||||
a.update_args_value(v, vi.value() - delta);
|
||||
|
||||
a.update_args_value(v, vi.value() - delta);
|
||||
return score;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue