Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## latest #2337 +/- ##
==========================================
+ Coverage 79.27% 79.29% +0.01%
==========================================
Files 345 345
Lines 84374 84366 -8
==========================================
+ Hits 66887 66895 +8
+ Misses 17487 17471 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Looks good to me! |
There was a problem hiding this comment.
Thank you for fixing this!
-
There is another occurrence of std::frexp in line 850. Is an upper bound needed there as well?
-
Would it be OK to have a method for scaling (to avoid having to repeat the fix)? For example, I tried this here:
double HighsCutGeneration::scale(double val) {
int expshift = 0;
std::frexp(val, &expshift);
expshift = -expshift;
// Don't scale the coefficients by more than +1024 (violations can increase)
expshift = std::min(10, expshift);
// Scale rhs
rhs = std::ldexp(static_cast<double>(rhs), expshift);
// Scale row
for (HighsInt i = 0; i != rowlen; ++i)
vals[i] = std::ldexp(vals[i], expshift);
// Return scaling factor
return std::ldexp(1.0, expshift);
}
jajhall
left a comment
There was a problem hiding this comment.
Looks good to me, but @Opt-Mucca, what about the query from @fwesselm and suggestion that duplicated code is avoided by having a method to do the scaling?
Once this query is resolved, I'm happy for the PR to be merged
|
@fwesselm No problem! Interested to see if this helps minimise the amount of issues created by the fuzzer.
|
|
Added suggested changes. Two things:
|
Yes, I would also be fine with having something like in the new utility. The scaling of the coefficients would still be done using The test failures may be due to the integration with the cMIR fixes that were just merged into |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## latest #2337 +/- ##
==========================================
- Coverage 79.26% 79.06% -0.21%
==========================================
Files 345 345
Lines 84363 84386 +23
==========================================
- Hits 66874 66722 -152
- Misses 17489 17664 +175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I think this is where I need some more C++ background. So the
I accidentally removed some initialisation of the |
I am no expert here, so I asked around and one suggestion was to implement and have
This would avoid the Sorry for the back and forth on this. |
|
@fwesselm no problem on the back and forth, especially if it comes out with a solution that convenient. I'll add that change now. |
jajhall
left a comment
There was a problem hiding this comment.
If @fwesselm and @Opt-Mucca are happy that the final tweaks have been implemented, then this is good to merge.
Note that we should get into the habit of commenting on developments and fixes in https://github.com/ERGO-Code/HiGHS/blob/latest/FEATURES.md I know that there are some formatting errors, and I'll add things from recent merged PRs, but concise comments on MIP developments/fixes are better done by those who implemented them.
This should fix #2322
Explanation: HiGHS always scales a generated inequality so that the largest coefficient is approximately 1.0 before running a separator from
HighsCutGeneration. This results in problems when all the coefficients are small, e.g. nearfeastol = 1e-6, and the inequality violates the optimal solution by some minor value, e.g.,1e-10, because the violation grows substantially after scaling, and the resultant cut then removes the solution.Solution: Add a max scaling factor (you can still scale from 1e+12 to 1.0, but not from 1e-6 to 1.0). Talked with Leona and some other developers on a sensible value (
2**10 = 1024).Instances affected: Any instance where HiGHS generates an inequality with largest absolute coefficient less than
5e-4and then calls a separator fromHighsCutGeneration. I don't see these being frequent and it's not like we're stopping a cut from being generated (just scaling it by less), but I can imagine a tiny performance hit.TLDR: Puts up some additional guard rails for numerically instable cuts