Skip to content
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
34 changes: 23 additions & 11 deletions highs/presolve/HPresolveVarBndAggregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ void HPresolve::aggregateVarBounds() {
if (lb > -kHighsInf && ub < kHighsInf)
range = static_cast<double>(static_cast<HighsCDouble>(ub) - lb);

// number of VLBs (VUBs) whose origin row could be rewritten
HighsInt numVlbOrigins = 0;
HighsInt numVubOrigins = 0;

// collect VLBs: y >= coef * x + constant
// standardized form: y >= a * x + lb, where a > 0
if (lb > -kHighsInf) {
Expand All @@ -205,6 +209,7 @@ void HPresolve::aggregateVarBounds() {
colImpliedBounds{v, HighsImplications::VarBound{
static_cast<double>(newCoef),
lb, v.origin}});
if (v.origin >= 0) numVlbOrigins++;
});
}
// collect VUBs: y <= coef * x + constant
Expand All @@ -228,20 +233,27 @@ void HPresolve::aggregateVarBounds() {
colImpliedBounds{v, HighsImplications::VarBound{
static_cast<double>(newCoef),
ub, v.origin}});
if (v.origin >= 0) numVubOrigins++;
});
}

// set up cliques
vlbs.for_each([&](HighsInt binaryCol, colImpliedBounds& bounds) {
HighsInt val = bounds.originalBound.coef > 0 ? 1 : 0;
vlbsClique.emplace_back(binaryCol, val);
});
vubs.for_each([&](HighsInt binaryCol, colImpliedBounds& bounds) {
HighsInt val = bounds.originalBound.coef < 0 ? 1 : 0;
vubsClique.emplace_back(binaryCol, val);
});

// clique cover
// only bounds with an origin row can be merged, so there is nothing to do
// if no VLB and no VUB has one
if (numVlbOrigins == 0 && numVubOrigins == 0) continue;

// set up cliques for the sides with an origin row
if (numVlbOrigins > 0)
vlbs.for_each([&](HighsInt binaryCol, colImpliedBounds& bounds) {
HighsInt val = bounds.originalBound.coef > 0 ? 1 : 0;
vlbsClique.emplace_back(binaryCol, val);
});
if (numVubOrigins > 0)
vubs.for_each([&](HighsInt binaryCol, colImpliedBounds& bounds) {
HighsInt val = bounds.originalBound.coef < 0 ? 1 : 0;
vubsClique.emplace_back(binaryCol, val);
});

// clique cover (clears the covers, which stay empty without cliques)
cliquetable.cliqueCover(vlbsClique, vlbsCover);
cliquetable.cliqueCover(vubsClique, vubsCover);

Expand Down
Loading