mirror of
https://github.com/Z3Prover/z3
synced 2025-04-27 19:05:51 +00:00
fix bugs in patching
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
e7bb8e57cb
commit
c355ee025a
3 changed files with 40 additions and 58 deletions
|
@ -565,40 +565,6 @@ bool lar_solver::remove_from_basis(unsigned j) {
|
|||
return m_mpq_lar_core_solver.m_r_solver.remove_from_basis(j);
|
||||
}
|
||||
|
||||
// val is the new value to be assigned to x[j]
|
||||
// return true iff can find a new basic column that would be feasible
|
||||
// after the pivoting
|
||||
bool lar_solver::remove_from_basis(unsigned basic_j, const mpq& val) {
|
||||
SASSERT(is_base(basic_j));
|
||||
impq del(0);
|
||||
const auto& slv = m_mpq_lar_core_solver.m_r_solver;
|
||||
bool grow = val < get_column_value(basic_j).x; // grow = true means that the monomial of the pivoted var has to grow
|
||||
for (auto &c : A_r().m_rows[row_of_basic_column(basic_j)]) {
|
||||
lpvar j = c.var();
|
||||
if (j == basic_j) {
|
||||
SASSERT(c.coeff().is_one());
|
||||
continue;
|
||||
}
|
||||
|
||||
bool can_pivot = column_is_free(j);
|
||||
if (!can_pivot &&
|
||||
((grow && slv.monoid_can_increase(c))|| (!grow && slv.monoid_can_decrease(c)))) {
|
||||
if (del.is_zero())
|
||||
del = impq(val) - get_column_value(basic_j);
|
||||
|
||||
impq j_val = get_column_value(j) - del / c.coeff();
|
||||
if (inside_bounds(j, j_val))
|
||||
can_pivot = true;
|
||||
}
|
||||
|
||||
if (can_pivot) {
|
||||
pivot_column_tableau(c.var(), row_of_basic_column(basic_j));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
lar_term lar_solver::get_term_to_maximize(unsigned j_or_term) const {
|
||||
if (tv::is_term(j_or_term)) {
|
||||
return get_term(j_or_term);
|
||||
|
@ -1292,7 +1258,8 @@ void lar_solver::get_rid_of_inf_eps() {
|
|||
mpq delta = m_mpq_lar_core_solver.find_delta_for_strict_bounds(mpq(1));
|
||||
for (unsigned j = 0; j < number_of_vars(); j++) {
|
||||
auto & r = m_mpq_lar_core_solver.m_r_x[j];
|
||||
r = impq(r.x + delta * r.y);
|
||||
if (!r.y.is_zero())
|
||||
r = impq(r.x + delta * r.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue