3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-30 12:25:51 +00:00

fixes to new solver, add mode for using nlsat solver eagerly from nla_core

This commit is contained in:
Nikolaj Bjorner 2021-03-14 13:57:04 -07:00
parent 9a975a4523
commit 8412ecbdbf
22 changed files with 156 additions and 164 deletions

View file

@ -37,7 +37,9 @@ core::core(lp::lar_solver& s, reslimit & lim) :
m_reslim(lim),
m_use_nra_model(false),
m_nra(s, lim, *this)
{}
{
m_nlsat_delay = lp_settings().nlsat_delay();
}
bool core::compare_holds(const rational& ls, llc cmp, const rational& rs) const {
switch(cmp) {
@ -1507,11 +1509,15 @@ lbool core::check(vector<lemma>& l_vec) {
run_grobner();
if (l_vec.empty() && !done())
m_basics.basic_lemma(true);
m_basics.basic_lemma(true);
if (l_vec.empty() && !done())
m_basics.basic_lemma(false);
if (!conflict_found() && !done() && should_run_bounded_nlsat())
ret = bounded_nlsat();
if (l_vec.empty() && !done()) {
std::function<void(void)> check1 = [&]() { m_order.order_lemma(); };
std::function<void(void)> check2 = [&]() { m_monotone.monotonicity_lemma(); };
@ -1523,15 +1529,9 @@ lbool core::check(vector<lemma>& l_vec) {
{ 1, check3 }};
check_weighted(3, checks);
if (!conflict_found() && m_nla_settings.run_nra() && random() % 50 == 0 &&
if (!conflict_found() && m_nla_settings.run_nra() && should_run_bounded_nlsat() &&
lp_settings().stats().m_nla_calls > 500) {
params_ref p;
p.set_uint("max_conflicts", 100);
m_nra.updt_params(p);
ret = m_nra.check();
p.set_uint("max_conflicts", UINT_MAX);
m_nra.updt_params(p);
m_stats.m_nra_calls++;
ret = bounded_nlsat();
}
}
@ -1554,6 +1554,30 @@ lbool core::check(vector<lemma>& l_vec) {
return ret;
}
bool core::should_run_bounded_nlsat() {
if (m_nlsat_delay > m_nlsat_fails)
++m_nlsat_fails;
return m_nlsat_delay <= m_nlsat_fails;
}
lbool core::bounded_nlsat() {
params_ref p;
p.set_uint("max_conflicts", 100);
scoped_rlimit sr(m_reslim, 100000);
m_nra.updt_params(p);
lbool ret = m_nra.check();
p.set_uint("max_conflicts", UINT_MAX);
m_nra.updt_params(p);
m_stats.m_nra_calls++;
if (ret == l_undef)
++m_nlsat_delay;
else {
m_nlsat_fails = 0;
m_nlsat_delay /= 2;
}
return ret;
}
bool core::no_lemmas_hold() const {
for (auto & l : * m_lemma_vec) {
if (lemma_holds(l)) {