Skip to content

Commit 4b7963f

Browse files
committed
No need to pass entire vector
1 parent 57b3759 commit 4b7963f

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

src/mip/HighsDomain.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ static double activityContributionMax(double coef, const double& lb,
4646
}
4747
}
4848

49-
static double computeDelta(HighsInt row, double val, double oldbound,
50-
double newbound, double inf,
51-
std::vector<HighsInt>& numinfs) {
49+
static double computeDelta(double val, double oldbound, double newbound,
50+
double inf, HighsInt& numinfs) {
5251
// if bounds are huge, HighsCDouble should be used when computing bound
5352
// differences. todo: qualify usage of HighsCDouble in this function.
5453
if (oldbound == inf) {
55-
--numinfs[row];
54+
--numinfs;
5655
return newbound * val;
5756
} else if (newbound == inf) {
58-
++numinfs[row];
57+
++numinfs;
5958
return -oldbound * val;
6059
} else {
6160
return (newbound - oldbound) * val;
@@ -482,8 +481,8 @@ void HighsDomain::CutpoolPropagation::updateActivityLbChange(HighsInt col,
482481
cutpool->getMatrix().forEachPositiveColumnEntry(
483482
col, [&](HighsInt row, double val) {
484483
assert(val > 0);
485-
double deltamin = computeDelta(row, val, oldbound, newbound, -kHighsInf,
486-
activitycutsinf_);
484+
double deltamin = computeDelta(val, oldbound, newbound, -kHighsInf,
485+
activitycutsinf_[row]);
487486
activitycuts_[row] += deltamin;
488487

489488
if (deltamin <= 0) {
@@ -516,8 +515,8 @@ void HighsDomain::CutpoolPropagation::updateActivityLbChange(HighsInt col,
516515
cutpool->getMatrix().forEachPositiveColumnEntry(
517516
col, [&](HighsInt row, double val) {
518517
assert(val > 0);
519-
activitycuts_[row] += computeDelta(row, val, oldbound, newbound,
520-
-kHighsInf, activitycutsinf_);
518+
activitycuts_[row] += computeDelta(val, oldbound, newbound,
519+
-kHighsInf, activitycutsinf_[row]);
521520

522521
if (domain->infeasible_reason.index == row) return false;
523522

@@ -543,8 +542,8 @@ void HighsDomain::CutpoolPropagation::updateActivityUbChange(HighsInt col,
543542
cutpool->getMatrix().forEachNegativeColumnEntry(
544543
col, [&](HighsInt row, double val) {
545544
assert(val < 0);
546-
double deltamin = computeDelta(row, val, oldbound, newbound, kHighsInf,
547-
activitycutsinf_);
545+
double deltamin = computeDelta(val, oldbound, newbound, kHighsInf,
546+
activitycutsinf_[row]);
548547
activitycuts_[row] += deltamin;
549548

550549
if (deltamin <= 0) {
@@ -575,8 +574,8 @@ void HighsDomain::CutpoolPropagation::updateActivityUbChange(HighsInt col,
575574
cutpool->getMatrix().forEachNegativeColumnEntry(
576575
col, [&](HighsInt row, double val) {
577576
assert(val < 0);
578-
activitycuts_[row] += computeDelta(row, val, oldbound, newbound,
579-
kHighsInf, activitycutsinf_);
577+
activitycuts_[row] += computeDelta(val, oldbound, newbound, kHighsInf,
578+
activitycutsinf_[row]);
580579

581580
if (domain->infeasible_reason.index == row) return false;
582581

@@ -1530,8 +1529,8 @@ void HighsDomain::updateActivityLbChange(HighsInt col, double oldbound,
15301529
for (HighsInt i = start; i != end; ++i) {
15311530
if (mip->a_matrix_.value_[i] > 0) {
15321531
double deltamin =
1533-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1534-
oldbound, newbound, -kHighsInf, activitymininf_);
1532+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound, -kHighsInf,
1533+
activitymininf_[mip->a_matrix_.index_[i]]);
15351534
activitymin_[mip->a_matrix_.index_[i]] += deltamin;
15361535

15371536
#ifndef NDEBUG
@@ -1574,8 +1573,8 @@ void HighsDomain::updateActivityLbChange(HighsInt col, double oldbound,
15741573
markPropagate(mip->a_matrix_.index_[i]);
15751574
} else {
15761575
double deltamax =
1577-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1578-
oldbound, newbound, -kHighsInf, activitymaxinf_);
1576+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound, -kHighsInf,
1577+
activitymaxinf_[mip->a_matrix_.index_[i]]);
15791578
activitymax_[mip->a_matrix_.index_[i]] += deltamax;
15801579

15811580
#ifndef NDEBUG
@@ -1633,12 +1632,12 @@ void HighsDomain::updateActivityLbChange(HighsInt col, double oldbound,
16331632
for (HighsInt i = start; i != end; ++i) {
16341633
if (mip->a_matrix_.value_[i] > 0) {
16351634
activitymin_[mip->a_matrix_.index_[i]] +=
1636-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1637-
oldbound, newbound, -kHighsInf, activitymininf_);
1635+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound,
1636+
-kHighsInf, activitymininf_[mip->a_matrix_.index_[i]]);
16381637
} else {
16391638
activitymax_[mip->a_matrix_.index_[i]] +=
1640-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1641-
oldbound, newbound, -kHighsInf, activitymaxinf_);
1639+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound,
1640+
-kHighsInf, activitymaxinf_[mip->a_matrix_.index_[i]]);
16421641
}
16431642
}
16441643

@@ -1669,8 +1668,8 @@ void HighsDomain::updateActivityUbChange(HighsInt col, double oldbound,
16691668
for (HighsInt i = start; i != end; ++i) {
16701669
if (mip->a_matrix_.value_[i] > 0) {
16711670
double deltamax =
1672-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1673-
oldbound, newbound, kHighsInf, activitymaxinf_);
1671+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound, kHighsInf,
1672+
activitymaxinf_[mip->a_matrix_.index_[i]]);
16741673
activitymax_[mip->a_matrix_.index_[i]] += deltamax;
16751674

16761675
#ifndef NDEBUG
@@ -1716,8 +1715,8 @@ void HighsDomain::updateActivityUbChange(HighsInt col, double oldbound,
17161715
}
17171716
} else {
17181717
double deltamin =
1719-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1720-
oldbound, newbound, kHighsInf, activitymininf_);
1718+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound, kHighsInf,
1719+
activitymininf_[mip->a_matrix_.index_[i]]);
17211720
activitymin_[mip->a_matrix_.index_[i]] += deltamin;
17221721

17231722
#ifndef NDEBUG
@@ -1778,12 +1777,12 @@ void HighsDomain::updateActivityUbChange(HighsInt col, double oldbound,
17781777
for (HighsInt i = start; i != end; ++i) {
17791778
if (mip->a_matrix_.value_[i] > 0) {
17801779
activitymax_[mip->a_matrix_.index_[i]] +=
1781-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1782-
oldbound, newbound, kHighsInf, activitymaxinf_);
1780+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound,
1781+
kHighsInf, activitymaxinf_[mip->a_matrix_.index_[i]]);
17831782
} else {
17841783
activitymin_[mip->a_matrix_.index_[i]] +=
1785-
computeDelta(mip->a_matrix_.index_[i], mip->a_matrix_.value_[i],
1786-
oldbound, newbound, kHighsInf, activitymininf_);
1784+
computeDelta(mip->a_matrix_.value_[i], oldbound, newbound,
1785+
kHighsInf, activitymininf_[mip->a_matrix_.index_[i]]);
17871786
}
17881787
}
17891788

0 commit comments

Comments
 (0)