Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an easy way to perform safe float comparisons, to fix the problems we mentioned in the meeting last week. I think the way this works is best illustrated with an example:
Let's say the problem instances contain a set of points and the solution contains a circle of some radius that should cover as many of these points as possible. The issue we now run into when naively comparing
is that the instance points might be placed in such a way that this calculated distance is bigger than size because of float rounding errors. This can be solved by instead comparing
But this will now run into issues if the generating team intentionally places points in such a way that the rounding error occur at
size + epsilon
rather than justsize
. Another problem case is when the floats involved are being computed with big intermediate values, then the rounding errors might be bigger than the constantepsilon
.This PR lets you easily sidestep both issues by just comparing like this:
or alternatively
depending on your syntax preference. This will automatically perform the comparison including an epsilon that adjusts to the total size of the involved values and doubles this fudge factor for the solving team.