Skip to content

Commit 2fb5d47

Browse files
authored
Merge pull request #2373 from ERGO-Code/fix-2326
Fix 2326
2 parents 2e93732 + d8d4964 commit 2fb5d47

File tree

5 files changed

+44
-17
lines changed

5 files changed

+44
-17
lines changed

highs/mip/HighsCliqueTable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ void HighsCliqueTable::extractCliques(
861861
for (HighsInt i = 0; i != nbin; ++i) {
862862
HighsInt bincol = inds[perm[i]];
863863
HighsCDouble impliedub = HighsCDouble(rhs) - vals[perm[i]];
864+
if (implics.getNumVarBounds() >= implics.getMaxVarBounds()) break;
864865
for (HighsInt j = nbin; j != ntotal; ++j) {
865866
HighsInt col = inds[perm[j]];
866867
if (globaldom.isFixed(col)) continue;

highs/mip/HighsImplications.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ void HighsImplications::addVUB(HighsInt col, HighsInt vubcol, double vubcoef,
395395
// assume that VUBs do not have infinite coefficients and infinite constant
396396
// terms since such VUBs effectively evaluate to NaN.
397397
assert(std::abs(vubcoef) != kHighsInf || std::abs(vubconstant) != kHighsInf);
398+
if (numVarBounds >= maxVarBounds) return;
398399

399400
VarBound vub{vubcoef, vubconstant};
400401

@@ -414,14 +415,16 @@ void HighsImplications::addVUB(HighsInt col, HighsInt vubcol, double vubcoef,
414415
currentvub.coef = vubcoef;
415416
currentvub.constant = vubconstant;
416417
}
417-
}
418+
} else
419+
numVarBounds++;
418420
}
419421

420422
void HighsImplications::addVLB(HighsInt col, HighsInt vlbcol, double vlbcoef,
421423
double vlbconstant) {
422424
// assume that VLBs do not have infinite coefficients and infinite constant
423425
// terms since such VLBs effectively evaluate to NaN.
424426
assert(std::abs(vlbcoef) != kHighsInf || std::abs(vlbconstant) != kHighsInf);
427+
if (numVarBounds >= maxVarBounds) return;
425428

426429
VarBound vlb{vlbcoef, vlbconstant};
427430

@@ -442,7 +445,8 @@ void HighsImplications::addVLB(HighsInt col, HighsInt vlbcol, double vlbcoef,
442445
currentvlb.coef = vlbcoef;
443446
currentvlb.constant = vlbconstant;
444447
}
445-
}
448+
} else
449+
numVarBounds++;
446450
}
447451

448452
void HighsImplications::rebuild(HighsInt ncols,
@@ -469,6 +473,7 @@ void HighsImplications::rebuild(HighsInt ncols,
469473
vlbs.shrink_to_fit();
470474
vlbs.resize(ncols);
471475
numImplications = 0;
476+
numVarBounds = 0;
472477
HighsInt oldncols = oldvubs.size();
473478

474479
nextCleanupCall = mipsolver.numNonzero();
@@ -710,6 +715,8 @@ void HighsImplications::cleanupVarbounds(HighsInt col) {
710715
double lb = mipsolver.mipdata_->domain.col_lower_[col];
711716

712717
if (ub == lb) {
718+
numVarBounds -= vlbs.size();
719+
numVarBounds -= vubs.size();
713720
vlbs[col].clear();
714721
vubs[col].clear();
715722
return;
@@ -726,7 +733,10 @@ void HighsImplications::cleanupVarbounds(HighsInt col) {
726733
});
727734

728735
if (!delVbds.empty()) {
729-
for (HighsInt vubCol : delVbds) vubs[col].erase(vubCol);
736+
for (HighsInt vubCol : delVbds) {
737+
vubs[col].erase(vubCol);
738+
numVarBounds--;
739+
}
730740
delVbds.clear();
731741
}
732742

@@ -738,7 +748,10 @@ void HighsImplications::cleanupVarbounds(HighsInt col) {
738748
if (infeasible) return;
739749
});
740750

741-
for (HighsInt vlbCol : delVbds) vlbs[col].erase(vlbCol);
751+
for (HighsInt vlbCol : delVbds) {
752+
vlbs[col].erase(vlbCol);
753+
numVarBounds--;
754+
}
742755
}
743756

744757
void HighsImplications::cleanupVlb(HighsInt col, HighsInt vlbCol,

highs/mip/HighsImplications.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class HighsImplications {
2929
};
3030
std::vector<Implics> implications;
3131
int64_t numImplications;
32+
int64_t numVarBounds;
33+
int64_t maxVarBounds;
3234

3335
bool computeImplications(HighsInt col, bool val);
3436

@@ -63,6 +65,8 @@ class HighsImplications {
6365
vlbs.resize(numcol);
6466
nextCleanupCall = mipsolver.numNonzero();
6567
numImplications = 0;
68+
numVarBounds = 0;
69+
maxVarBounds = 5000000 + 10 * numcol;
6670
}
6771

6872
std::function<void(HighsInt, HighsInt, HighsInt, double)>
@@ -84,6 +88,8 @@ class HighsImplications {
8488
vlbs.clear();
8589
vlbs.shrink_to_fit();
8690
vlbs.resize(numcol);
91+
numVarBounds = 0;
92+
maxVarBounds = 5000000 + 10 * numcol;
8793

8894
nextCleanupCall = mipsolver.numNonzero();
8995
}
@@ -108,6 +114,10 @@ class HighsImplications {
108114
return implications[loc].computed;
109115
}
110116

117+
HighsInt getNumVarBounds() const { return numVarBounds; }
118+
119+
HighsInt getMaxVarBounds() const { return maxVarBounds; }
120+
111121
void addVUB(HighsInt col, HighsInt vubcol, double vubcoef,
112122
double vubconstant);
113123

highs/mip/HighsPrimalHeuristics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ bool HighsPrimalHeuristics::solveSubMip(
155155
if (submipsolver.mipdata_) {
156156
double numUnfixed = mipsolver.mipdata_->integral_cols.size() +
157157
mipsolver.mipdata_->continuous_cols.size();
158-
double adjustmentfactor = submipsolver.numCol() / std::max(1.0, numUnfixed);
158+
double adjustmentfactor =
159+
((1 - fixingRate) * mipsolver.mipdata_->integral_cols.size() +
160+
mipsolver.mipdata_->continuous_cols.size()) /
161+
std::max(1.0, numUnfixed);
159162
// (double)mipsolver.orig_model_->a_matrix_.value_.size();
160163
int64_t adjusted_lp_iterations =
161164
(size_t)(adjustmentfactor * submipsolver.mipdata_->total_lp_iterations);

highs/presolve/HPresolve.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,12 +1281,12 @@ HPresolve::Result HPresolve::dominatedColumns(
12811281
double ak = nonz.value() * bestRowPlusScale;
12821282

12831283
if (model->col_lower_[k] != -kHighsInf &&
1284-
(upperImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1285-
HighsCliqueTable::CliqueVar(j, 1),
1286-
HighsCliqueTable::CliqueVar(k, 1))) &&
12871284
ajBestRowPlus <= ak + options->small_matrix_value &&
12881285
(!isEqOrRangedRow ||
12891286
ajBestRowPlus >= ak - options->small_matrix_value) &&
1287+
(upperImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1288+
HighsCliqueTable::CliqueVar(j, 1),
1289+
HighsCliqueTable::CliqueVar(k, 1))) &&
12901290
checkDomination(1, j, 1, k)) {
12911291
// case (i) ub(x_j) = inf, x_j > x_k: set x_k = lb(x_k)
12921292
++numFixedCols;
@@ -1297,13 +1297,13 @@ HPresolve::Result HPresolve::dominatedColumns(
12971297
}
12981298
HPRESOLVE_CHECKED_CALL(removeRowSingletons(postsolve_stack));
12991299
} else if (model->col_upper_[k] != kHighsInf &&
1300+
ajBestRowPlus <= -ak + options->small_matrix_value &&
1301+
(!isEqOrRangedRow ||
1302+
ajBestRowPlus >= -ak - options->small_matrix_value) &&
13001303
(upperImplied ||
13011304
mipsolver->mipdata_->cliquetable.haveCommonClique(
13021305
HighsCliqueTable::CliqueVar(j, 1),
13031306
HighsCliqueTable::CliqueVar(k, 0))) &&
1304-
ajBestRowPlus <= -ak + options->small_matrix_value &&
1305-
(!isEqOrRangedRow ||
1306-
ajBestRowPlus >= -ak - options->small_matrix_value) &&
13071307
checkDomination(1, j, -1, k)) {
13081308
// case (ii) ub(x_j) = inf, x_j > -x_k: set x_k = ub(x_k)
13091309
++numFixedCols;
@@ -1331,12 +1331,12 @@ HPresolve::Result HPresolve::dominatedColumns(
13311331
double ak = nonz.value() * bestRowMinusScale;
13321332

13331333
if (model->col_upper_[k] != kHighsInf &&
1334-
(lowerImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1335-
HighsCliqueTable::CliqueVar(j, 0),
1336-
HighsCliqueTable::CliqueVar(k, 0))) &&
13371334
-ajBestRowMinus <= -ak + options->small_matrix_value &&
13381335
(!isEqOrRangedRow ||
13391336
-ajBestRowMinus >= -ak - options->small_matrix_value) &&
1337+
(lowerImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1338+
HighsCliqueTable::CliqueVar(j, 0),
1339+
HighsCliqueTable::CliqueVar(k, 0))) &&
13401340
checkDomination(-1, j, -1, k)) {
13411341
// case (iii) lb(x_j) = -inf, -x_j > -x_k: set x_k = ub(x_k)
13421342
++numFixedCols;
@@ -1347,13 +1347,13 @@ HPresolve::Result HPresolve::dominatedColumns(
13471347
}
13481348
HPRESOLVE_CHECKED_CALL(removeRowSingletons(postsolve_stack));
13491349
} else if (model->col_lower_[k] != -kHighsInf &&
1350+
-ajBestRowMinus <= ak + options->small_matrix_value &&
1351+
(!isEqOrRangedRow ||
1352+
-ajBestRowMinus >= ak - options->small_matrix_value) &&
13501353
(lowerImplied ||
13511354
mipsolver->mipdata_->cliquetable.haveCommonClique(
13521355
HighsCliqueTable::CliqueVar(j, 0),
13531356
HighsCliqueTable::CliqueVar(k, 1))) &&
1354-
-ajBestRowMinus <= ak + options->small_matrix_value &&
1355-
(!isEqOrRangedRow ||
1356-
-ajBestRowMinus >= ak - options->small_matrix_value) &&
13571357
checkDomination(-1, j, 1, k)) {
13581358
// case (iv) lb(x_j) = -inf, -x_j > x_k: set x_k = lb(x_k)
13591359
++numFixedCols;

0 commit comments

Comments
 (0)