Skip to content

Commit 08d3a82

Browse files
committed
simplify the jump on entering
1 parent bdf1fcf commit 08d3a82

File tree

3 files changed

+10
-44
lines changed

3 files changed

+10
-44
lines changed

src/math/lp/lp_primal_core_solver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ namespace lp {
231231
return rc.var();
232232
}
233233

234-
bool try_jump_to_another_bound_on_entering(unsigned entering, const X &theta, X &t, bool &unlimited);
234+
bool try_jump_to_another_bound_on_entering(unsigned entering, X &t);
235235

236236
bool try_jump_to_another_bound_on_entering_unlimited(unsigned entering, X &t);
237237

src/math/lp/lp_primal_core_solver_def.h

+8-39
Original file line numberDiff line numberDiff line change
@@ -98,48 +98,17 @@ bool lp_primal_core_solver<T, X>::column_is_benefitial_for_entering_basis(unsign
9898
}
9999
return false;
100100
}
101-
102-
template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_another_bound_on_entering(unsigned entering,
103-
const X & theta,
104-
X & t,
105-
bool & unlimited) {
106-
switch(this->m_column_types[entering]){
107-
case column_type::boxed:
108-
if (m_sign_of_entering_delta > 0) {
109-
t = this->m_upper_bounds[entering] - this->m_x[entering];
110-
if (unlimited || t <= theta){
111-
lp_assert(t >= zero_of_type<X>());
112-
return true;
113-
}
114-
} else { // m_sign_of_entering_delta == -1
115-
t = this->m_x[entering] - this->m_lower_bounds[entering];
116-
if (unlimited || t <= theta) {
117-
lp_assert(t >= zero_of_type<X>());
118-
return true;
119-
}
120-
}
121-
return false;
122-
case column_type::upper_bound:
123-
if (m_sign_of_entering_delta > 0) {
124-
t = this->m_upper_bounds[entering] - this->m_x[entering];
125-
if (unlimited || t <= theta){
126-
lp_assert(t >= zero_of_type<X>());
127-
return true;
128-
}
129-
}
130-
return false;
131-
case column_type::lower_bound:
132-
if (m_sign_of_entering_delta < 0) {
133-
t = this->m_x[entering] - this->m_lower_bounds[entering];
134-
if (unlimited || t <= theta) {
135-
lp_assert(t >= zero_of_type<X>());
136-
return true;
137-
}
138-
}
101+
// we assume that the columns are at their bounds
102+
template <typename T, typename X> bool lp_primal_core_solver<T, X>::try_jump_to_another_bound_on_entering(unsigned entering, X & theta) {
103+
if (this->m_column_types[entering] != column_type::boxed)
139104
return false;
140-
default:return false;
105+
X t = this->m_upper_bounds[entering] - this->m_lower_bounds[entering];
106+
if (t <= theta) {
107+
theta = t;
108+
return true;
141109
}
142110
return false;
111+
143112
}
144113

145114
template <typename T, typename X> bool lp_primal_core_solver<T, X>::

src/math/lp/lp_primal_core_solver_tableau_def.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ template <typename T, typename X> int lp_primal_core_solver<T, X>::find_leaving_
246246
}
247247
}
248248

249-
ratio = t;
250-
unlimited = false;
251-
if (try_jump_to_another_bound_on_entering(entering, t, ratio, unlimited)) {
252-
t = ratio;
249+
if (try_jump_to_another_bound_on_entering(entering, t)) {
253250
return entering;
254251
}
255252
if (m_leaving_candidates.size() == 1)

0 commit comments

Comments
 (0)