Skip to content

Commit b985838

Browse files
committed
do not pass row index to bound_analyzer_on_row
Signed-off-by: Lev Nachmanson <[email protected]>
1 parent 10c2af8 commit b985838

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/math/lp/bound_analyzer_on_row.h

+5-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ template <typename C, typename B> // C plays a role of a container, B - lp_bound
3232
class bound_analyzer_on_row {
3333
const C& m_row;
3434
B & m_bp;
35-
unsigned m_row_index;
3635
int m_column_of_u; // index of an unlimited from above monoid
3736
// -1 means that such a value is not found, -2 means that at least two of such monoids were found
3837
int m_column_of_l; // index of an unlimited from below monoid
@@ -43,12 +42,10 @@ public :
4342
bound_analyzer_on_row(
4443
const C & it,
4544
const numeric_pair<mpq>& rs,
46-
unsigned row_or_term_index,
4745
B & bp)
4846
:
4947
m_row(it),
5048
m_bp(bp),
51-
m_row_index(row_or_term_index),
5249
m_column_of_u(-1),
5350
m_column_of_l(-1),
5451
m_rs(rs)
@@ -57,9 +54,8 @@ public :
5754

5855
static unsigned analyze_row(const C & row,
5956
const numeric_pair<mpq>& rs,
60-
unsigned row_or_term_index,
6157
B & bp) {
62-
bound_analyzer_on_row a(row, rs, row_or_term_index, bp);
58+
bound_analyzer_on_row a(row, rs, bp);
6359
return a.analyze();
6460
}
6561

@@ -281,16 +277,16 @@ public :
281277

282278
void limit_j(unsigned bound_j, const mpq& u, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict)
283279
{
284-
unsigned row_index = this->m_row_index;
285280
auto* lar = &m_bp.lp();
286-
auto explain = [bound_j, coeff_before_j_is_pos, is_lower_bound, strict, row_index, lar]() {
281+
const auto& row = this->m_row;
282+
auto explain = [row, bound_j, coeff_before_j_is_pos, is_lower_bound, strict, lar]() {
287283
(void) strict;
288-
TRACE("bound_analyzer", tout << "explain_bound_on_var_on_coeff, bound_j = " << bound_j << ", coeff_before_j_is_pos = " << coeff_before_j_is_pos << ", is_lower_bound = " << is_lower_bound << ", strict = " << strict << ", row_index = " << row_index << "\n";);
284+
TRACE("bound_analyzer", tout << "explain_bound_on_var_on_coeff, bound_j = " << bound_j << ", coeff_before_j_is_pos = " << coeff_before_j_is_pos << ", is_lower_bound = " << is_lower_bound << ", strict = " << strict << "\n";);
289285
int bound_sign = (is_lower_bound ? 1 : -1);
290286
int j_sign = (coeff_before_j_is_pos ? 1 : -1) * bound_sign;
291287

292288
u_dependency* ret = nullptr;
293-
for (auto const& r : lar->get_row(row_index)) {
289+
for (auto const& r : row) {
294290
unsigned j = r.var();
295291
if (j == bound_j)
296292
continue;

src/math/lp/dioph_eq.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ namespace lp {
485485
indexed_uint_set m_changed_rows;
486486
indexed_uint_set m_changed_columns;
487487
indexed_uint_set m_changed_terms; // a term is defined by its column j, as in lar_solver.get_term(j)
488+
indexed_uint_set m_tightened_columns; // the column that got tightened by the tigthening phase,
488489
// m_column_to_terms[j] is the set of all k such lra.get_term(k) depends on j
489490
std::unordered_map<unsigned, std::unordered_set<unsigned>> m_columns_to_terms;
490491

@@ -1361,6 +1362,7 @@ namespace lp {
13611362
// Copy changed terms to another vector for sorting
13621363
std_vector<unsigned> sorted_changed_terms;
13631364
std_vector<unsigned> cleanup;
1365+
m_tightened_columns.reset();
13641366
for (unsigned j : m_changed_terms) {
13651367
if (
13661368
j >= lra.column_count() ||
@@ -1620,8 +1622,11 @@ namespace lp {
16201622
}
16211623
}
16221624

1625+
lia_move propagate_bounds_on_tightened_columns() {
1626+
return lia_move::undef;
1627+
}
16231628
// m_espace contains the coefficients of the term
1624-
// m_c contains the constant term
1629+
// m_c contains the fixed part of the term
16251630
// m_tmp_l is the linear combination of the equations that removes the
16261631
// substituted variables.
16271632
// returns true iff the conflict is found
@@ -1642,14 +1647,15 @@ namespace lp {
16421647
return lia_move::conflict;
16431648
}
16441649
}
1650+
std::cout << "new tbs:" << m_tightened_columns.size() << "\n";
16451651
return lia_move::undef;
16461652
}
16471653

16481654
// returns true only on a conflict
16491655
bool tighten_bound_kind(const mpq& g, unsigned j, const mpq& ub, bool upper,
16501656
u_dependency* prev_dep) {
16511657
// ub = (upper_bound(j) - m_c)/g.
1652-
// we have x[j] = t = g*t_+ m_c <= upper_bound(j), then
1658+
// we have xj = t = g*t_+ m_c <= upper_bound(j), then
16531659
// t_ <= floor((upper_bound(j) - m_c)/g) = floor(ub)
16541660
//
16551661
// so xj = g*t_+m_c <= g*floor(ub) + m_c is new upper bound
@@ -1679,6 +1685,7 @@ namespace lp {
16791685
lra.update_column_type_and_bound(j, kind, bound, dep);
16801686
lp_status st = lra.find_feasible_solution();
16811687
if ((int)st >= (int)lp::lp_status::FEASIBLE) {
1688+
m_tightened_columns.insert(j);
16821689
return false;
16831690
}
16841691
if (st == lp_status::CANCELLED) return false;

src/math/lp/lar_solver.h

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ class lar_solver : public column_namer {
185185
return bound_analyzer_on_row<row_strip<mpq>, lp_bound_propagator<T>>::analyze_row(
186186
A_r().m_rows[row_index],
187187
zero_of_type<numeric_pair<mpq>>(),
188-
row_index,
189188
bp);
190189
}
191190

0 commit comments

Comments
 (0)