Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 14c672f

Browse files
committedMar 16, 2025·
isolate m_conflict_index functionality
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 0b3ef82 commit 14c672f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed
 

‎src/math/lp/dioph_eq.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,10 @@ namespace lp {
494494
// m_column_to_terms[j] is the set of all k such lra.get_term(k) depends on j
495495
std::unordered_map<unsigned, std::unordered_set<unsigned>> m_columns_to_terms;
496496

497-
unsigned m_conflict_index = -1; // the row index of the conflict
497+
unsigned m_conflict_index = UINT_MAX; // the row index of the conflict
498+
void reset_conflict() { m_conflict_index = UINT_MAX; }
499+
bool has_conflict() const { return m_conflict_index == UINT_MAX; }
500+
void set_rewrite_conflict(unsigned idx) { SASSERT(idx != UINT_MAX); m_conflict_index = idx; lra.stats().m_dio_rewrite_conflicts++; }
498501
unsigned m_max_of_branching_iterations = 0;
499502
unsigned m_number_of_branching_calls;
500503
struct branch {
@@ -1102,12 +1105,12 @@ namespace lp {
11021105

11031106
void init(std_vector<unsigned> & f_vector) {
11041107
m_report_branch = false;
1105-
m_conflict_index = -1;
11061108
m_infeas_explanation.clear();
11071109
lia.get_term().clear();
11081110
m_number_of_branching_calls = 0;
11091111
m_branch_stack.clear();
11101112
m_lra_level = 0;
1113+
reset_conflict();
11111114

11121115
process_changed_columns(f_vector);
11131116
for (const lar_term* t : m_added_terms) {
@@ -1757,7 +1760,7 @@ namespace lp {
17571760
continue;
17581761
}
17591762
else {
1760-
m_conflict_index = ei;
1763+
set_rewrite_conflict(ei);
17611764
return;
17621765
}
17631766
}
@@ -1766,10 +1769,8 @@ namespace lp {
17661769
}
17671770

17681771
lia_move process_f(std_vector<unsigned>& f_vector) {
1769-
if (m_conflict_index != UINT_MAX) {
1770-
lra.stats().m_dio_rewrite_conflicts++;
1772+
if (has_conflict())
17711773
return lia_move::conflict;
1772-
}
17731774
lia_move r;
17741775
do {
17751776
r = rewrite_eqs(f_vector);
@@ -1782,9 +1783,6 @@ namespace lp {
17821783
while (f_vector.size());
17831784

17841785
if (r == lia_move::conflict) {
1785-
if (m_conflict_index != UINT_MAX) {
1786-
lra.stats().m_dio_rewrite_conflicts++;
1787-
}
17881786
return lia_move::conflict;
17891787
}
17901788
TRACE("dio_s", print_S(tout));
@@ -2559,15 +2557,15 @@ namespace lp {
25592557
continue;
25602558
}
25612559
else {
2562-
m_conflict_index = ei;
2560+
set_rewrite_conflict(ei);
25632561
return lia_move::conflict;
25642562
}
25652563
}
25662564

25672565
auto [ahk, k, k_sign, markovich_number] = find_minimal_abs_coeff(ei);
25682566
mpq gcd;
25692567
if (!normalize_e_by_gcd(ei, gcd)) {
2570-
m_conflict_index = ei;
2568+
set_rewrite_conflict(ei);
25712569
return lia_move::conflict;
25722570
}
25732571
if (!gcd.is_one())
@@ -2616,7 +2614,7 @@ namespace lp {
26162614

26172615
public:
26182616
void explain(explanation& ex) {
2619-
if (m_conflict_index == UINT_MAX) {
2617+
if (!has_conflict()) {
26202618
for (auto ci : m_infeas_explanation) {
26212619
ex.push_back(ci.ci());
26222620
}

0 commit comments

Comments
 (0)
Please sign in to comment.