dev(lp): performance tuning in find_leaving_on_harris_theta
Signed-off-by: Lev Nachmanson <levnach@microsoft.com>
This commit is contained in:
parent
d098dfe326
commit
99dcad0dda
4 changed files with 8 additions and 49 deletions
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
namespace lean {
|
||||
template <typename T, typename X> class lp_core_solver_base; // forward definition
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
namespace lean {
|
||||
|
||||
// This is the sum of a unit matrix and a one-column matrix
|
||||
|
|
|
@ -148,7 +148,6 @@ public: // todo : move public lower ; it is for debug only
|
|||
|
||||
int find_leaving_on_harris_theta(X const & harris_theta, X & t) {
|
||||
int leaving = -1;
|
||||
int leaving_fixed = -1; // we would like to get rid of fixed columns in the basis first because they might bring t to zero
|
||||
T pivot_abs_max;
|
||||
T pivot_abs_max_fixed;
|
||||
// we know already that there is no bound flip on entering
|
||||
|
@ -167,7 +166,7 @@ public: // todo : move public lower ; it is for debug only
|
|||
unsigned j = this->m_basis[i];
|
||||
limit_theta_on_basis_column(j, - this->m_ed[i] * m_sign_of_entering_delta, ratio);
|
||||
if (ratio <= harris_theta) {
|
||||
if (get_current_x_is_infeasible() && !m_recalc_reduced_costs) { // when we have made several basic variables feasible then we need to recalculate the costs and the reduced costs: here we are catching this case
|
||||
if (!m_recalc_reduced_costs && get_current_x_is_infeasible()) { // when we have made several basic variables feasible we need to recalculate the costs and the reduced costs: here we are catching this case
|
||||
if (!is_zero(this->m_costs[j])) {
|
||||
if (column_with_non_zero_cost != -1)
|
||||
m_recalc_reduced_costs = true;
|
||||
|
@ -179,28 +178,12 @@ public: // todo : move public lower ; it is for debug only
|
|||
t = ratio;
|
||||
leaving = j;
|
||||
pivot_abs_max = abs(this->m_ed[i]);
|
||||
if (this->m_column_type[j] == fixed) {
|
||||
leaving_fixed = j;
|
||||
pivot_abs_max_fixed = pivot_abs_max;
|
||||
}
|
||||
} else if (this->m_column_type[j] == fixed) {
|
||||
if (leaving_fixed == -1 || abs(this->m_ed[i]) > pivot_abs_max_fixed) {
|
||||
pivot_abs_max_fixed = abs(this->m_ed[i]);
|
||||
leaving_fixed = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (++i == this->m_m) i = 0;
|
||||
} while ( i != initial_i);
|
||||
restore_harris_eps();
|
||||
// if (m_j_uht.size() > 1) {
|
||||
// cout << "under set " << std::endl;
|
||||
// for(auto j : m_j_uht)
|
||||
// print_column(j);
|
||||
// // }
|
||||
// cout << "done with under set" << std::endl;
|
||||
return leaving; // debug
|
||||
// return leaving_fixed != -1 ? leaving_fixed : leaving;
|
||||
return leaving;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -230,12 +230,12 @@ public:
|
|||
solve_with_total_inf();
|
||||
}
|
||||
|
||||
void fill_A_x_and_basis_for_stage_on_total_inf() {
|
||||
void fill_A_x_and_basis_for_stage_one_total_inf() {
|
||||
for (unsigned row = 0; row < this->row_count(); row++)
|
||||
fill_A_x_and_basis_for_stage_on_total_inf_for_row(row);
|
||||
fill_A_x_and_basis_for_stage_one_total_inf_for_row(row);
|
||||
}
|
||||
|
||||
void fill_A_x_and_basis_for_stage_on_total_inf_for_row(unsigned row) {
|
||||
void fill_A_x_and_basis_for_stage_one_total_inf_for_row(unsigned row) {
|
||||
lean_assert(row < this->row_count());
|
||||
auto ext_row_it = this->m_core_solver_rows_to_external_rows.find(row);
|
||||
lean_assert(ext_row_it != this->m_core_solver_rows_to_external_rows.end());
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
this->m_basis.resize(this->row_count());
|
||||
this->m_costs.clear();
|
||||
this->m_costs.resize(total_vars, zero_of_type<T>());
|
||||
fill_A_x_and_basis_for_stage_on_total_inf();
|
||||
fill_A_x_and_basis_for_stage_one_total_inf();
|
||||
this->print_statistics_on_A();
|
||||
this->fill_column_names_for_core_solver();
|
||||
int j = this->m_A->column_count() - 1;
|
||||
|
@ -304,32 +304,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
// void stage_one_of_total_inf() {
|
||||
// std::cout << "starting stage_one_of_total_inf()" << std::endl;
|
||||
// int total_vars = this->m_A->column_count() + this->row_count();
|
||||
// m_low_bounds.clear();
|
||||
// m_low_bounds.resize(total_vars, zero_of_type<X>()); // low bounds are shifted ot zero
|
||||
// this->m_x.resize(total_vars, numeric_traits<T>::zero());
|
||||
// this->m_basis.resize(this->row_count());
|
||||
// this->m_costs.clear();
|
||||
// this->m_costs.resize(total_vars, zero_of_type<T>());
|
||||
// fill_A_x_and_basis_for_stage_on_total_inf();
|
||||
// this->print_statistics_on_A();
|
||||
// this->fill_column_names_for_core_solver();
|
||||
// m_core_solver = new lp_primal_core_solver<T, X>(*this->m_A,
|
||||
// this->m_b,
|
||||
// this->m_x,
|
||||
// this->m_basis,
|
||||
// this->m_costs,
|
||||
// this->m_column_types,
|
||||
// m_low_bounds,
|
||||
// this->m_upper_bounds,
|
||||
// this->m_settings, this->m_name_map);
|
||||
// m_core_solver->find_feasible_solution();
|
||||
// this->m_first_stage_iterations = m_core_solver->m_total_iterations;
|
||||
// this->m_status = m_core_solver->m_status == lp_status::OPTIMAL? lp_status::FEASIBLE: m_core_solver->m_status; // just map FEASIBLE to OPTIMAL and do not change the rest
|
||||
// }
|
||||
|
||||
~lp_primal_simplex() {
|
||||
if (m_core_solver != nullptr) {
|
||||
delete m_core_solver;
|
||||
|
|
Loading…
Reference in a new issue