Skip to content

Commit 774ef56

Browse files
committed
Add lambda
1 parent 06ab636 commit 774ef56

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

highs/presolve/HPresolve.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,18 @@ HPresolve::Result HPresolve::dominatedColumns(
12411241
};
12421242

12431243
if (colIsBinary) {
1244+
auto binaryCanBeFixed = [&](HighsInt col, HighsInt k, double bestVal,
1245+
double val, HighsInt direction,
1246+
HighsInt multiplier, bool isEqOrRangedRow) {
1247+
HighsInt mydirection = multiplier * direction;
1248+
return direction * bestVal <=
1249+
mydirection * val + options->small_matrix_value &&
1250+
(!isEqOrRangedRow ||
1251+
direction * bestVal >=
1252+
mydirection * val - options->small_matrix_value) &&
1253+
checkDomination(direction, col, mydirection, k);
1254+
};
1255+
12441256
auto checkFixCol = [&](HighsInt row, HighsInt col, HighsInt direction,
12451257
double scale, double bestVal) {
12461258
storeRow(row);
@@ -1253,18 +1265,10 @@ HPresolve::Result HPresolve::dominatedColumns(
12531265

12541266
double ak = nonz.value() * scale;
12551267

1256-
if ((direction * bestVal <=
1257-
direction * ak + options->small_matrix_value &&
1258-
(!isEqOrRangedRow ||
1259-
direction * bestVal >=
1260-
direction * ak - options->small_matrix_value) &&
1261-
checkDomination(direction, col, direction, k)) ||
1262-
(direction * bestVal <=
1263-
-direction * ak + options->small_matrix_value &&
1264-
(!isEqOrRangedRow ||
1265-
direction * bestVal >=
1266-
-direction * ak - options->small_matrix_value) &&
1267-
checkDomination(direction, col, -direction, k))) {
1268+
if (binaryCanBeFixed(col, k, bestVal, ak, direction, HighsInt{1},
1269+
isEqOrRangedRow) ||
1270+
binaryCanBeFixed(col, k, bestVal, ak, direction, HighsInt{-1},
1271+
isEqOrRangedRow)) {
12681272
// direction = 1: fix binary variable to one
12691273
// direction = -1: fix binary variable to zero
12701274
++numFixedCols;

0 commit comments

Comments
 (0)