Skip to content

Commit 74a4c23

Browse files
committed
Fix bug where local domain change not repr
1 parent 32536dd commit 74a4c23

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

highs/mip/HighsTransformedLp.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,15 @@ bool HighsTransformedLp::transformSNFRelaxation(
589589
: lprelaxation.slackUpper(col - slackOffset));
590590
};
591591

592+
auto colIsBinary = [&](const HighsInt col, const double lb, const double ub) {
593+
// Check local domain too. Global domain change may not yet be reflected
594+
if (lprelaxation.isColIntegral(col) && lb == 0 && ub == 1 &&
595+
lprelaxation.colLower(col) >= 0 && lprelaxation.colUpper(col) <= 1) {
596+
return true;
597+
}
598+
return false;
599+
};
600+
592601
auto getLpSolution = [&](HighsInt col) {
593602
HighsInt numCols = lprelaxation.numCols();
594603
if (col < numCols) {
@@ -664,7 +673,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
664673
HighsInt col = inds[i];
665674
double lb = getLb(col);
666675
double ub = getUb(col);
667-
if (lprelaxation.isColIntegral(col) && lb == 0 && ub == 1) {
676+
if (colIsBinary(col, lb, ub)) {
668677
numBinCols++;
669678
snfr.origBinColCoef[col] = vals[i];
670679
std::swap(inds[i], inds[numNz - numBinCols]);
@@ -684,7 +693,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
684693
if (ub - lb < mip.options_mip_->small_matrix_value) {
685694
rhs -= std::min(lb, ub) * vals[i];
686695
tmpSnfrRhs -= std::min(lb, ub) * vals[i];
687-
if (lprelaxation.isColIntegral(col) && lb == 0 && ub == 1) {
696+
if (colIsBinary(col, lb, ub)) {
688697
snfr.origBinColCoef[col] = 0;
689698
}
690699
remove(i);
@@ -726,7 +735,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
726735
}
727736

728737
// Transform entry into the SNFR
729-
if (lprelaxation.isColIntegral(col) && lb == 0 && ub == 1) {
738+
if (colIsBinary(col, lb, ub)) {
730739
if (snfr.binColUsed[col] == false) {
731740
if (vals[i] >= 0) {
732741
addSNFRentry(col, -1, getLpSolution(col),
@@ -874,8 +883,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
874883

875884
// Remove slack, small coefficients, and calculate the efficacy
876885
bool HighsTransformedLp::cleanup(std::vector<HighsInt>& inds,
877-
std::vector<double>& vals,
878-
double& rhs,
886+
std::vector<double>& vals, double& rhs,
879887
double& efficacy) {
880888
HighsCDouble tmpRhs = rhs;
881889
const HighsMipSolver& mip = lprelaxation.getMipSolver();
@@ -942,11 +950,11 @@ bool HighsTransformedLp::cleanup(std::vector<HighsInt>& inds,
942950
double sqrnorm = 0;
943951
const std::vector<double>& lpSolution = lprelaxation.getSolution().col_value;
944952
for (HighsInt i = 0; i != numNz; ++i) {
945-
if (vals[i] >= 0 && lpSolution[i] <=
946-
mip.mipdata_->domain.col_lower_[i] + mip.mipdata_->feastol)
953+
if (vals[i] >= 0 && lpSolution[i] <= mip.mipdata_->domain.col_lower_[i] +
954+
mip.mipdata_->feastol)
947955
continue;
948-
if (vals[i] < 0 && lpSolution[i] >=
949-
mip.mipdata_->domain.col_upper_[i] - mip.mipdata_->feastol)
956+
if (vals[i] < 0 && lpSolution[i] >= mip.mipdata_->domain.col_upper_[i] -
957+
mip.mipdata_->feastol)
950958
continue;
951959
viol += vals[i] * lpSolution[i];
952960
sqrnorm += vals[i] * vals[i];

0 commit comments

Comments
 (0)