Skip to content

Commit b3b21ef

Browse files
committed
Add maxlim for vbs. Change order of dominating col check
1 parent f8cf3c9 commit b3b21ef

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

highs/mip/HighsCliqueTable.cpp

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

highs/mip/HighsImplications.cpp

Lines changed: 15 additions & 2 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

@@ -415,13 +416,15 @@ void HighsImplications::addVUB(HighsInt col, HighsInt vubcol, double vubcoef,
415416
currentvub.constant = vubconstant;
416417
}
417418
}
419+
else 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

@@ -443,6 +446,7 @@ void HighsImplications::addVLB(HighsInt col, HighsInt vlbcol, double vlbcoef,
443446
currentvlb.constant = vlbconstant;
444447
}
445448
}
449+
else 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 = 2000000 + 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 = 2000000 + 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/presolve/HPresolve.cpp

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

12811281
if (model->col_lower_[k] != -kHighsInf &&
1282-
(upperImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1283-
HighsCliqueTable::CliqueVar(j, 1),
1284-
HighsCliqueTable::CliqueVar(k, 1))) &&
12851282
ajBestRowPlus <= ak + options->small_matrix_value &&
12861283
(!isEqOrRangedRow ||
12871284
ajBestRowPlus >= ak - options->small_matrix_value) &&
1285+
(upperImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1286+
HighsCliqueTable::CliqueVar(j, 1),
1287+
HighsCliqueTable::CliqueVar(k, 1))) &&
12881288
checkDomination(1, j, 1, k)) {
12891289
// case (i) ub(x_j) = inf, x_j > x_k: set x_k = lb(x_k)
12901290
++numFixedCols;
@@ -1295,13 +1295,13 @@ HPresolve::Result HPresolve::dominatedColumns(
12951295
}
12961296
HPRESOLVE_CHECKED_CALL(removeRowSingletons(postsolve_stack));
12971297
} else if (model->col_upper_[k] != kHighsInf &&
1298+
ajBestRowPlus <= -ak + options->small_matrix_value &&
1299+
(!isEqOrRangedRow ||
1300+
ajBestRowPlus >= -ak - options->small_matrix_value) &&
12981301
(upperImplied ||
12991302
mipsolver->mipdata_->cliquetable.haveCommonClique(
13001303
HighsCliqueTable::CliqueVar(j, 1),
13011304
HighsCliqueTable::CliqueVar(k, 0))) &&
1302-
ajBestRowPlus <= -ak + options->small_matrix_value &&
1303-
(!isEqOrRangedRow ||
1304-
ajBestRowPlus >= -ak - options->small_matrix_value) &&
13051305
checkDomination(1, j, -1, k)) {
13061306
// case (ii) ub(x_j) = inf, x_j > -x_k: set x_k = ub(x_k)
13071307
++numFixedCols;
@@ -1329,12 +1329,12 @@ HPresolve::Result HPresolve::dominatedColumns(
13291329
double ak = nonz.value() * bestRowMinusScale;
13301330

13311331
if (model->col_upper_[k] != kHighsInf &&
1332-
(lowerImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1333-
HighsCliqueTable::CliqueVar(j, 0),
1334-
HighsCliqueTable::CliqueVar(k, 0))) &&
13351332
-ajBestRowMinus <= -ak + options->small_matrix_value &&
13361333
(!isEqOrRangedRow ||
13371334
-ajBestRowMinus >= -ak - options->small_matrix_value) &&
1335+
(lowerImplied || mipsolver->mipdata_->cliquetable.haveCommonClique(
1336+
HighsCliqueTable::CliqueVar(j, 0),
1337+
HighsCliqueTable::CliqueVar(k, 0))) &&
13381338
checkDomination(-1, j, -1, k)) {
13391339
// case (iii) lb(x_j) = -inf, -x_j > -x_k: set x_k = ub(x_k)
13401340
++numFixedCols;
@@ -1345,13 +1345,13 @@ HPresolve::Result HPresolve::dominatedColumns(
13451345
}
13461346
HPRESOLVE_CHECKED_CALL(removeRowSingletons(postsolve_stack));
13471347
} else if (model->col_lower_[k] != -kHighsInf &&
1348+
-ajBestRowMinus <= ak + options->small_matrix_value &&
1349+
(!isEqOrRangedRow ||
1350+
-ajBestRowMinus >= ak - options->small_matrix_value) &&
13481351
(lowerImplied ||
13491352
mipsolver->mipdata_->cliquetable.haveCommonClique(
13501353
HighsCliqueTable::CliqueVar(j, 0),
13511354
HighsCliqueTable::CliqueVar(k, 1))) &&
1352-
-ajBestRowMinus <= ak + options->small_matrix_value &&
1353-
(!isEqOrRangedRow ||
1354-
-ajBestRowMinus >= ak - options->small_matrix_value) &&
13551355
checkDomination(-1, j, 1, k)) {
13561356
// case (iv) lb(x_j) = -inf, -x_j > x_k: set x_k = lb(x_k)
13571357
++numFixedCols;

0 commit comments

Comments
 (0)