Skip to content

Commit a024849

Browse files
committed
Added additional numerical safeguard
1 parent b2ffd80 commit a024849

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

highs/mip/HighsCutGeneration.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -703,34 +703,40 @@ bool HighsCutGeneration::cmirCutGenerationHeuristic(double minEfficacy,
703703
double downrhs = fast_floor(scalrhs);
704704
double f0 = scalrhs - downrhs;
705705
double oneoveroneminusf0 = 1.0 / (1.0 - f0);
706+
// Skip numerically troublesome cuts
706707
double k = fast_ceil((1 / f0) - epsilon) - 1;
707-
708-
// All coefficients of continuous variables are 0 in strong CG cut
709-
double sqrnorm = 0;
710-
double viol = -downrhs;
711-
712-
for (HighsInt j : integerinds) {
713-
double scalaj = vals[j] * scale;
714-
double downaj = fast_floor(scalaj + kHighsTiny);
715-
double fj = scalaj - downaj;
716-
if (fj <= f0 + 1e-5) {
717-
double aj = downaj;
718-
updateViolationAndNorm(j, aj, viol, sqrnorm);
719-
} else {
720-
double pj = fast_ceil(k * (fj - f0) * oneoveroneminusf0 - kHighsTiny);
721-
double aj = downaj + (pj / (k + 1));
722-
updateViolationAndNorm(j, aj, viol, sqrnorm);
723-
}
724-
}
725-
if (sqrnorm <= kHighsTiny) {
708+
double checkk = fast_ceil((1 / f0) + epsilon) - 1;
709+
if (fabs(k - checkk) >= 0.5) {
726710
strongcg = false;
727711
} else {
728-
double efficacy = viol / sqrt(sqrnorm);
729-
// Use the strong CG cut instead of the CMIR if efficacy is larger
730-
if (efficacy < bestefficacy + 1e-5) {
712+
// All coefficients of continuous variables are 0 in strong CG cut
713+
double sqrnorm = 0;
714+
double viol = -downrhs;
715+
716+
for (HighsInt j : integerinds) {
717+
double scalaj = vals[j] * scale;
718+
double downaj = fast_floor(scalaj + kHighsTiny);
719+
double fj = scalaj - downaj;
720+
if (fj <= f0 + 1e-5) {
721+
double aj = downaj;
722+
updateViolationAndNorm(j, aj, viol, sqrnorm);
723+
} else {
724+
double pj = fast_ceil(
725+
k * (fj - f0) * oneoveroneminusf0 - kHighsTiny);
726+
double aj = downaj + (pj / (k + 1));
727+
updateViolationAndNorm(j, aj, viol, sqrnorm);
728+
}
729+
}
730+
if (sqrnorm <= kHighsTiny) {
731731
strongcg = false;
732732
} else {
733-
bestefficacy = efficacy;
733+
double efficacy = viol / sqrt(sqrnorm);
734+
// Use the strong CG cut instead of the CMIR if efficacy is larger
735+
if (efficacy < bestefficacy + 1e-5) {
736+
strongcg = false;
737+
} else {
738+
bestefficacy = efficacy;
739+
}
734740
}
735741
}
736742
}

0 commit comments

Comments
 (0)