Skip to content

Commit 364abb6

Browse files
committed
separate m_changed_terms and m_terms_to_tighten in indexed_uint_sets
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent 62435b1 commit 364abb6

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

src/math/lp/dioph_eq.cpp

+14-26
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,8 @@ namespace lp {
488488
// m_changed_columns are the columns that just became fixed, or those that just stopped being fixed.
489489
// If such a column appears in an entry it has to be recalculated.
490490
indexed_uint_set m_changed_columns;
491-
enum class term_status{
492-
no_change,
493-
change, // need to find changed rows depending on the term
494-
bound_change // need to tighten the term
495-
};
496-
std_vector<term_status> m_changed_terms;
491+
indexed_uint_set m_changed_terms; // represented by term columns
492+
indexed_uint_set m_terms_to_tighten; // represented by term columns
497493
indexed_uint_set m_tightened_columns; // the column that got tightened by the tigthening phase,
498494
// m_column_to_terms[j] is the set of all k such lra.get_term(k) depends on j
499495
std::unordered_map<unsigned, std::unordered_set<unsigned>> m_columns_to_terms;
@@ -759,9 +755,7 @@ namespace lp {
759755

760756
void mark_term_change(unsigned j) {
761757
TRACE("dio", tout << "marked term change j:" << j << std::endl;);
762-
if (j >= m_changed_terms.size())
763-
m_changed_terms.resize(j + 1, term_status::no_change);
764-
m_changed_terms[j] = term_status::change;
758+
m_changed_terms.insert(j);
765759
}
766760

767761
void update_column_bound_callback(unsigned j) {
@@ -999,13 +993,8 @@ namespace lp {
999993

1000994
void process_changed_columns(std_vector<unsigned> &f_vector) {
1001995
find_changed_terms_and_more_changed_rows();
1002-
for (unsigned j = 0; j < m_changed_terms.size(); j++) {
1003-
term_status t = m_changed_terms[j];
1004-
if (t != term_status::change) {
1005-
TRACE("dio", tout << "went on continue\n";);
1006-
continue;
1007-
}
1008-
m_changed_terms[j] = term_status::bound_change; // prepare for tightening
996+
for (unsigned j: m_changed_terms) {
997+
m_terms_to_tighten.insert(j);
1009998
if (j < m_l_matrix.column_count()) {
1010999
for (const auto& cs : m_l_matrix.column(j)) {
10111000
m_changed_rows.insert(cs.var());
@@ -1051,7 +1040,7 @@ namespace lp {
10511040
eliminate_substituted_in_changed_rows();
10521041
m_changed_columns.reset();
10531042
m_changed_rows.reset();
1054-
// do not clean up m_changed_terms as they are used in tighten_terms_with_S()
1043+
m_changed_terms.reset();
10551044
SASSERT(entries_are_ok());
10561045
}
10571046

@@ -1388,14 +1377,14 @@ namespace lp {
13881377
lia_move tighten_terms_with_S() {
13891378
// Copy changed terms to another vector for sorting
13901379
std_vector<unsigned> sorted_changed_terms;
1380+
std_vector<unsigned> processed_terms;
13911381
m_tightened_columns.reset();
1392-
for (unsigned j = 0; j < m_changed_terms.size(); j++) {
1393-
if (m_changed_terms[j] == term_status::no_change) continue;
1382+
for (unsigned j: m_terms_to_tighten) {
13941383
if (j >= lra.column_count() ||
13951384
!lra.column_has_term(j) ||
13961385
lra.column_is_free(j) ||
13971386
!lia.column_is_int(j)) {
1398-
unmark_changed_term(j);
1387+
processed_terms.push_back(j);
13991388
continue;
14001389
}
14011390
sorted_changed_terms.push_back(j);
@@ -1414,19 +1403,18 @@ namespace lp {
14141403
// print_bounds(tout);
14151404
);
14161405
for (unsigned j : sorted_changed_terms) {
1417-
unmark_changed_term(j);
1406+
m_terms_to_tighten.remove(j);
14181407
r = tighten_bounds_for_term_column(j);
14191408
if (r != lia_move::undef) {
14201409
break;
14211410
}
14221411
}
1412+
for (unsigned j :processed_terms) {
1413+
m_terms_to_tighten.remove(j);
1414+
}
14231415
return r;
14241416
}
14251417

1426-
void unmark_changed_term(unsigned j) {
1427-
m_changed_terms[j] = term_status::no_change;
1428-
}
1429-
14301418
term_o create_term_from_espace() const {
14311419
term_o t;
14321420
for (const auto& p : m_espace.m_data) {
@@ -1438,7 +1426,7 @@ namespace lp {
14381426

14391427
// We will have lar_t, and let j is lar_t.j(), the term column.
14401428
// In the m_espace we have lar_t. The result of open_ml((1*j)) is lar_t - (1, j).
1441-
// So we have "equality" m_espace = open(m_lspace) + (1*lar_t.j.
1429+
// So we have "equality" m_espace = open(m_lspace) + (1*lar_t.j())
14421430
void init_substitutions(const lar_term& lar_t, protected_queue& q) {
14431431
m_espace.clear();
14441432
m_c = mpq(0);

0 commit comments

Comments
 (0)