Skip to content

Commit c300843

Browse files
committed
cancel bugs fixes
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
1 parent e4f3b57 commit c300843

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/math/lp/dioph_eq.cpp

+20-17
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ namespace lp {
771771
if ((int)st >= (int)lp::lp_status::FEASIBLE) {
772772
return false;
773773
}
774+
if (st == lp_status::CANCELLED) return false;
774775
lra.get_infeasibility_explanation(m_infeas_explanation);
775776
return true;
776777
}
@@ -846,7 +847,6 @@ namespace lp {
846847

847848
// returns true if the left and the right branches were explored
848849
bool undo_last_branch() {
849-
unsigned h = m_branch_stack.size() - 1;
850850
if (m_branch_stack.back().m_fully_explored) {
851851
TRACE("dio_br", tout << "pop fully explored, m_branch_stack.size():" << m_branch_stack.size() << std::endl;);
852852
m_branch_stack.pop_back();
@@ -905,7 +905,7 @@ namespace lp {
905905
lra.pop();
906906
}
907907
lra.find_feasible_solution();
908-
SASSERT(lra.is_feasible());
908+
SASSERT(lra.get_status() == lp_status::CANCELLED || lra.is_feasible());
909909
}
910910
// Returns true if a branch is created, and false if not.
911911
// The latter case can happen if we have a sat.
@@ -940,7 +940,7 @@ namespace lp {
940940
m_lra_level--;
941941
lra.pop();
942942
lra.find_feasible_solution();
943-
SASSERT(lra.is_feasible());
943+
SASSERT(lra.get_status() == lp_status::CANCELLED || lra.is_feasible());
944944
}
945945

946946
lia_move process_undef() {
@@ -970,8 +970,8 @@ namespace lp {
970970
lra_pop();
971971
continue;
972972
}
973-
int st = static_cast<int>(lra.find_feasible_solution());
974-
if (st >= static_cast<int>(lp_status::FEASIBLE)) {
973+
auto st = lra.find_feasible_solution();
974+
if ((int)st >= (int)(lp_status::FEASIBLE)) {
975975
// have a feasible solution
976976
unsigned n_of_ii = get_number_of_int_inf();
977977
TRACE("dio_br", tout << "n_of_ii:" << n_of_ii << "\n";);
@@ -982,7 +982,8 @@ namespace lp {
982982
// got to create a new branch
983983
update_branch_stats(*b, n_of_ii);
984984
need_create_branch = true;
985-
} else { // got a conflict
985+
} else {
986+
if (st == lp_status::CANCELLED) return lia_move::undef;
986987
collect_evidence();
987988
if (m_branch_stack.size() == 0)
988989
return lia_move::conflict;
@@ -1023,6 +1024,7 @@ namespace lp {
10231024
m_branch_stats[b.m_j].m_ii_after_right.push_back(n_of_ii);
10241025
}
10251026
}
1027+
10261028

10271029
branch create_branch() {
10281030
unsigned bj = UINT_MAX;
@@ -1040,17 +1042,18 @@ namespace lp {
10401042
}
10411043
}
10421044
branch br;
1043-
if (bj == UINT_MAX) { // it a the case when we cannot create a branch
1044-
SASSERT(lra.is_feasible() &&
1045-
[&]() {
1046-
for (unsigned j = 0; j < lra.column_count(); ++j) {
1047-
if (lia.column_is_int_inf(j)) {
1048-
return false;
1049-
}
1050-
}
1051-
return true;
1052-
}());
1053-
return br; // to signal that we have no ii variables
1045+
if (bj == UINT_MAX) { // it the case when we cannot create a branch
1046+
SASSERT(
1047+
lra.settings().get_cancel_flag() ||
1048+
(lra.is_feasible() && [&]() {
1049+
for (unsigned j = 0; j < lra.column_count(); ++j) {
1050+
if (lia.column_is_int_inf(j)) {
1051+
return false;
1052+
}
1053+
}
1054+
return true;
1055+
}()));
1056+
return br; // to signal that we have no ii variables
10541057
}
10551058

10561059
br.m_j = bj;

0 commit comments

Comments
 (0)