Skip to content

Commit f501aea

Browse files
committed
add comments and renaming
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent a522e81 commit f501aea

File tree

3 files changed

+19
-31
lines changed

3 files changed

+19
-31
lines changed

src/math/lp/dioph_eq.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ namespace lp {
484484
std::unordered_map<unsigned, std_vector<unsigned>> m_row2fresh_defs;
485485

486486
indexed_uint_set m_changed_rows;
487-
indexed_uint_set m_new_fixed_columns;
487+
// m_changed_columns are the columns that just became fixed, or those that just stopped being fixed.
488+
// If such a column appears in an entry it has to be recalculated.
489+
indexed_uint_set m_changed_columns;
488490
indexed_uint_set m_changed_terms; // a term is defined by its column j, as in lar_solver.get_term(j)
489491
indexed_uint_set m_tightened_columns; // the column that got tightened by the tigthening phase,
490492
// m_column_to_terms[j] is the set of all k such lra.get_term(k) depends on j
@@ -721,7 +723,7 @@ namespace lp {
721723

722724
void add_changed_column(unsigned j) {
723725
TRACE("dio", lra.print_column_info(j, tout););
724-
m_new_fixed_columns.insert(j);
726+
m_changed_columns.insert(j);
725727
}
726728
std_vector<const lar_term*> m_added_terms;
727729
std::unordered_set<const lar_term*> m_active_terms;
@@ -751,7 +753,7 @@ namespace lp {
751753
void update_column_bound_callback(unsigned j) {
752754
if (!lra.column_is_int(j) || !lra.column_is_fixed(j))
753755
return;
754-
m_new_fixed_columns.insert(j);
756+
m_changed_columns.insert(j);
755757
auto undo = undo_fixed_column(*this, j);
756758
lra.trail().push(undo);
757759
}
@@ -932,7 +934,7 @@ namespace lp {
932934
}
933935

934936
void find_changed_terms_and_more_changed_rows() {
935-
for (unsigned j : m_new_fixed_columns) {
937+
for (unsigned j : m_changed_columns) {
936938
const auto it = m_columns_to_terms.find(j);
937939
if (it != m_columns_to_terms.end())
938940
for (unsigned k : it->second) {
@@ -1025,8 +1027,8 @@ namespace lp {
10251027
remove_irrelevant_fresh_defs();
10261028

10271029
eliminate_substituted_in_changed_rows();
1028-
m_new_fixed_columns.reset();
1029-
SASSERT(m_new_fixed_columns.size() == 0);
1030+
m_changed_columns.reset();
1031+
SASSERT(m_changed_columns.size() == 0);
10301032
m_changed_rows.reset();
10311033
SASSERT(entries_are_ok());
10321034
}
@@ -1500,7 +1502,7 @@ namespace lp {
15001502
if (tighten_bounds_for_non_trivial_gcd(g, j, false) != lia_move::undef) {
15011503
return lia_move::conflict;
15021504
}
1503-
if (m_new_fixed_columns.contains(j)) {
1505+
if (m_changed_columns.contains(j)) {
15041506
return lia_move::continue_with_check;
15051507
}
15061508
return lia_move::undef;
@@ -1743,7 +1745,7 @@ namespace lp {
17431745
if (r == lia_move::conflict || r == lia_move::undef) {
17441746
break;
17451747
}
1746-
SASSERT(m_new_fixed_columns.size() == 0);
1748+
SASSERT(m_changed_columns.size() == 0);
17471749
} while (f_vector.size());
17481750

17491751
if (r == lia_move::conflict) {

src/math/lp/lar_solver.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,15 @@ namespace lp {
19971997
TRACE("lar_solver_feas", tout << "j = " << j << " became " << (this->column_is_feasible(j) ? "feas" : "non-feas") << ", and " << (this->column_is_bounded(j) ? "bounded" : "non-bounded") << std::endl;);
19981998
if (m_update_column_bound_callback)
19991999
m_update_column_bound_callback(j);
2000+
2001+
if (settings().dump_bound_lemmas()) {
2002+
if (kind == LE)
2003+
write_bound_lemma(j, false, __func__, std::cout);
2004+
else if (kind == GE)
2005+
write_bound_lemma(j, true, __func__, std::cout);
2006+
else
2007+
NOT_IMPLEMENTED_YET();
2008+
}
20002009
}
20012010

20022011
void lar_solver::insert_to_columns_with_changed_bounds(unsigned j) {
@@ -2509,24 +2518,6 @@ namespace lp {
25092518
// Otherwise the new asserted lower bound is is greater than the existing upper bound.
25102519
// dep is the reason for the new bound
25112520

2512-
void lar_solver::write_bound_lemma_to_file(unsigned j, bool is_low, const std::string & file_name, const std::string& location) const {
2513-
std::ofstream file(file_name);
2514-
if (!file.is_open()) {
2515-
// Handle file open error
2516-
std::cerr << "Failed to open file: " << file_name << std::endl;
2517-
return;
2518-
}
2519-
2520-
write_bound_lemma(j, is_low, location, file);
2521-
file.close();
2522-
2523-
if (file.fail()) {
2524-
std::cerr << "Error occurred while writing to file: " << file_name << std::endl;
2525-
} else {
2526-
std::cout << "Bound lemma written to " << file_name << std::endl;
2527-
}
2528-
}
2529-
25302521
void lar_solver::set_crossed_bounds_column_and_deps(unsigned j, bool lower_bound, u_dependency* dep) {
25312522
if (m_crossed_bounds_column != null_lpvar) return; // already set
25322523
SASSERT(m_crossed_bounds_deps == nullptr);
@@ -2557,9 +2548,6 @@ namespace lp {
25572548
return out;
25582549
}
25592550

2560-
2561-
2562-
25632551
// Helper function to format constants in SMT2 format
25642552
std::string format_smt2_constant(const mpq& val) {
25652553
if (val.is_neg()) {

src/math/lp/lar_solver.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,6 @@ class lar_solver : public column_namer {
726726
return m_usage_in_terms[j];
727727
}
728728

729-
void write_bound_lemma_to_file(unsigned j, bool is_low, const std::string & file_name, const std::string & location) const;
730-
731729
void write_bound_lemma(unsigned j, bool is_low, const std::string & location, std::ostream & out) const;
732730

733731
std::function<void (const indexed_uint_set& columns_with_changed_bound)> m_find_monics_with_changed_bounds_func = nullptr;

0 commit comments

Comments
 (0)