Skip to content

Commit 8423f40

Browse files
committed
Use l2 norm. Primary weight as numContinuous
1 parent d76bdb5 commit 8423f40

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

highs/mip/HighsPathSeparator.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,25 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
109109
}
110110

111111
// Score will be used for deciding order in which rows get aggregated
112-
std::vector<std::pair<double, double>> rowscore(lp.num_row_,
113-
std::make_pair(0.0, 0.0));
112+
std::vector<double> rowNorm(lp.num_row_);
113+
std::vector<double> fracActivity(lp.num_row_);
114114
for (HighsInt col = 0; col != lp.num_col_; ++col) {
115115
for (HighsInt i = lp.a_matrix_.start_[col];
116116
i != lp.a_matrix_.start_[col + 1]; ++i) {
117117
HighsInt row = lp.a_matrix_.index_[i];
118118
if (rowtype[row] == RowType::kUnusuable) continue;
119119
double val = std::abs(lp.a_matrix_.value_[i]);
120-
rowscore[row].first += val * transLp.getColFractionality(col);
121-
rowscore[row].second += val;
120+
fracActivity[row] += val * transLp.getColFractionality(col);
121+
rowNorm[row] += val * val;
122122
}
123123
}
124+
std::vector<std::pair<HighsInt, double>> rowScore;
125+
rowScore.reserve(lp.num_row_);
124126
for (HighsInt row = 0; row != lp.num_row_; ++row) {
125-
if (rowscore[row].second > mip.mipdata_->feastol) {
126-
rowscore[row].first /= rowscore[row].second;
127-
} else {
128-
rowscore[row].first = 0.0;
129-
}
127+
rowScore.emplace_back(numContinuous[row],
128+
rowNorm[row] <= mip.mipdata_->feastol
129+
? 0
130+
: -fracActivity[row] / rowNorm[row]);
130131
}
131132

132133
// for each continuous variable with nonzero transformed solution value
@@ -191,13 +192,13 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
191192
inArcRows.begin() + colInArcs[col].second,
192193
[&](const std::pair<HighsInt, double>& i,
193194
const std::pair<HighsInt, double>& j) {
194-
return rowscore[i.first] > rowscore[j.first];
195+
return rowScore[i.first] < rowScore[j.first];
195196
});
196197
pdqsort(outArcRows.begin() + colOutArcs[col].first,
197198
outArcRows.begin() + colOutArcs[col].second,
198199
[&](const std::pair<HighsInt, double>& i,
199200
const std::pair<HighsInt, double>& j) {
200-
return rowscore[i.first] > rowscore[j.first];
201+
return rowScore[i.first] < rowScore[j.first];
201202
});
202203
}
203204

0 commit comments

Comments
 (0)