Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect bound checks #2040

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading