Skip to content

Avoid overflow in float interval medians#231

Merged
zayenz merged 3 commits into
mainfrom
feature/safe-float-median
Jul 14, 2026
Merged

Avoid overflow in float interval medians#231
zayenz merged 3 commits into
mainfrom
feature/safe-float-median

Conversation

@zayenz

@zayenz zayenz commented Jul 13, 2026

Copy link
Copy Markdown
Member

An unbounded FlatZinc float variable can enter an all-negative interval whose median overflows to negative infinity. The split brancher then has one failing alternative and one alternative that leaves the domain unchanged, so search repeats indefinitely.

Compute finite medians with the existing nearest-rounding policy, scaling the operands only near the numerical limits to avoid overflow. Semi-infinite intervals retain their legacy extended endpoint, the fully unbounded interval has symmetric median zero, and singleton infinities remain unchanged.

Regression coverage includes positive, negative, and mixed intervals at the Float limits; the one-ULP closest-representation case; semi-infinite and infinite intervals; signed zero; and subnormal intervals. The reported model goes from 977,266 nodes without a solution after one second to 54 nodes and a solution in under one millisecond.

Checks:

  • Float::Basic (20 iterations)
  • all Float::Branch tests (20 iterations)
  • original MiniZinc model compiled with MiniZinc 2.9.7 and run through current fzn-gecode (1 solution, 54 nodes)
  • 500,000 randomized finite interval pairs against an MPFR exact-midpoint oracle under all four IEEE rounding modes
  • git diff --check

Closes #164.

@zayenz zayenz marked this pull request as ready for review July 14, 2026 07:01
@zayenz zayenz force-pushed the feature/safe-float-median branch from 652a74f to b018bc7 Compare July 14, 2026 07:33
@zayenz zayenz merged commit a8fb115 into main Jul 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant