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

try reordering before analyzing bounds

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2025-11-24 12:44:22 -10:00 committed by Lev Nachmanson
parent 9529275e2f
commit 4b5fb2607f
2 changed files with 9 additions and 16 deletions

View file

@ -8,7 +8,6 @@ def_module_params('nlsat',
('cell_sample', BOOL, True, "cell sample projection"), ('cell_sample', BOOL, True, "cell sample projection"),
('lazy', UINT, 0, "how lazy the solver is."), ('lazy', UINT, 0, "how lazy the solver is."),
('reorder', BOOL, True, "reorder variables."), ('reorder', BOOL, True, "reorder variables."),
('correct_order', BOOL, True, "apply gc/reordering before collecting branch-and-bound constraints."),
('log_lemmas', BOOL, False, "display lemmas as self-contained SMT formulas"), ('log_lemmas', BOOL, False, "display lemmas as self-contained SMT formulas"),
('log_lemma_smtrat', BOOL, False, "log lemmas to be readable by smtrat"), ('log_lemma_smtrat', BOOL, False, "log lemmas to be readable by smtrat"),
('dump_mathematica', BOOL, False, "display lemmas as matematica"), ('dump_mathematica', BOOL, False, "display lemmas as matematica"),

View file

@ -214,7 +214,6 @@ namespace nlsat {
unsigned m_lazy; // how lazy the solver is: 0 - satisfy all learned clauses, 1 - process only unit and empty learned clauses, 2 - use only conflict clauses for resolving conflicts unsigned m_lazy; // how lazy the solver is: 0 - satisfy all learned clauses, 1 - process only unit and empty learned clauses, 2 - use only conflict clauses for resolving conflicts
bool m_simplify_cores; bool m_simplify_cores;
bool m_reorder; bool m_reorder;
bool m_correct_order;
bool m_randomize; bool m_randomize;
bool m_random_order; bool m_random_order;
unsigned m_random_seed; unsigned m_random_seed;
@ -293,7 +292,6 @@ namespace nlsat {
m_simplify_cores = p.simplify_conflicts(); m_simplify_cores = p.simplify_conflicts();
bool min_cores = p.minimize_conflicts(); bool min_cores = p.minimize_conflicts();
m_reorder = p.reorder(); m_reorder = p.reorder();
m_correct_order = p.correct_order();
m_randomize = p.randomize(); m_randomize = p.randomize();
m_max_conflicts = p.max_conflicts(); m_max_conflicts = p.max_conflicts();
m_random_order = p.shuffle_vars(); m_random_order = p.shuffle_vars();
@ -1901,6 +1899,14 @@ namespace nlsat {
<< " :learned " << m_learned.size() << ")\n"); << " :learned " << m_learned.size() << ")\n");
} }
void try_reorder() {
gc();
if (m_stats.m_restarts % 10)
return;
if (m_reordered)
restore_order();
apply_reorder();
}
lbool search_check() { lbool search_check() {
lbool r = l_undef; lbool r = l_undef;
@ -1912,17 +1918,8 @@ namespace nlsat {
if (r != l_true) if (r != l_true)
break; break;
++m_stats.m_restarts; ++m_stats.m_restarts;
auto reorder_restart = [&]() {
gc();
if (m_stats.m_restarts % 10 == 0) {
if (m_reordered)
restore_order();
apply_reorder();
}
};
if (m_correct_order) try_reorder();
reorder_restart();
vector<std::pair<var, rational>> bounds; vector<std::pair<var, rational>> bounds;
@ -1949,9 +1946,6 @@ namespace nlsat {
if (bounds.empty()) if (bounds.empty())
break; break;
if (!m_correct_order)
reorder_restart();
init_search(); init_search();
IF_VERBOSE(2, verbose_stream() << "(nlsat-b&b :conflicts " << m_stats.m_conflicts IF_VERBOSE(2, verbose_stream() << "(nlsat-b&b :conflicts " << m_stats.m_conflicts
<< " :decisions " << m_stats.m_decisions << " :decisions " << m_stats.m_decisions