3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +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 4c23527974
commit b21741cccd
2 changed files with 10 additions and 5 deletions

View file

@ -479,6 +479,7 @@ public:
void change_basis(unsigned entering, unsigned leaving) {
lean_assert(m_basis_heading[entering] < 0);
lean_assert(m_basis_heading[leaving] >= 0);
int place_in_basis = m_basis_heading[leaving];
int place_in_non_basis = - m_basis_heading[entering] - 1;

View file

@ -925,7 +925,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
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);
if (m_settings.m_simplex_strategy == simplex_strategy_enum::lu) {
if (m_factorization->need_to_refactor()) {
@ -940,15 +942,16 @@ template <typename T, typename X> bool lp_core_solver_base<T, X>::pivot_column_g
return false;
}
} 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() {
// run over basis and non-basis at the same time
indexed_vector<T> w(m_basis.size()); // the buffer
unsigned i = 0; // points to basis
unsigned j = 0; // points to nonbasis
for (; i < m_basis.size() && j < m_nbasis.size(); i++) {
unsigned ii = m_basis[i];
unsigned jj;
@ -963,8 +966,9 @@ template <typename T, typename X> void lp_core_solver_base<T, X>::pivot_fixed_v
if (j >= m_nbasis.size())
break;
j++;
if (!pivot_column_general(jj, ii, w))
break;
if (!pivot_column_general(jj, ii, w))
return; // total failure
break;
}
}
}