Skip to content

Commit 3b3d8ce

Browse files
committed
use m_chandedNterms to tighten terms
1 parent 65bdd58 commit 3b3d8ce

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/math/lp/dioph_eq.cpp

+19-11
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ namespace lp {
438438

439439
indexed_uint_set m_changed_rows;
440440
indexed_uint_set m_changed_columns;
441+
indexed_uint_set m_changed_terms; // a term is defined by its column j, as in lar_solver.get_term(j)
441442
// m_column_to_terms[j] is the set of all k such lra.get_term(k) depends on j
442443
std::unordered_map<unsigned, std::unordered_set<unsigned>> m_columns_to_terms;
443444

@@ -886,12 +887,12 @@ namespace lp {
886887
SASSERT(entry_invariant(ei));
887888
}
888889

889-
void find_changed_terms_and_more_changed_rows(std::unordered_set<unsigned> & changed_terms) {
890+
void find_changed_terms_and_more_changed_rows() {
890891
for (unsigned j : m_changed_columns) {
891892
const auto it = m_columns_to_terms.find(j);
892893
if (it != m_columns_to_terms.end())
893894
for (unsigned k : it->second) {
894-
changed_terms.insert(k);
895+
m_changed_terms.insert(k);
895896
}
896897
if (!m_var_register.external_is_used(j))
897898
continue;
@@ -923,9 +924,8 @@ namespace lp {
923924
delete_column(j);
924925
}
925926
}
926-
std::unordered_set<unsigned> changed_terms; // a term is signified by the term column, like j in lra.get_term(j)
927-
find_changed_terms_and_more_changed_rows(changed_terms);
928-
for (unsigned j : changed_terms) {
927+
find_changed_terms_and_more_changed_rows();
928+
for (unsigned j : m_changed_terms) {
929929
for (const auto & cs: m_l_matrix.column(j)) {
930930
m_changed_rows.insert(cs.var());
931931
}
@@ -1324,16 +1324,24 @@ namespace lp {
13241324
}
13251325

13261326
lia_move tighten_terms_with_S() {
1327-
for (unsigned j = 0; j < lra.column_count(); j++) {
1327+
std_vector<unsigned> cleanup;
1328+
lia_move ret = lia_move::undef;
1329+
for (unsigned j : m_changed_terms) {
1330+
cleanup.push_back(j);
13281331
if (!lra.column_has_term(j) || lra.column_is_free(j) ||
1329-
is_fixed(j) || !lia.column_is_int(j))
1332+
is_fixed(j) || !lia.column_is_int(j)) {
13301333
continue;
1334+
}
13311335

1332-
if (tighten_bounds_for_term_column(j))
1333-
return lia_move::conflict;
1336+
if (tighten_bounds_for_term_column(j)) {
1337+
ret = lia_move::conflict;
1338+
break;
1339+
}
13341340
}
1335-
1336-
return lia_move::undef;
1341+
for (unsigned j: cleanup) {
1342+
m_changed_terms.remove(j);
1343+
}
1344+
return ret;
13371345
}
13381346

13391347
std::ostream& print_queue(std::queue<unsigned> q, std::ostream& out) {

0 commit comments

Comments
 (0)