mirror of
https://github.com/Z3Prover/z3
synced 2025-08-11 05:30:51 +00:00
propagate monics with lp_bound_propagator
This commit is contained in:
parent
c309d52283
commit
cbad61ba2e
5 changed files with 74 additions and 64 deletions
|
@ -93,39 +93,17 @@ private:
|
|||
}
|
||||
|
||||
bool bound_is_available(unsigned j, bool lower_bound) {
|
||||
return (lower_bound && lower_bound_is_available(j)) ||
|
||||
(!lower_bound && upper_bound_is_available(j));
|
||||
}
|
||||
|
||||
bool upper_bound_is_available(unsigned j) const {
|
||||
switch (m_bp.get_column_type(j)) {
|
||||
case column_type::fixed:
|
||||
case column_type::boxed:
|
||||
case column_type::upper_bound:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool lower_bound_is_available(unsigned j) const {
|
||||
switch (m_bp.get_column_type(j)) {
|
||||
case column_type::fixed:
|
||||
case column_type::boxed:
|
||||
case column_type::lower_bound:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return (lower_bound && m_bp.lower_bound_is_available(j)) ||
|
||||
(!lower_bound && m_bp.upper_bound_is_available(j));
|
||||
}
|
||||
|
||||
const impq & ub(unsigned j) const {
|
||||
lp_assert(upper_bound_is_available(j));
|
||||
lp_assert(m_bp.upper_bound_is_available(j));
|
||||
return m_bp.get_upper_bound(j);
|
||||
}
|
||||
|
||||
const impq & lb(unsigned j) const {
|
||||
lp_assert(lower_bound_is_available(j));
|
||||
lp_assert(m_bp.lower_bound_is_available(j));
|
||||
return m_bp.get_lower_bound(j);
|
||||
}
|
||||
|
||||
|
@ -305,9 +283,8 @@ private:
|
|||
|
||||
|
||||
void limit_j(unsigned bound_j, const mpq& u, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict){
|
||||
lar_solver* lar = & this->m_bp.lp();
|
||||
unsigned row_index = this->m_row_index;
|
||||
auto explain = [lar, bound_j, coeff_before_j_is_pos, is_lower_bound, strict, row_index]() { return explain_bound_on_var_on_coeff(lar, bound_j, coeff_before_j_is_pos, is_lower_bound, strict, row_index); };
|
||||
auto explain = [bound_j, coeff_before_j_is_pos, is_lower_bound, strict, row_index](lar_solver& s) { return explain_bound_on_var_on_coeff(s, bound_j, coeff_before_j_is_pos, is_lower_bound, strict, row_index); };
|
||||
m_bp.add_bound(u, bound_j, is_lower_bound, strict, explain );
|
||||
}
|
||||
|
||||
|
@ -341,22 +318,22 @@ private:
|
|||
break;
|
||||
}
|
||||
}
|
||||
static u_dependency* explain_bound_on_var_on_coeff(lar_solver* lar, unsigned bound_j, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict, unsigned row_index) {
|
||||
static u_dependency* explain_bound_on_var_on_coeff(lar_solver& lar, unsigned bound_j, bool coeff_before_j_is_pos, bool is_lower_bound, bool strict, unsigned row_index) {
|
||||
int bound_sign = (is_lower_bound ? 1 : -1);
|
||||
int j_sign = (coeff_before_j_is_pos ? 1 : -1) * bound_sign;
|
||||
|
||||
if (tv::is_term(bound_j))
|
||||
bound_j = lar->map_term_index_to_column_index(bound_j);
|
||||
bound_j = lar.map_term_index_to_column_index(bound_j);
|
||||
u_dependency* ret = nullptr;
|
||||
for (auto const& r : lar->get_row(row_index)) {
|
||||
for (auto const& r : lar.get_row(row_index)) {
|
||||
unsigned j = r.var();
|
||||
if (j == bound_j)
|
||||
continue;
|
||||
mpq const& a = r.coeff();
|
||||
int a_sign = is_pos(a) ? 1 : -1;
|
||||
int sign = j_sign * a_sign;
|
||||
u_dependency* witness = sign > 0 ? lar->get_column_upper_bound_witness(j) : lar->get_column_lower_bound_witness(j);
|
||||
ret = lar->join_deps(ret, witness);
|
||||
u_dependency* witness = sign > 0 ? lar.get_column_upper_bound_witness(j) : lar.get_column_lower_bound_witness(j);
|
||||
ret = lar.join_deps(ret, witness);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue