Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5829a0f
Remove some duplicate code
fwesselm Aug 18, 2025
756a9ba
Fix issue
fwesselm Aug 18, 2025
fce0428
Clean up
fwesselm Aug 18, 2025
22eebe0
Add lambda
fwesselm Aug 19, 2025
0e1af04
Remove lambda
fwesselm Aug 19, 2025
daa876b
WIP
fwesselm Aug 19, 2025
57cc10a
Merge branch 'refactorPreDomChecks' of https://github.com/fwesselm/Hi…
fwesselm Aug 19, 2025
72afeb4
Make use of new lambda
fwesselm Aug 19, 2025
363237c
WIP
fwesselm Aug 20, 2025
dbecd3b
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into refa…
fwesselm Aug 20, 2025
5bac501
WIP
fwesselm Aug 20, 2025
e171ea2
Still WIP
fwesselm Aug 20, 2025
002a73c
Simplify a little
fwesselm Aug 20, 2025
13410b1
Fix issue on lseu
fwesselm Aug 20, 2025
06ab636
Remove unnecessary else
fwesselm Aug 20, 2025
774ef56
Add lambda
fwesselm Aug 20, 2025
53bce52
Rename
fwesselm Aug 20, 2025
b027dbe
Fix warning
fwesselm Aug 21, 2025
90b85a9
Fix some more warnings
fwesselm Aug 21, 2025
eebb63e
Add comments
fwesselm Aug 21, 2025
6d44793
Add another lambda
fwesselm Aug 26, 2025
8cb38c1
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into refa…
fwesselm Aug 26, 2025
8398878
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into refa…
fwesselm Aug 28, 2025
59a6f06
Add comments
fwesselm Aug 29, 2025
97ba645
Fix typo
fwesselm Aug 29, 2025
ee20dd3
More comments
fwesselm Aug 29, 2025
ff94d97
More comments
fwesselm Aug 29, 2025
3629ebf
Try to improve some comments
fwesselm Sep 1, 2025
e87aa7d
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into refa…
fwesselm Sep 4, 2025
aa79316
Use new utility
fwesselm Sep 4, 2025
dd69d7a
Merge branch 'latest' of https://github.com/ERGO-Code/HiGHS into refa…
fwesselm Sep 17, 2025
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
54 changes: 30 additions & 24 deletions highs/mip/HighsPseudocost.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class HighsPostsolveStack;

class HighsPseudocost;

constexpr double minThreshold = 1e-6;

struct HighsPseudocostInitialization {
std::vector<double> pseudocostup;
std::vector<double> pseudocostdown;
Expand All @@ -47,6 +49,7 @@ struct HighsPseudocostInitialization {
const HighsPseudocost& pscost, HighsInt maxCount,
const presolve::HighsPostsolveStack& postsolveStack);
};

class HighsPseudocost {
friend struct HighsPseudocostInitialization;
std::vector<double> pseudocostup;
Expand Down Expand Up @@ -77,9 +80,7 @@ class HighsPseudocost {
HighsPseudocost(const HighsMipSolver& mipsolver);

void subtractBase(const HighsPseudocost& base) {
HighsInt ncols = pseudocostup.size();

for (HighsInt i = 0; i != ncols; ++i) {
for (size_t i = 0; i != pseudocostup.size(); ++i) {
pseudocostup[i] -= base.pseudocostup[i];
pseudocostdown[i] -= base.pseudocostdown[i];
nsamplesup[i] -= base.nsamplesup[i];
Expand All @@ -95,8 +96,7 @@ class HighsPseudocost {
conflict_weight = 1.0;
conflict_avg_score *= scale;

HighsInt numCol = conflictscoreup.size();
for (HighsInt i = 0; i < numCol; ++i) {
for (size_t i = 0; i != conflictscoreup.size(); ++i) {
conflictscoreup[i] *= scale;
conflictscoredown[i] *= scale;
}
Expand Down Expand Up @@ -248,11 +248,13 @@ class HighsPseudocost {
}

double getScore(HighsInt col, double upcost, double downcost) const {
double costScore = std::max(upcost, 1e-6) * std::max(downcost, 1e-6) /
std::max(1e-6, cost_total * cost_total);
double inferenceScore = std::max(inferencesup[col], 1e-6) *
std::max(inferencesdown[col], 1e-6) /
std::max(1e-6, inferences_total * inferences_total);
double costScore = std::max(upcost, minThreshold) *
std::max(downcost, minThreshold) /
std::max(minThreshold, cost_total * cost_total);
double inferenceScore =
std::max(inferencesup[col], minThreshold) *
std::max(inferencesdown[col], minThreshold) /
std::max(minThreshold, inferences_total * inferences_total);

double cutOffScoreUp =
ncutoffsup[col] /
Expand All @@ -266,18 +268,19 @@ class HighsPseudocost {
std::max(1.0, static_cast<double>(ncutoffstotal) +
static_cast<double>(nsamplestotal));

double cutoffScore = std::max(cutOffScoreUp, 1e-6) *
std::max(cutOffScoreDown, 1e-6) /
std::max(1e-6, avgCutoffs * avgCutoffs);
double cutoffScore = std::max(cutOffScoreUp, minThreshold) *
std::max(cutOffScoreDown, minThreshold) /
std::max(minThreshold, avgCutoffs * avgCutoffs);

double conflictScoreUp = conflictscoreup[col] / conflict_weight;
double conflictScoreDown = conflictscoredown[col] / conflict_weight;
double conflictScoreAvg =
conflict_avg_score /
(conflict_weight * static_cast<double>(conflictscoreup.size()));
double conflictScore = std::max(conflictScoreUp, 1e-6) *
std::max(conflictScoreDown, 1e-6) /
std::max(1e-6, conflictScoreAvg * conflictScoreAvg);
double conflictScore =
std::max(conflictScoreUp, minThreshold) *
std::max(conflictScoreDown, minThreshold) /
std::max(minThreshold, conflictScoreAvg * conflictScoreAvg);

auto mapScore = [](double score) { return 1.0 - 1.0 / (1.0 + score); };
return mapScore(costScore) / degeneracyFactor +
Expand All @@ -294,9 +297,10 @@ class HighsPseudocost {
}

double getScoreUp(HighsInt col, double frac) const {
double costScore = getPseudocostUp(col, frac) / std::max(1e-6, cost_total);
double costScore =
getPseudocostUp(col, frac) / std::max(minThreshold, cost_total);
double inferenceScore =
inferencesup[col] / std::max(1e-6, inferences_total);
inferencesup[col] / std::max(minThreshold, inferences_total);

double cutOffScoreUp =
ncutoffsup[col] /
Expand All @@ -306,13 +310,14 @@ class HighsPseudocost {
std::max(1.0, static_cast<double>(ncutoffstotal) +
static_cast<double>(nsamplestotal));

double cutoffScore = cutOffScoreUp / std::max(1e-6, avgCutoffs);
double cutoffScore = cutOffScoreUp / std::max(minThreshold, avgCutoffs);

double conflictScoreUp = conflictscoreup[col] / conflict_weight;
double conflictScoreAvg =
conflict_avg_score /
(conflict_weight * static_cast<double>(conflictscoreup.size()));
double conflictScore = conflictScoreUp / std::max(1e-6, conflictScoreAvg);
double conflictScore =
conflictScoreUp / std::max(minThreshold, conflictScoreAvg);

auto mapScore = [](double score) { return 1.0 - 1.0 / (1.0 + score); };

Expand All @@ -323,9 +328,9 @@ class HighsPseudocost {

double getScoreDown(HighsInt col, double frac) const {
double costScore =
getPseudocostDown(col, frac) / std::max(1e-6, cost_total);
getPseudocostDown(col, frac) / std::max(minThreshold, cost_total);
double inferenceScore =
inferencesdown[col] / std::max(1e-6, inferences_total);
inferencesdown[col] / std::max(minThreshold, inferences_total);

double cutOffScoreDown =
ncutoffsdown[col] /
Expand All @@ -335,13 +340,14 @@ class HighsPseudocost {
std::max(1.0, static_cast<double>(ncutoffstotal) +
static_cast<double>(nsamplestotal));

double cutoffScore = cutOffScoreDown / std::max(1e-6, avgCutoffs);
double cutoffScore = cutOffScoreDown / std::max(minThreshold, avgCutoffs);

double conflictScoreDown = conflictscoredown[col] / conflict_weight;
double conflictScoreAvg =
conflict_avg_score /
(conflict_weight * static_cast<double>(conflictscoredown.size()));
double conflictScore = conflictScoreDown / std::max(1e-6, conflictScoreAvg);
double conflictScore =
conflictScoreDown / std::max(minThreshold, conflictScoreAvg);

auto mapScore = [](double score) { return 1.0 - 1.0 / (1.0 + score); };

Expand Down
Loading
Loading