Skip to content

Commit

Permalink
rm lu
Browse files Browse the repository at this point in the history
Signed-off-by: Lev Nachmanson <[email protected]>
  • Loading branch information
levnach committed Mar 8, 2023
1 parent bfe73c0 commit 6132bf9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 69 deletions.
1 change: 0 additions & 1 deletion src/math/lp/lp_core_solver_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ template lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::lp_core_s
const vector<lp::numeric_pair<lp::mpq> >&,
const vector<lp::numeric_pair<lp::mpq> >&);
template bool lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::print_statistics_with_cost_and_check_that_the_time_is_over(lp::numeric_pair<lp::mpq>, std::ostream&);
template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::snap_xN_to_bounds_and_fill_xB();
template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::solve_Ax_eq_b();

template void lp::lp_core_solver_base<lp::mpq, lp::numeric_pair<lp::mpq> >::add_delta_to_entering(unsigned int, const lp::numeric_pair<lp::mpq>&);
Expand Down
7 changes: 2 additions & 5 deletions src/math/lp/lp_core_solver_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class lp_core_solver_base {
vector<X> & m_x; // a feasible solution, the fist time set in the constructor
vector<T> & m_costs;
lp_settings & m_settings;
lu<static_matrix<T, X>> * m_factorization = nullptr;

vector<T> m_y; // the buffer for yB = cb
// a device that is able to solve Bx=c, xB=d, and change the basis
const column_namer & m_column_names;
Expand Down Expand Up @@ -134,7 +134,7 @@ class lp_core_solver_base {
void init();

virtual ~lp_core_solver_base() {
delete m_factorization;

}

vector<unsigned> & non_basis() {
Expand Down Expand Up @@ -413,9 +413,6 @@ class lp_core_solver_base {
}


void snap_non_basic_x_to_bound_and_free_to_zeroes();
void snap_xN_to_bounds_and_fill_xB();


non_basic_column_value_position get_non_basic_column_value_position(unsigned j) const;

Expand Down
46 changes: 1 addition & 45 deletions src/math/lp/lp_core_solver_base_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,52 +554,8 @@ find_error_in_BxB(vector<X>& rs){
// recalculates the projection of x to B, such that Ax = b
template <typename T, typename X> void lp_core_solver_base<T, X>::
solve_Ax_eq_b() {
if (numeric_traits<X>::precise()) {
vector<X> rs(m_m());
rs_minus_Anx(rs);
m_factorization->solve_By(rs);
copy_rs_to_xB(rs);
}
else {
vector<X> rs(m_m());
rs_minus_Anx(rs);
vector<X> rrs = rs; // another copy of rs
m_factorization->solve_By(rs);
copy_rs_to_xB(rs);
find_error_in_BxB(rrs);
m_factorization->solve_By(rrs);
add_delta_to_xB(rrs);
}
}




template <typename T, typename X> void lp_core_solver_base<T, X>::
snap_non_basic_x_to_bound_and_free_to_zeroes() {
for (unsigned j : non_basis()) {
lp_assert(j < m_x.size());
switch (m_column_types[j]) {
case column_type::fixed:
case column_type::boxed:
case column_type::lower_bound:
m_x[j] = m_lower_bounds[j];
break;
case column_type::upper_bound:
m_x[j] = m_upper_bounds[j];
break;
default:
m_x[j] = zero_of_type<X>();
break;
}
}
lp_assert(false);
}
template <typename T, typename X> void lp_core_solver_base<T, X>::
snap_xN_to_bounds_and_fill_xB() {
snap_non_basic_x_to_bound();
solve_Ax_eq_b();
}



template <typename T, typename X> non_basic_column_value_position lp_core_solver_base<T, X>::
Expand Down
21 changes: 3 additions & 18 deletions src/math/lp/lp_primal_core_solver_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_run(


template <typename T, typename X> void lp_primal_core_solver<T, X>::calc_working_vector_beta_for_column_norms(){
lp_assert(numeric_traits<T>::precise() == false);
lp_assert(this->m_ed.is_OK());
lp_assert(m_beta.is_OK());
m_beta = this->m_ed;
this->m_factorization->solve_yB_with_error_check_indexed(m_beta, this->m_basis_heading, this->m_basis, this->m_settings);
lp_assert(false);
}

template <typename T, typename X>
Expand Down Expand Up @@ -758,10 +754,7 @@ template <typename T, typename X> unsigned lp_primal_core_solver<T, X>::solve()
}

template <typename T, typename X> void lp_primal_core_solver<T, X>::delete_factorization() {
if (this->m_factorization != nullptr) {
delete this->m_factorization;
this->m_factorization = nullptr;
}
lp_assert(false);
}

// according to Swietanowski, " A new steepest edge approximation for the simplex method for linear programming"
Expand All @@ -776,15 +769,7 @@ template <typename T, typename X> void lp_primal_core_solver<T, X>::init_column_

// debug only
template <typename T, typename X> T lp_primal_core_solver<T, X>::calculate_column_norm_exactly(unsigned j) {
lp_assert(numeric_traits<T>::precise() == false);
indexed_vector<T> w(this->m_m());
this->m_A.copy_column_to_vector(j, w);
vector<T> d(this->m_m());
this->m_factorization->solve_Bd_when_w_is_ready(d, w);
T ret = zero_of_type<T>();
for (auto v : d)
ret += v*v;
return ret+1;
lp_assert(false);
}

template <typename T, typename X> void lp_primal_core_solver<T, X>::update_or_init_column_norms(unsigned entering, unsigned leaving) {
Expand Down

0 comments on commit 6132bf9

Please sign in to comment.