Skip to content

Commit

Permalink
Merge pull request #2040 from fwesselm/signErrors
Browse files Browse the repository at this point in the history
Fix incorrect bound checks
  • Loading branch information
jajhall authored Nov 18, 2024
2 parents 4856a65 + 7579a7f commit 5115f46
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/presolve/HPresolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ bool HPresolve::isImpliedInteger(HighsInt col) {

if ((model->col_lower_[col] != -kHighsInf &&
fractionality(model->col_lower_[col]) > options->small_matrix_value) ||
(model->col_upper_[col] != -kHighsInf &&
(model->col_upper_[col] != kHighsInf &&
fractionality(model->col_upper_[col]) > options->small_matrix_value))
return false;

Expand Down Expand Up @@ -2356,7 +2356,7 @@ void HPresolve::scaleStoredRow(HighsInt row, double scale, bool integral) {
if (integral) {
if (model->row_upper_[row] != kHighsInf)
model->row_upper_[row] = std::round(model->row_upper_[row]);
if (model->row_lower_[row] != kHighsInf)
if (model->row_lower_[row] != -kHighsInf)
model->row_lower_[row] = std::round(model->row_lower_[row]);
}

Expand Down Expand Up @@ -5491,17 +5491,21 @@ HPresolve::Result HPresolve::detectParallelRowsAndCols(
// compensating column is integral
bool checkColImplBounds = true;
bool checkDuplicateColImplBounds = true;
auto isLowerStrictlyImplied = [&](HighsInt col) {
return (model->col_lower_[col] == -kHighsInf ||
implColLower[col] > model->col_lower_[col] + primal_feastol);
};
auto isUpperStrictlyImplied = [&](HighsInt col) {
return (model->col_upper_[col] == kHighsInf ||
implColUpper[col] < model->col_upper_[col] - primal_feastol);
};
auto colUpperInf = [&]() {
if (!checkColImplBounds) return false;
if (mipsolver == nullptr) {
// for LP we check strict redundancy of the bounds as otherwise dual
// postsolve might fail when the bound is used in the optimal solution
return colScale > 0 ? model->col_upper_[col] == kHighsInf ||
implColUpper[col] <
model->col_upper_[col] - primal_feastol
: model->col_lower_[col] == -kHighsInf ||
implColLower[col] >
model->col_lower_[col] + primal_feastol;
return colScale > 0 ? isUpperStrictlyImplied(col)
: isLowerStrictlyImplied(col);
} else {
// for MIP we do not need dual postsolve so the reduction is valid if
// the bound is weakly redundant
Expand All @@ -5512,12 +5516,8 @@ HPresolve::Result HPresolve::detectParallelRowsAndCols(
auto colLowerInf = [&]() {
if (!checkColImplBounds) return false;
if (mipsolver == nullptr) {
return colScale > 0 ? model->col_lower_[col] == -kHighsInf ||
implColLower[col] >
model->col_lower_[col] + primal_feastol
: model->col_upper_[col] == kHighsInf ||
implColUpper[col] <
model->col_upper_[col] - primal_feastol;
return colScale > 0 ? isLowerStrictlyImplied(col)
: isUpperStrictlyImplied(col);
} else {
return colScale > 0 ? isLowerImplied(col) : isUpperImplied(col);
}
Expand All @@ -5526,9 +5526,7 @@ HPresolve::Result HPresolve::detectParallelRowsAndCols(
auto duplicateColUpperInf = [&]() {
if (!checkDuplicateColImplBounds) return false;
if (mipsolver == nullptr) {
return model->col_upper_[duplicateCol] == kHighsInf ||
implColUpper[duplicateCol] <
model->col_upper_[duplicateCol] - primal_feastol;
return isUpperStrictlyImplied(duplicateCol);
} else {
return isUpperImplied(duplicateCol);
}
Expand All @@ -5537,9 +5535,7 @@ HPresolve::Result HPresolve::detectParallelRowsAndCols(
auto duplicateColLowerInf = [&]() {
if (!checkDuplicateColImplBounds) return false;
if (mipsolver == nullptr) {
return model->col_lower_[duplicateCol] == -kHighsInf ||
implColLower[duplicateCol] >
model->col_lower_[duplicateCol] + primal_feastol;
return isLowerStrictlyImplied(duplicateCol);
} else {
return isLowerImplied(duplicateCol);
}
Expand Down Expand Up @@ -5608,7 +5604,7 @@ HPresolve::Result HPresolve::detectParallelRowsAndCols(
// incorporate the check for the variable types that allow domination.
if (objDiff < -options->dual_feasibility_tolerance) {
// scaled col is better than duplicate col
if (colUpperInf() && model->col_lower_[duplicateCol] != kHighsInf)
if (colUpperInf() && model->col_lower_[duplicateCol] != -kHighsInf)
reductionCase = kDominanceDuplicateColToLower;
else if (duplicateColLowerInf() &&
(colScale < 0 || model->col_upper_[col] != kHighsInf) &&
Expand Down

0 comments on commit 5115f46

Please sign in to comment.