mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 14:13:23 +00:00
on #4702
Add weighting function to cycle more fairly through nla solvers.
Handles anomaly from 5361721/pero.txt
This commit is contained in:
parent
2679ae517b
commit
8546cf97d7
2 changed files with 38 additions and 7 deletions
|
@ -10,6 +10,7 @@ Author:
|
||||||
Nikolaj Bjorner (nbjorner)
|
Nikolaj Bjorner (nbjorner)
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
|
#include "util/uint_set.h"
|
||||||
#include "math/lp/nla_core.h"
|
#include "math/lp/nla_core.h"
|
||||||
#include "math/lp/factorization_factory_imp.h"
|
#include "math/lp/factorization_factory_imp.h"
|
||||||
#include "math/lp/nex.h"
|
#include "math/lp/nex.h"
|
||||||
|
@ -1452,6 +1453,31 @@ bool core::integrality_holds() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cycle through different end-game solvers weighted by probability.
|
||||||
|
*/
|
||||||
|
void core::check_weighted(unsigned sz, std::pair<unsigned, std::function<void(void)>>* checks) {
|
||||||
|
unsigned bound = 0;
|
||||||
|
for (unsigned i = 0; i < sz; ++i)
|
||||||
|
bound += checks[i].first;
|
||||||
|
uint_set seen;
|
||||||
|
while (bound > 0 && !done() && m_lemma_vec->empty()) {
|
||||||
|
SASSERT(bound > 0);
|
||||||
|
unsigned n = random() % bound;
|
||||||
|
for (unsigned i = 0; i < sz; ++i) {
|
||||||
|
if (seen.contains(i))
|
||||||
|
continue;
|
||||||
|
if (n < checks[i].first) {
|
||||||
|
seen.insert(i);
|
||||||
|
checks[i].second();
|
||||||
|
bound -= n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n -= checks[i].first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
lbool core::check(vector<lemma>& l_vec) {
|
lbool core::check(vector<lemma>& l_vec) {
|
||||||
lp_settings().stats().m_nla_calls++;
|
lp_settings().stats().m_nla_calls++;
|
||||||
|
@ -1487,14 +1513,16 @@ lbool core::check(vector<lemma>& l_vec) {
|
||||||
if (l_vec.empty() && !done())
|
if (l_vec.empty() && !done())
|
||||||
m_basics.basic_lemma(false);
|
m_basics.basic_lemma(false);
|
||||||
|
|
||||||
if (l_vec.empty() && !done())
|
|
||||||
m_order.order_lemma();
|
|
||||||
|
|
||||||
if (l_vec.empty() && !done()) {
|
if (l_vec.empty() && !done()) {
|
||||||
if (!done())
|
std::function<void(void)> check1 = [&]() { m_order.order_lemma(); };
|
||||||
m_monotone.monotonicity_lemma();
|
std::function<void(void)> check2 = [&]() { m_monotone.monotonicity_lemma(); };
|
||||||
if (!done())
|
std::function<void(void)> check3 = [&]() { m_tangents.tangent_lemma(); };
|
||||||
m_tangents.tangent_lemma();
|
|
||||||
|
std::pair<unsigned, std::function<void(void)>> checks[] =
|
||||||
|
{ { 6, check1 },
|
||||||
|
{ 2, check2 },
|
||||||
|
{ 1, check3 }};
|
||||||
|
check_weighted(3, checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l_vec.empty() && !done() && m_nla_settings.run_nra()) {
|
if (l_vec.empty() && !done() && m_nla_settings.run_nra()) {
|
||||||
|
|
|
@ -178,6 +178,9 @@ private:
|
||||||
bool m_cautious_patching;
|
bool m_cautious_patching;
|
||||||
lpvar m_patched_var;
|
lpvar m_patched_var;
|
||||||
monic const* m_patched_monic;
|
monic const* m_patched_monic;
|
||||||
|
|
||||||
|
void check_weighted(unsigned sz, std::pair<unsigned, std::function<void(void)>>* checks);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void insert_to_refine(lpvar j);
|
void insert_to_refine(lpvar j);
|
||||||
void erase_from_to_refine(lpvar j);
|
void erase_from_to_refine(lpvar j);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue