3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 21:03:39 +00:00

fix a bug in pivot_fixed_vars_from_basis

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2017-07-06 10:53:32 -07:00
parent 8bd029c657
commit 9eb82815e2
2 changed files with 15 additions and 3 deletions

View file

@ -493,6 +493,7 @@ public:
} }
void change_basis(unsigned entering, unsigned leaving) { void change_basis(unsigned entering, unsigned leaving) {
SASSERT(m_basis_heading[entering] < 0); SASSERT(m_basis_heading[entering] < 0);
int place_in_basis = m_basis_heading[leaving]; int place_in_basis = m_basis_heading[leaving];

View file

@ -940,7 +940,9 @@ template <typename T, typename X> void lp_core_solver_base<T, X>::transpose_row
} }
// j is the new basic column, j_basic - the leaving column // j is the new basic column, j_basic - the leaving column
template <typename T, typename X> bool lp_core_solver_base<T, X>::pivot_column_general(unsigned j, unsigned j_basic, indexed_vector<T> & w) { template <typename T, typename X> bool lp_core_solver_base<T, X>::pivot_column_general(unsigned j, unsigned j_basic, indexed_vector<T> & w) {
unsigned row_index = m_basis_heading[j_basic]; lean_assert(m_basis_heading[j] < 0);
lean_assert(m_basis_heading[j_basic] >= 0);
unsigned row_index = m_basis_heading[j_basic];
change_basis(j, j_basic); change_basis(j, j_basic);
if (m_settings.m_simplex_strategy == simplex_strategy_enum::lu) { if (m_settings.m_simplex_strategy == simplex_strategy_enum::lu) {
if (m_factorization->need_to_refactor()) { if (m_factorization->need_to_refactor()) {
@ -955,15 +957,16 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::pivot_column_g
return false; return false;
} }
} else { // the tableau case } else { // the tableau case
pivot_column_tableau(j, row_index); return pivot_column_tableau(j, row_index);
} }
return true;
} }
template <typename T, typename X> void lp_core_solver_base<T, X>::pivot_fixed_vars_from_basis() { template <typename T, typename X> void lp_core_solver_base<T, X>::pivot_fixed_vars_from_basis() {
// run over basis and non-basis at the same time // run over basis and non-basis at the same time
indexed_vector<T> w(m_basis.size()); // the buffer indexed_vector<T> w(m_basis.size()); // the buffer
unsigned i = 0; // points to basis unsigned i = 0; // points to basis
unsigned j = 0; // points to nonbasis unsigned j = 0; // points to nonbasis
for (; i < m_basis.size() && j < m_nbasis.size(); i++) { for (; i < m_basis.size() && j < m_nbasis.size(); i++) {
unsigned ii = m_basis[i]; unsigned ii = m_basis[i];
unsigned jj; unsigned jj;
@ -978,11 +981,19 @@ template <typename T, typename X> void lp_core_solver_base<T, X>::pivot_fixed_v
if (j >= m_nbasis.size()) if (j >= m_nbasis.size())
break; break;
j++; j++;
<<<<<<< a4275bb735828a40f94571cae4765f8be8225423
if (!pivot_column_general(jj, ii, w)) if (!pivot_column_general(jj, ii, w))
break; break;
} }
} }
SASSERT(m_factorization->get_status()== LU_status::OK); SASSERT(m_factorization->get_status()== LU_status::OK);
=======
if (!pivot_column_general(jj, ii, w))
return; // total failure
break;
}
}
>>>>>>> fix a bug in pivot_fixed_vars_from_basis
} }
template <typename T, typename X> bool template <typename T, typename X> bool