3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 19:35:50 +00:00

new equality propagation scheme, etc

This commit is contained in:
Lev Nachmanson 2023-08-03 17:24:37 -10:00 committed by Lev Nachmanson
parent 125787c458
commit 0c98c755ba
6 changed files with 269 additions and 542 deletions

View file

@ -477,9 +477,17 @@ namespace lp {
}
return false;
}
bool lar_solver::remove_from_basis(unsigned j) {
return m_mpq_lar_core_solver.m_r_solver.remove_from_basis(j);
// returns true iff the row of j has a non-fixed column different from j
bool lar_solver::remove_from_basis(unsigned j) {
lp_assert(is_base(j));
unsigned i = row_of_basic_column(j);
for (const auto & c : A_r().m_rows[i]) {
if (j != c.var() && !is_fixed(c.var())) {
return m_mpq_lar_core_solver.m_r_solver.remove_from_basis_core(c.var(), j);
}
}
return false;
}
lar_term lar_solver::get_term_to_maximize(unsigned j_or_term) const {
@ -621,6 +629,54 @@ namespace lp {
m_touched_rows.insert(rid);
}
void lar_solver::remove_fixed_vars_from_base() {
// this will allow to disable and restore the tracking of the touched rows
flet<indexed_uint_set*> f(m_mpq_lar_core_solver.m_r_solver.m_touched_rows, nullptr);
unsigned num = A_r().column_count();
unsigned_vector to_remove;
for (unsigned j : m_fixed_base_var_set) {
if (j >= num || !is_base(j) || !is_fixed(j)) {
to_remove.push_back(j);
continue;
}
lp_assert(is_base(j) && is_fixed(j));
auto const& r = basic2row(j);
for (auto const& c : r) {
unsigned j_entering = c.var();
if (!is_fixed(j_entering)) {
pivot(j_entering, j);
to_remove.push_back(j);
lp_assert(is_base(j_entering));
break;
}
}
}
for (unsigned j : to_remove) {
m_fixed_base_var_set.remove(j);
}
lp_assert(fixed_base_removed_correctly());
}
#ifdef Z3DEBUG
bool lar_solver::fixed_base_removed_correctly() const {
for (unsigned i = 0; i < A_r().row_count(); i++) {
unsigned j = get_base_column_in_row(i);
if (column_is_fixed(j)) {
for (const auto & c : A_r().m_rows[i] ) {
if (!column_is_fixed(c.var())) {
TRACE("lar_solver", print_row(A_r().m_rows[i], tout) << "\n";
for(const auto & c : A_r().m_rows[i]) {
print_column_info(c.var(), tout) << "\n";
});
return false;
}
}
}
}
return true;
}
#endif
bool lar_solver::use_tableau_costs() const {
return m_settings.simplex_strategy() == simplex_strategy_enum::tableau_costs;
}
@ -1726,6 +1782,10 @@ namespace lp {
update_column_type_and_bound_with_ub(j, kind, right_side, constr_index);
else
update_column_type_and_bound_with_no_ub(j, kind, right_side, constr_index);
if (is_base(j) && column_is_fixed(j)) {
m_fixed_base_var_set.insert(j);
}
TRACE("lar_solver_feas", tout << "j = " << j << " became " << (this->column_is_feasible(j)?"feas":"non-feas") << ", and " << (this->column_is_bounded(j)? "bounded":"non-bounded") << std::endl;);
}
void lar_solver::insert_to_columns_with_changed_bounds(unsigned j) {