feat(ga): Implement Cauchy's bound for automatic root range detection #18
Reference in New Issue
Block a user
Delete Branch "v0.4.2-dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
Adds a
_get_cauchy_boundhelper function to mathematically calculate a search radius that is guaranteed to contain all real roots.Updates
_solve_x_numpyand_solve_x_cudawith new logic:min_rangeormax_range, we treat them as an expert and use their specified range.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.