mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
fixes in dio branching
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
6bc7662580
commit
63980f3bfd
|
@ -892,7 +892,10 @@ namespace lp {
|
||||||
TRACE("dio_br",
|
TRACE("dio_br",
|
||||||
tout << "fixed j:" << j <<", was substited by "; print_entry(m_k2s[j], tout););
|
tout << "fixed j:" << j <<", was substited by "; print_entry(m_k2s[j], tout););
|
||||||
if (check_fixing(j) == lia_move::conflict) {
|
if (check_fixing(j) == lia_move::conflict) {
|
||||||
m_conflict_index = m_k2s[j];
|
auto& ep = m_entries[m_k2s[j]];
|
||||||
|
for (auto ci : lra.flatten(explain_fixed_in_meta_term(ep.m_l))) {
|
||||||
|
m_explanation_of_branches.push_back(ci);
|
||||||
|
}
|
||||||
return lia_move::conflict;
|
return lia_move::conflict;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -917,15 +920,18 @@ namespace lp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lia_move add_var_bound_for_branch(const branch* b) {
|
lia_move add_var_bound_for_branch(const branch& b) {
|
||||||
if (b->m_left) {
|
if (b.m_left) {
|
||||||
lra.add_var_bound(b->m_j, lconstraint_kind::LE, b->m_rs);
|
lra.add_var_bound(b.m_j, lconstraint_kind::LE, b.m_rs);
|
||||||
} else {
|
} else {
|
||||||
lra.add_var_bound(b->m_j, lconstraint_kind::GE, b->m_rs + mpq(1));
|
lra.add_var_bound(b.m_j, lconstraint_kind::GE, b.m_rs + mpq(1));
|
||||||
}
|
}
|
||||||
if (lra.column_is_fixed(b->m_j)) {
|
TRACE("dio_br", lra.print_column_info(b.m_j, tout) <<"add bound" << std::endl;);
|
||||||
if (fix_var(lar_solver_to_local(b->m_j)) == lia_move::conflict)
|
if (lra.column_is_fixed(b.m_j)) {
|
||||||
|
if (fix_var(lar_solver_to_local(b.m_j)) == lia_move::conflict) {
|
||||||
|
TRACE("dio_br", tout << "conflict in fix_var" << std::endl;) ;
|
||||||
return lia_move::conflict;
|
return lia_move::conflict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lia_move::undef;
|
return lia_move::undef;
|
||||||
}
|
}
|
||||||
|
@ -955,7 +961,6 @@ namespace lp {
|
||||||
|
|
||||||
lia_move branching_on_undef() {
|
lia_move branching_on_undef() {
|
||||||
m_explanation_of_branches.clear();
|
m_explanation_of_branches.clear();
|
||||||
branch* b;
|
|
||||||
bool need_create_branch = true;
|
bool need_create_branch = true;
|
||||||
m_number_of_iterations = 0;
|
m_number_of_iterations = 0;
|
||||||
while (++m_number_of_iterations < m_max_number_of_iterations) {
|
while (++m_number_of_iterations < m_max_number_of_iterations) {
|
||||||
|
@ -967,25 +972,23 @@ namespace lp {
|
||||||
return lia_move::sat;
|
return lia_move::sat;
|
||||||
}
|
}
|
||||||
need_create_branch = false;
|
need_create_branch = false;
|
||||||
b = &m_branch_stack.back();
|
|
||||||
}
|
}
|
||||||
lra_push(); // exploring a new branch
|
lra_push(); // exploring a new branch
|
||||||
|
|
||||||
if (add_var_bound_for_branch(b) == lia_move::conflict) {
|
if (add_var_bound_for_branch(m_branch_stack.back()) == lia_move::conflict) {
|
||||||
collect_evidence();
|
|
||||||
undo_explored_branches();
|
undo_explored_branches();
|
||||||
if (m_branch_stack.size() == 0) {
|
if (m_branch_stack.size() == 0) {
|
||||||
lra.stats().m_dio_branching_infeasibles++;
|
lra.stats().m_dio_branching_infeasibles++;
|
||||||
transfer_explanations_from_closed_branches();
|
transfer_explanations_from_closed_branches();
|
||||||
return lia_move::conflict;
|
return lia_move::conflict;
|
||||||
}
|
}
|
||||||
TRACE("dio_br", tout << lp_status_to_string(lra.get_status()) << std::endl;
|
|
||||||
tout << "explanation:\n"; lra.print_expl(tout, m_infeas_explanation););
|
|
||||||
need_create_branch = false;
|
need_create_branch = false;
|
||||||
m_branch_stack.back().flip();
|
m_branch_stack.back().flip();
|
||||||
|
lra_pop();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto st = lra.find_feasible_solution();
|
auto st = lra.find_feasible_solution();
|
||||||
|
TRACE("dio_br", tout << "st:" << lp_status_to_string(st) << std::endl;);
|
||||||
if ((int)st >= (int)(lp_status::FEASIBLE)) {
|
if ((int)st >= (int)(lp_status::FEASIBLE)) {
|
||||||
// have a feasible solution
|
// have a feasible solution
|
||||||
unsigned n_of_ii = get_number_of_int_inf();
|
unsigned n_of_ii = get_number_of_int_inf();
|
||||||
|
@ -996,7 +999,7 @@ namespace lp {
|
||||||
return lia_move::sat;
|
return lia_move::sat;
|
||||||
}
|
}
|
||||||
// got to create a new branch
|
// got to create a new branch
|
||||||
update_branch_stats(*b, n_of_ii);
|
update_branch_stats(m_branch_stack.back(), n_of_ii);
|
||||||
need_create_branch = true;
|
need_create_branch = true;
|
||||||
} else {
|
} else {
|
||||||
if (st == lp_status::CANCELLED) return lia_move::undef;
|
if (st == lp_status::CANCELLED) return lia_move::undef;
|
||||||
|
@ -1089,6 +1092,8 @@ namespace lp {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lia_move check() {
|
lia_move check() {
|
||||||
|
++glb;
|
||||||
|
TRACE("dioph_eq", tout << "glb:" << glb << std::endl; );
|
||||||
lra.stats().m_dio_calls++;
|
lra.stats().m_dio_calls++;
|
||||||
init();
|
init();
|
||||||
lia_move ret = process_f_and_tighten_terms();
|
lia_move ret = process_f_and_tighten_terms();
|
||||||
|
@ -1096,8 +1101,10 @@ namespace lp {
|
||||||
return ret;
|
return ret;
|
||||||
SASSERT(ret == lia_move::undef);
|
SASSERT(ret == lia_move::undef);
|
||||||
ret = branching_on_undef();
|
ret = branching_on_undef();
|
||||||
if (ret == lia_move::sat || ret == lia_move::conflict)
|
if (ret == lia_move::sat || ret == lia_move::conflict) {
|
||||||
return ret;
|
SASSERT(lra.settings().get_cancel_flag() == false);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
SASSERT(ret == lia_move::undef);
|
SASSERT(ret == lia_move::undef);
|
||||||
return lia_move::undef;
|
return lia_move::undef;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue