feat(ga): Implement quality filtering and precision-based clustering #19

Merged
jono merged 2 commits from v0.5.0-dev into main 2025-10-27 19:26:50 +00:00
Owner

The previous GA logic was returning the "top N" solutions, which led to test failures when the algorithm correctly converged on only one of all possible roots (e.g., returning 1000 variations of -1.0).

This commit fixes the root-finding logic to correctly identify and return all unique, high-quality roots:

  1. feat(api): Adds root_precision to GA_Options. This new parameter (default: 5) allows the user to control the number of decimal places for clustering unique roots.

  2. fix(ga): Replaces the flawed "top N" logic in both _solve_x_numpy and _solve_x_cuda. The new process is:

    • Dynamically sets a quality_threshold based on the user's root_precision (e.g., precision=5 requires a rank > 1e6).
    • Filters the entire final population for all solutions that meet this quality threshold.
    • Rounds these high-quality solutions to root_precision.
    • Returns only the np.unique() results.

This ensures the solver returns all distinct roots that meet the accuracy requirements, rather than just the top N variations of a single root.

The previous GA logic was returning the "top N" solutions, which led to test failures when the algorithm correctly converged on only one of all possible roots (e.g., returning 1000 variations of -1.0). This commit fixes the root-finding logic to correctly identify and return *all* unique, high-quality roots: 1. **feat(api):** Adds `root_precision` to `GA_Options`. This new parameter (default: 5) allows the user to control the number of decimal places for clustering unique roots. 2. **fix(ga):** Replaces the flawed "top N" logic in both `_solve_x_numpy` and `_solve_x_cuda`. The new process is: * Dynamically sets a `quality_threshold` based on the user's `root_precision` (e.g., `precision=5` requires a rank > `1e6`). * Filters the *entire* final population for all solutions that meet this quality threshold. * Rounds these high-quality solutions to `root_precision`. * Returns only the `np.unique()` results. This ensures the solver returns all distinct roots that meet the accuracy requirements, rather than just the top N variations of a single root.
jono added 1 commit 2025-10-27 19:20:32 +00:00
feat(ga): Implement quality filtering and precision-based clustering
Some checks failed
Run Python Tests / test (3.12) (pull_request) Failing after 10s
Run Python Tests / test (3.10) (pull_request) Failing after 18s
Run Python Tests / test (3.8) (pull_request) Failing after 11s
eff650bf2c
The previous GA logic was returning the "top N" solutions, which led to test failures when the algorithm correctly converged on only one of all possible roots (e.g., returning 1000 variations of -1.0).

This commit fixes the root-finding logic to correctly identify and return *all* unique, high-quality roots:

1.  **feat(api):** Adds `root_precision` to `GA_Options`. This new parameter (default: 5) allows the user to control the number of decimal places for clustering unique roots.

2.  **fix(ga):** Replaces the flawed "top N" logic in both `_solve_x_numpy` and `_solve_x_cuda`. The new process is:
    * Dynamically sets a `quality_threshold` based on the user's `root_precision` (e.g., `precision=5` requires a rank > `1e6`).
    * Filters the *entire* final population for all solutions that meet this quality threshold.
    * Rounds these high-quality solutions to `root_precision`.
    * Returns only the `np.unique()` results.

This ensures the solver returns all distinct roots that meet the accuracy requirements, rather than just the top N variations of a single root.
jono added 1 commit 2025-10-27 19:26:01 +00:00
updated GA tests
All checks were successful
Run Python Tests / test (3.12) (pull_request) Successful in 11s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 12s
9f22d50fc4
jono merged commit 4e46c11f83 into main 2025-10-27 19:26:50 +00:00
jono deleted branch v0.5.0-dev 2025-10-27 19:26:50 +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#19