Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Sep 16, 2023
1 parent c240f62 commit 77e56b0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/math/lp/bound_analyzer_on_row.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public :
}
}
static u_dependency* explain_bound_on_var_on_coeff(B* bp, unsigned bound_j, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict, unsigned row_index) {
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";);
auto& lar = bp->lp();
int bound_sign = (is_lower_bound ? 1 : -1);
int j_sign = (coeff_before_j_is_pos ? 1 : -1) * bound_sign;
Expand Down
2 changes: 1 addition & 1 deletion src/math/lp/implied_bound.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class implied_bound {
std::function<u_dependency*(int *)> m_explain_bound = nullptr;
public:
// s is expected to be the pointer to lp_bound_propagator.
u_dependency* explain(int * s) const { return m_explain_bound(s); }
u_dependency* explain_implied(int * s) const { return m_explain_bound(s); }
void set_explain(std::function<u_dependency*(int *)> f) { m_explain_bound = f; }
lconstraint_kind kind() const {
lconstraint_kind k = m_is_lower_bound? GE : LE;
Expand Down
4 changes: 2 additions & 2 deletions src/math/lp/lar_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ class lar_solver : public column_namer {

template <typename T>
void explain_implied_bound(const implied_bound& ib, lp_bound_propagator<T>& bp) {
u_dependency* dep = ib.explain((int*)&bp);
u_dependency* dep = ib.explain_implied((int*)&bp);
for (auto ci : flatten(dep))
bp.consume(mpq(1), ci); // TODO: flatten should provid the coefficients
bp.consume(mpq(1), ci); // TODO: flatten should provide the coefficients
/*
if (ib.m_is_monic) {
NOT_IMPLEMENTED_YET();
Expand Down
10 changes: 7 additions & 3 deletions src/math/lp/lp_bound_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ class lp_bound_propagator {
return n_of_non_fixed <= 1;
}


void add_bounds_for_zero_var(lpvar monic_var, lpvar zero_var) {
add_lower_bound_monic(monic_var, mpq(0), false, [zero_var](int* s){return ((lp_bound_propagator*)s)->lp().get_bound_constraint_witnesses_for_column(zero_var);});
add_upper_bound_monic(monic_var, mpq(0), false, [zero_var](int* s){return ((lp_bound_propagator*)s)->lp().get_bound_constraint_witnesses_for_column(zero_var);});
auto lambda = [zero_var](int* s) {
return ((lp_bound_propagator*)s)->lp().get_bound_constraint_witnesses_for_column(zero_var);
};
TRACE("add_bound", lp().print_column_info(zero_var, tout) << std::endl;);
add_lower_bound_monic(monic_var, mpq(0), false, lambda);
add_upper_bound_monic(monic_var, mpq(0), false, lambda);
}

void add_lower_bound_monic(lpvar j, const mpq& v, bool is_strict, std::function<u_dependency* (int*)> explain_dep) {
unsigned k;
TRACE("add_bound", lp().print_column_info(j, tout) << std::endl;);
j = lp().column_to_reported_index(j);
if (!try_get_value(m_improved_lower_bounds, j, k)) {
m_improved_lower_bounds[j] = m_ibounds.size();
Expand Down
2 changes: 1 addition & 1 deletion src/sat/smt/arith_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace arith {
first = false;
reset_evidence();
m_explanation.clear();
be.explain((int*)&m_bp);
be.explain_implied((int*)&m_bp);
}
CTRACE("arith", m_unassigned_bounds[v] == 0, tout << "missed bound\n";);
updt_unassigned_bounds(v, -1);
Expand Down

0 comments on commit 77e56b0

Please sign in to comment.