Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflow edge case in sequence of balls volume method #228

Merged
merged 2 commits into from
Jul 18, 2022

Conversation

dymil
Copy link
Contributor

@dymil dymil commented Jun 30, 2022

Force rnum>=1, avoiding integer overflow when rnum-1 is passed into RandomPointGenerator::apply a few lines later, which hoovers up RAM and time. This edge case can be observed with a degenerate polytope (I tried a 1D interval) or with extreme choices of error and n_threads.

rnum-1 is passed into RandomPointGenerator::apply a few lines later
@codecov
Copy link

codecov bot commented Jun 30, 2022

Codecov Report

Merging #228 (5b29181) into develop (59cd27e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #228   +/-   ##
========================================
  Coverage    55.24%   55.24%           
========================================
  Files           85       85           
  Lines         4802     4802           
  Branches      2108     2109    +1     
========================================
  Hits          2653     2653           
  Misses         896      896           
  Partials      1253     1253           
Impacted Files Coverage Δ
include/volume/volume_sequence_of_balls.hpp 66.66% <100.00%> (ø)

Copy link
Member

@vissarion vissarion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dymil for this PR! I am OK with merging of this change but please add the edge cases you mention in the test suite (this will eventually increase the coverage, notice that the CI is complaining about coverage decrease).

@vissarion
Copy link
Member

You can add tests here https://github.com/GeomScale/volesti/blob/develop/test/volume_sob_hpolytope.cpp for (sequence of balls volume algorithm)

@vissarion vissarion added the bug label Jul 1, 2022
@dymil dymil marked this pull request as draft July 4, 2022 11:09
@dymil dymil force-pushed the SoB_overflow branch 2 times, most recently from a23ab66 to a2e152a Compare July 5, 2022 12:37
Force rnum>=2 rather than >=1,
so that all three walk methods succeed for 1D case.
Small rnum's due to larger error or n_threads may fail in other ways
in higher dimensions, e.g., empty balls check
@dymil
Copy link
Contributor Author

dymil commented Jul 5, 2022

I added a 1D test case which fails (times out) with the old code but passes with the updated (after tweaking the fix to ensure rnum>=2 instead of 1). I also tried a 2D test case with large error or n_threads and those indeed trigger the overflow but, even with the fix, balls would be empty or something else would go wrong with a small rnum. The fix presumably needs to scale with dimension but I'm not sure exactly how, and, in any case, I find failing an assertion superior to simply hanging.

Alternative fixes which might be more suitable include shrinking n_threads if needed (rnum may still need to be increased if it was already small) or to make an earlier assertion so that the caller is better informed of the ultimate cause of the issue, rather than silently plugging the issue.

@dymil dymil marked this pull request as ready for review July 5, 2022 14:02
@vissarion vissarion merged commit cc8e5b0 into GeomScale:develop Jul 18, 2022
@dymil dymil deleted the SoB_overflow branch July 21, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants