Skip to content

Commit 74a36d3

Browse files
committed
First draft before holiday
1 parent f2b4b35 commit 74a36d3

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

highs/mip/HighsPathSeparator.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,23 @@ void HighsPathSeparator::separateLpSolution(HighsLpRelaxation& lpRelaxation,
5858
}
5959

6060
std::vector<HighsInt> numContinuous(lp.num_row_);
61-
61+
// Score will be used for deciding order in which rows get aggregated
62+
// TODO: The second entry is currently a hacky way to store the norm
63+
std::vector<std::pair<double, double>> rowscore(lp.num_row_,
64+
std::make_pair(0.0, 0.0));
6265
size_t maxAggrRowSize = 0;
6366
for (HighsInt col : mip.mipdata_->continuous_cols) {
6467
if (transLp.boundDistance(col) == 0.0) continue;
6568

6669
maxAggrRowSize += lp.a_matrix_.start_[col + 1] - lp.a_matrix_.start_[col];
6770
for (HighsInt i = lp.a_matrix_.start_[col];
68-
i != lp.a_matrix_.start_[col + 1]; ++i)
71+
i != lp.a_matrix_.start_[col + 1]; ++i) {
6972
++numContinuous[lp.a_matrix_.index_[i]];
73+
// Add the fractional score of the row
74+
rowscore[i].first +=
75+
lp.a_matrix_.value_[i] * transLp.getFracVbEstimate(col);
76+
rowscore[i].second += lp.a_matrix_.value_[i];
77+
}
7078
}
7179

7280
std::vector<std::pair<HighsInt, double>> colSubstitutions(

highs/mip/HighsTransformedLp.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <vector>
1818

19+
#include "HighsLpRelaxation.h"
1920
#include "lp_data/HConst.h"
2021
#include "mip/HighsImplications.h"
2122
#include "util/HighsCDouble.h"
@@ -52,6 +53,30 @@ class HighsTransformedLp {
5253

5354
double boundDistance(HighsInt col) const { return boundDist[col]; }
5455

56+
// TODO: Should this simple be calculated when we initialise the transLp?
57+
double getFracVbEstimate(HighsInt col) const {
58+
HighsInt vbCol = -1;
59+
double vbCoef = 0.0;
60+
if (ubDist[col] <= lbDist[col] && bestVlb[col].first != -1) {
61+
vbCol = bestVlb[col].first;
62+
vbCoef = bestVlb[col].second.coef;
63+
} else if (lbDist[col] <= ubDist[col] && bestVub[col].first != -1) {
64+
vbCol = bestVub[col].first;
65+
vbCoef = bestVub[col].second.coef;
66+
} else if (bestVlb[col].first != -1) {
67+
vbCol = bestVlb[col].first;
68+
vbCoef = bestVlb[col].second.coef;
69+
} else if (bestVub[col].first != -1) {
70+
vbCol = bestVub[col].first;
71+
vbCoef = bestVub[col].second.coef;
72+
}
73+
if (vbCol == -1) return 0;
74+
// TODO: This differs from the SCIP definition? Their frac can be > 1?
75+
double val = vbCoef * lprelaxation.solutionValue(col);
76+
double frac = std::max(val - std::floor(val), 0.0);
77+
return std::min(frac, 1 - frac);
78+
}
79+
5580
bool transform(std::vector<double>& vals, std::vector<double>& upper,
5681
std::vector<double>& solval, std::vector<HighsInt>& inds,
5782
double& rhs, bool& integralPositive, bool preferVbds = false);

0 commit comments

Comments
 (0)