Skip to content

Commit 9a62ed5

Browse files
NikolajBjornerlevnach
authored andcommitted
added some comments
1 parent c634701 commit 9a62ed5

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/math/lp/dioph_eq.cpp

+22-21
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ namespace lp {
506506

507507
unsigned m_conflict_index = UINT_MAX; // the row index of the conflict
508508
void reset_conflict() { m_conflict_index = UINT_MAX; }
509-
bool has_conflict() const { return m_conflict_index != UINT_MAX; }
509+
bool has_conflict_index() const { return m_conflict_index != UINT_MAX; }
510510
void set_rewrite_conflict(unsigned idx) { SASSERT(idx != UINT_MAX); m_conflict_index = idx; lra.stats().m_dio_rewrite_conflicts++; }
511511
unsigned m_max_of_branching_iterations = 0;
512512
unsigned m_number_of_branching_calls;
@@ -1658,7 +1658,7 @@ namespace lp {
16581658
lia_move tighten_bounds_for_non_trivial_gcd(const mpq& g, unsigned j,
16591659
bool is_upper) {
16601660
mpq rs;
1661-
bool is_strict;
1661+
bool is_strict = false;
16621662
u_dependency* b_dep = nullptr;
16631663
SASSERT(!g.is_zero());
16641664

@@ -1679,10 +1679,14 @@ namespace lp {
16791679
return lia_move::undef;
16801680
}
16811681

1682-
// returns true only on a conflict
1682+
// returns true only on a conflict
16831683
bool tighten_bound_kind(const mpq& g, unsigned j, const mpq& rs, const mpq& rs_mod_g, bool upper) {
1684+
// Assume:
1685+
// rs_mod_g := (rs - m_c) % g
1686+
// rs_mod_g != 0
1687+
//
16841688
// In case of an upper bound we have
1685-
// xj = t = g*t_+ m_c <= rs, also, by definition fo rs_mod_g, for some integer k holds rs - m_c = k*g + rs_mod_g.
1689+
// xj = t = g*t_+ m_c <= rs, also, by definition of rs_mod_g, for some integer k holds rs - m_c = k*g + rs_mod_g.
16861690
// Then g*t_ <= rs - mc = k*g + rs_mod_g => g*t_ <= k*g = rs - m_c - rs_mod_g.
16871691
// Adding m_c to both parts gets us
16881692
// xj = g*t_ + m_c <= rs - rs_mod_g
@@ -1696,8 +1700,7 @@ namespace lp {
16961700

16971701
mpq bound = upper ? rs - rs_mod_g : rs + g - rs_mod_g;
16981702
TRACE("dio", tout << "is upper:" << upper << std::endl;
1699-
tout << "new " << (upper ? "upper" : "lower")
1700-
<< " bound:" << bound << std::endl;);
1703+
tout << "new " << (upper ? "upper" : "lower") << " bound:" << bound << std::endl;);
17011704

17021705
SASSERT((upper && bound < lra.get_upper_bound(j).x) ||
17031706
(!upper && bound > lra.get_lower_bound(j).x));
@@ -1710,8 +1713,8 @@ namespace lp {
17101713
for (const auto& p: fixed_part_of_the_term) {
17111714
SASSERT(is_fixed(p.var()));
17121715
if ((p.coeff() % g).is_zero()) {
1713-
// we can skip thise dependency,
1714-
// because the monomial p.coeff()*p.var() is null by modulo g, and it does not matter that p.var() is fixed.
1716+
// we can skip this dependency
1717+
// because the monomial p.coeff()*p.var() is 0 modulo g, and it does not matter that p.var() is fixed.
17151718
// We could have added p.coeff()*p.var() to t_, substructed the value of p.coeff()*p.var() from m_c and
17161719
// still get the same result.
17171720
TRACE("dio", tout << "skipped dep:\n"; print_deps(tout, lra.get_bound_constraint_witnesses_for_column(p.var())););
@@ -1767,7 +1770,7 @@ namespace lp {
17671770
}
17681771

17691772
lia_move process_f(std_vector<unsigned>& f_vector) {
1770-
if (has_conflict())
1773+
if (has_conflict_index())
17711774
return lia_move::conflict;
17721775
lia_move r;
17731776
do {
@@ -2156,7 +2159,7 @@ namespace lp {
21562159
bool first = true;
21572160
mpq ahk;
21582161
unsigned k = -1;
2159-
int k_sign;
2162+
int k_sign = 0;
21602163
mpq t;
21612164
for (const auto& p : m_e_matrix.m_rows[ei]) {
21622165
t = abs(p.coeff());
@@ -2586,19 +2589,17 @@ namespace lp {
25862589
}
25872590

25882591
public:
2592+
25892593
void explain(explanation& ex) {
2590-
if (!has_conflict()) {
2591-
for (auto ci : m_infeas_explanation) {
2592-
ex.push_back(ci.ci());
2593-
}
2594-
TRACE("dio", lra.print_expl(tout, ex););
2595-
return;
2596-
}
25972594
SASSERT(ex.empty());
2598-
TRACE("dio", tout << "conflict:";
2599-
print_entry(m_conflict_index, tout, true) << std::endl;);
2600-
for (auto ci : lra.flatten(explain_fixed_in_meta_term(m_l_matrix.m_rows[m_conflict_index]))) {
2601-
ex.push_back(ci);
2595+
if (has_conflict_index()) {
2596+
TRACE("dio", print_entry(m_conflict_index, tout << "conflict:", true) << std::endl;);
2597+
for (auto ci : lra.flatten(explain_fixed_in_meta_term(m_l_matrix.m_rows[m_conflict_index])))
2598+
ex.push_back(ci);
2599+
}
2600+
else {
2601+
for (auto ci : m_infeas_explanation)
2602+
ex.push_back(ci.ci());
26022603
}
26032604
TRACE("dio", lra.print_expl(tout, ex););
26042605
}

0 commit comments

Comments
 (0)