feat(ga): Implement Cauchy's bound for automatic root range detection #18

Merged
jono merged 1 commits from v0.4.2-dev into main 2025-10-27 18:36:41 +00:00
Owner

The previous benchmark results showed that the GA was failing to find accurate roots (high MAE) for many polynomials. This was because the fixed default search range ([-100, 100]) was often incorrect, and the GA was searching in the wrong place.

This commit introduces a significantly more robust solution:

  1. Adds a _get_cauchy_bound helper function to mathematically calculate a search radius that is guaranteed to contain all real roots.

  2. Updates _solve_x_numpy and _solve_x_cuda with new logic:

    • If the user provides a custom min_range or max_range, we treat them as an expert and use their specified range.
    • If the user is using the default range, we silently discard it and use the smarter, automatically-calculated Cauchy bound instead.

This provides the best of both worlds: a powerful, smart default for most users and an "expert override" for those who need to fine-tune the search area.

The previous benchmark results showed that the GA was failing to find accurate roots (high MAE) for many polynomials. This was because the fixed default search range ([-100, 100]) was often incorrect, and the GA was searching in the wrong place. This commit introduces a significantly more robust solution: 1. Adds a `_get_cauchy_bound` helper function to mathematically calculate a search radius that is guaranteed to contain all real roots. 2. Updates `_solve_x_numpy` and `_solve_x_cuda` with new logic: * If the user provides a *custom* `min_range` or `max_range`, we treat them as an expert and use their specified range. * If the user is using the *default* range, we silently discard it and use the smarter, automatically-calculated Cauchy bound instead. This provides the best of both worlds: a powerful, smart default for most users and an "expert override" for those who need to fine-tune the search area.
jono added 1 commit 2025-10-27 18:35:04 +00:00
feat(ga): Implement Cauchy's bound for automatic root range detection
All checks were successful
Run Python Tests / test (3.12) (pull_request) Successful in 10s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Successful in 12s
962eab5af7
The previous benchmark results showed that the GA was failing to find accurate roots (high MAE) for many polynomials. This was because the fixed default search range ([-100, 100]) was often incorrect, and the GA was searching in the wrong place.

This commit introduces a significantly more robust solution:

1.  Adds a `_get_cauchy_bound` helper function to mathematically calculate a search radius that is guaranteed to contain all real roots.

2.  Updates `_solve_x_numpy` and `_solve_x_cuda` with new logic:
    * If the user provides a *custom* `min_range` or `max_range`, we treat them as an expert and use their specified range.
    * If the user is using the *default* range, we silently discard it and use the smarter, automatically-calculated Cauchy bound instead.

This provides the best of both worlds: a powerful, smart default for most users and an "expert override" for those who need to fine-tune the search area.
jono merged commit 962eab5af7 into main 2025-10-27 18:36:41 +00:00
jono deleted branch v0.4.2-dev 2025-10-27 18:36:42 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jono/PolySolve#18