Skip to content

Commit 63980f3

Browse files
committed
fixes in dio branching
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
1 parent 6bc7662 commit 63980f3

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/math/lp/dioph_eq.cpp

+25-18
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,10 @@ namespace lp {
892892
TRACE("dio_br",
893893
tout << "fixed j:" << j <<", was substited by "; print_entry(m_k2s[j], tout););
894894
if (check_fixing(j) == lia_move::conflict) {
895-
m_conflict_index = m_k2s[j];
895+
auto& ep = m_entries[m_k2s[j]];
896+
for (auto ci : lra.flatten(explain_fixed_in_meta_term(ep.m_l))) {
897+
m_explanation_of_branches.push_back(ci);
898+
}
896899
return lia_move::conflict;
897900
}
898901
}
@@ -917,15 +920,18 @@ namespace lp {
917920
return true;
918921
}
919922

920-
lia_move add_var_bound_for_branch(const branch* b) {
921-
if (b->m_left) {
922-
lra.add_var_bound(b->m_j, lconstraint_kind::LE, b->m_rs);
923-
} else {
924-
lra.add_var_bound(b->m_j, lconstraint_kind::GE, b->m_rs + mpq(1));
925-
}
926-
if (lra.column_is_fixed(b->m_j)) {
927-
if (fix_var(lar_solver_to_local(b->m_j)) == lia_move::conflict)
923+
lia_move add_var_bound_for_branch(const branch& b) {
924+
if (b.m_left) {
925+
lra.add_var_bound(b.m_j, lconstraint_kind::LE, b.m_rs);
926+
} else {
927+
lra.add_var_bound(b.m_j, lconstraint_kind::GE, b.m_rs + mpq(1));
928+
}
929+
TRACE("dio_br", lra.print_column_info(b.m_j, tout) <<"add bound" << std::endl;);
930+
if (lra.column_is_fixed(b.m_j)) {
931+
if (fix_var(lar_solver_to_local(b.m_j)) == lia_move::conflict) {
932+
TRACE("dio_br", tout << "conflict in fix_var" << std::endl;) ;
928933
return lia_move::conflict;
934+
}
929935
}
930936
return lia_move::undef;
931937
}
@@ -955,7 +961,6 @@ namespace lp {
955961

956962
lia_move branching_on_undef() {
957963
m_explanation_of_branches.clear();
958-
branch* b;
959964
bool need_create_branch = true;
960965
m_number_of_iterations = 0;
961966
while (++m_number_of_iterations < m_max_number_of_iterations) {
@@ -967,25 +972,23 @@ namespace lp {
967972
return lia_move::sat;
968973
}
969974
need_create_branch = false;
970-
b = &m_branch_stack.back();
971975
}
972976
lra_push(); // exploring a new branch
973977

974-
if (add_var_bound_for_branch(b) == lia_move::conflict) {
975-
collect_evidence();
978+
if (add_var_bound_for_branch(m_branch_stack.back()) == lia_move::conflict) {
976979
undo_explored_branches();
977980
if (m_branch_stack.size() == 0) {
978981
lra.stats().m_dio_branching_infeasibles++;
979982
transfer_explanations_from_closed_branches();
980983
return lia_move::conflict;
981984
}
982-
TRACE("dio_br", tout << lp_status_to_string(lra.get_status()) << std::endl;
983-
tout << "explanation:\n"; lra.print_expl(tout, m_infeas_explanation););
984985
need_create_branch = false;
985986
m_branch_stack.back().flip();
987+
lra_pop();
986988
continue;
987989
}
988990
auto st = lra.find_feasible_solution();
991+
TRACE("dio_br", tout << "st:" << lp_status_to_string(st) << std::endl;);
989992
if ((int)st >= (int)(lp_status::FEASIBLE)) {
990993
// have a feasible solution
991994
unsigned n_of_ii = get_number_of_int_inf();
@@ -996,7 +999,7 @@ namespace lp {
996999
return lia_move::sat;
9971000
}
9981001
// got to create a new branch
999-
update_branch_stats(*b, n_of_ii);
1002+
update_branch_stats(m_branch_stack.back(), n_of_ii);
10001003
need_create_branch = true;
10011004
} else {
10021005
if (st == lp_status::CANCELLED) return lia_move::undef;
@@ -1089,15 +1092,19 @@ namespace lp {
10891092

10901093
public:
10911094
lia_move check() {
1095+
++glb;
1096+
TRACE("dioph_eq", tout << "glb:" << glb << std::endl; );
10921097
lra.stats().m_dio_calls++;
10931098
init();
10941099
lia_move ret = process_f_and_tighten_terms();
10951100
if (ret == lia_move::branch || ret == lia_move::conflict)
10961101
return ret;
10971102
SASSERT(ret == lia_move::undef);
10981103
ret = branching_on_undef();
1099-
if (ret == lia_move::sat || ret == lia_move::conflict)
1100-
return ret;
1104+
if (ret == lia_move::sat || ret == lia_move::conflict) {
1105+
SASSERT(lra.settings().get_cancel_flag() == false);
1106+
return ret;
1107+
}
11011108
SASSERT(ret == lia_move::undef);
11021109
return lia_move::undef;
11031110
}

0 commit comments

Comments
 (0)