Skip to content

Commit

Permalink
simplify the jump on entering
Browse files Browse the repository at this point in the history
  • Loading branch information
levnach committed Nov 2, 2023
1 parent bdf1fcf commit 08d3a82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/math/lp/lp_primal_core_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ namespace lp {
return rc.var();
}

bool try_jump_to_another_bound_on_entering(unsigned entering, const X &theta, X &t, bool &unlimited);
bool try_jump_to_another_bound_on_entering(unsigned entering, X &t);

bool try_jump_to_another_bound_on_entering_unlimited(unsigned entering, X &t);

Expand Down
47 changes: 8 additions & 39 deletions src/math/lp/lp_primal_core_solver_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,48 +98,17 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis(unsign
}
return false;
}

template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_another_bound_on_entering(unsigned entering,
const X & theta,
X & t,
bool & unlimited) {
switch(this->m_column_types[entering]){
case column_type::boxed:
if (m_sign_of_entering_delta > 0) {
t = this->m_upper_bounds[entering] - this->m_x[entering];
if (unlimited || t <= theta){
lp_assert(t >= zero_of_type<X>());
return true;
}
} else { // m_sign_of_entering_delta == -1
t = this->m_x[entering] - this->m_lower_bounds[entering];
if (unlimited || t <= theta) {
lp_assert(t >= zero_of_type<X>());
return true;
}
}
return false;
case column_type::upper_bound:
if (m_sign_of_entering_delta > 0) {
t = this->m_upper_bounds[entering] - this->m_x[entering];
if (unlimited || t <= theta){
lp_assert(t >= zero_of_type<X>());
return true;
}
}
return false;
case column_type::lower_bound:
if (m_sign_of_entering_delta < 0) {
t = this->m_x[entering] - this->m_lower_bounds[entering];
if (unlimited || t <= theta) {
lp_assert(t >= zero_of_type<X>());
return true;
}
}
// we assume that the columns are at their bounds
template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_another_bound_on_entering(unsigned entering, X & theta) {
if (this->m_column_types[entering] != column_type::boxed)
return false;
default:return false;
X t = this->m_upper_bounds[entering] - this->m_lower_bounds[entering];
if (t <= theta) {
theta = t;
return true;
}
return false;

}

template <typename T, typename X> bool lp_primal_core_solver<T, X>::
Expand Down
5 changes: 1 addition & 4 deletions src/math/lp/lp_primal_core_solver_tableau_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
}
}

ratio = t;
unlimited = false;
if (try_jump_to_another_bound_on_entering(entering, t, ratio, unlimited)) {
t = ratio;
if (try_jump_to_another_bound_on_entering(entering, t)) {
return entering;
}
if (m_leaving_candidates.size() == 1)
Expand Down

0 comments on commit 08d3a82

Please sign in to comment.