Skip to content

Commit ea19846

Browse files
committed
Updated PR with respect to comments of @fwesselm
1 parent 6fa6097 commit ea19846

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

highs/lp_data/HighsSolution.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ void getVariableKktFailures(const double primal_feasibility_tolerance,
554554
// as the primal infeasibility, ensuring (cf #2653) that it doesn't
555555
// exceed the primal feasibility tolerance if the standard primal
556556
// infeasibility (ie infeasibility exceeding the tolerance) is zero
557-
std::pair<double, double> infeasibility_residual =
558-
infeasibility(&lower, &value, &upper, &primal_feasibility_tolerance);
557+
auto infeasibility_residual =
558+
infeasibility(lower, value, upper, primal_feasibility_tolerance);
559559
primal_infeasibility = infeasibility_residual.second;
560560
// Determine whether this value is close to a bound
561561
at_status = kHighsSolutionNo;

highs/util/HighsUtils.h

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -215,41 +215,27 @@ inline T fractionality(T input, T* intval = nullptr) {
215215
return abs(input - val);
216216
}
217217

218-
inline std::pair<double, double> infeasibility(const double* lower,
219-
const double* value,
220-
const double* upper,
221-
const double* tolerance) {
218+
inline std::pair<double, double> infeasibility(const double lower,
219+
const double value,
220+
const double upper,
221+
const double tolerance) {
222222
using std::fabs;
223223
using std::min;
224224
double residual = 0;
225225
double infeasibility = 0;
226-
std::string bound_type = "";
227-
double bound_value = 0;
228226
// Determine the infeasibility exceeding the tolerance used in
229-
// computing the number of infeasibilities - which defines
230-
// feasibility of a solution
227+
// computing the number of infeasibilities in a basic solution -
228+
// which defines its feasibility
231229
//
232230
// @primal_infeasibility calculation
233-
if (*value < *lower - *tolerance) {
234-
infeasibility = *lower - *value;
235-
}
236-
if (*value > *upper + *tolerance) {
237-
infeasibility = *value - *upper;
238-
}
231+
if (value < lower - tolerance) infeasibility = lower - value;
232+
if (value > upper + tolerance) infeasibility = value - upper;
239233
// Determine the residual used in computing the sum of
240234
// infeasibilities and max infeasibility - which are just for
241235
// reporting
242-
if (*tolerance > 0) {
243-
if (*value < *lower) {
244-
bound_type = "LB";
245-
bound_value = *lower;
246-
residual = *lower - *value;
247-
}
248-
if (*value > *upper) {
249-
bound_type = "UB";
250-
bound_value = *upper;
251-
residual = *value - *upper;
252-
}
236+
if (tolerance > 0) {
237+
if (value < lower) residual = lower - value;
238+
if (value > upper) residual = value - upper;
253239
} else {
254240
residual = infeasibility;
255241
}
@@ -279,7 +265,7 @@ inline std::pair<double, double> infeasibility(const double* lower,
279265
// so that values of maximum infeasibility defined by residual
280266
// doesn't exceed the tolerance
281267
//
282-
if (infeasibility == 0) residual = min(residual, *tolerance);
268+
if (infeasibility == 0) residual = min(residual, tolerance);
283269
return std::make_pair(infeasibility, residual);
284270
}
285271
#endif // UTIL_HIGHSUTILS_H_

0 commit comments

Comments
 (0)