Skip to content

Commit f2f5829

Browse files
committed
Do combined score
1 parent 3bd1726 commit f2f5829

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

highs/mip/HighsPathSeparator.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
7070
rowNorm[row] += val * val;
7171
}
7272
}
73+
// Score will be used for deciding order in which rows get aggregated
74+
std::vector<double> rowScore(lp.num_row_);
75+
for (HighsInt i = 0; i != lp.num_row_; ++i) {
76+
rowScore[i] =
77+
rowNorm[i] <= mip.mipdata_->feastol ? 0 : fracActivity[i] / rowNorm[i];
78+
}
7379

7480
std::vector<HighsInt> numContinuous(lp.num_row_);
7581

@@ -119,9 +125,7 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
119125
// larger
120126
if (colSubstitutions[col].first != -1) {
121127
HighsInt k = colSubstitutions[col].first;
122-
if (fracActivity[k] / std::max(rowNorm[k], mip.mipdata_->feastol) <
123-
fracActivity[i] / std::max(rowNorm[i], mip.mipdata_->feastol) -
124-
mip.mipdata_->feastol) {
128+
if (rowScore[k] < rowScore[i] - mip.mipdata_->feastol) {
125129
colSubstitutions[col].first = i;
126130
colSubstitutions[col].second = val;
127131
rowtype[k] = origrowtype[k];
@@ -135,14 +139,19 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
135139
rowtype[i] = RowType::kUnusuable;
136140
}
137141

138-
// Score will be used for deciding order in which rows get aggregated
139-
std::vector<std::pair<HighsInt, double>> rowScore;
140-
rowScore.reserve(lp.num_row_);
141-
for (HighsInt row = 0; row != lp.num_row_; ++row) {
142-
rowScore.emplace_back(numContinuous[row],
143-
rowNorm[row] <= mip.mipdata_->feastol
144-
? 0
145-
: -fracActivity[row] / rowNorm[row]);
142+
// Adjust the numContinuous to reflect columns that will always be replaced
143+
for (HighsInt col : mip.mipdata_->continuous_cols) {
144+
if (transLp.boundDistance(col) == 0.0 || colSubstitutions[col].first == -1)
145+
continue;
146+
for (HighsInt i = lp.a_matrix_.start_[col];
147+
i != lp.a_matrix_.start_[col + 1]; ++i) {
148+
--numContinuous[lp.a_matrix_.index_[i]];
149+
}
150+
}
151+
152+
// Adjust the score by some factor
153+
for (HighsInt i = 0; i != lp.num_row_; ++i) {
154+
rowScore[i] /= 1 + numContinuous[i];
146155
}
147156

148157
// for each continuous variable with nonzero transformed solution value

0 commit comments

Comments
 (0)