Commit Graph

44 Commits

Author SHA1 Message Date
4e46c11f83 feat(ga): Implement quality filtering and precision-based clustering (#19)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 12s
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.

Reviewed-on: #19
Co-authored-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
Co-committed-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
2025-10-27 19:26:50 +00:00
962eab5af7 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
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.
2025-10-27 14:33:12 -04:00
7c75000637 fix(ga): Suppress divide-by-zero warning in NumPy solver
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 18s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
The `_solve_x_numpy` method was correctly using `np.where(error == 0, ...)` to handle perfect roots. However, NumPy eagerly calculates `1.0 / error` for the entire array before applying the `where` condition, which was causing a `RuntimeWarning: divide by zero` when a perfect root was found.

This warning was harmless but created unnecessary console noise during testing and use.

This commit wraps the `ranks = ...` assignments in a `with np.errstate(divide='ignore'):` block to silence this specific, expected warning. The CUDA kernel is unaffected as its ternary operator already prevents this calculation.
2025-10-27 12:25:54 -04:00
c3b3513e79 feat(ga, api): Implement advanced GA strategy and refactor API for v0.4.0 (#16)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 18s
This commit introduces a major enhancement to the genetic algorithm's convergence logic and refactors key parts of the API for better clarity and usability.

- **feat(ga):** Re-implements the GA solver (CPU & CUDA) to use a more robust strategy based on Elitism, Crossover, and Mutation. This replaces the previous, less efficient model and is designed to significantly improve accuracy and convergence speed.

- **feat(api):** Updates `GA_Options` to expose the new GA strategy parameters:
    - Renames `mutation_percentage` to `mutation_strength` for clarity.
    - Adds `elite_ratio`, `crossover_ratio`, and `mutation_ratio`.
    - Includes a `__post_init__` validator to ensure ratios are valid.

- **refactor(api):** Moves `quadratic_solve` from a standalone function to a method of the `Function` class (`f1.quadratic_solve()`). This provides a cleaner, more object-oriented API.

- **docs:** Updates the README, `GA_Options` doc page, and `quadratic_solve` doc page to reflect all API changes, new parameters, and updated usage examples.

- **chore:** Bumps version to 0.4.0.

Reviewed-on: #16
Co-authored-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
Co-committed-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
2025-10-27 14:20:56 +00:00
0536003dce Update README.md
Some checks failed
Publish Python Package to PyPI / deploy (push) Has been cancelled
2025-06-30 15:39:47 +00:00
bb89149930 Update .all-contributorsrc
Some checks failed
Publish Python Package to PyPI / deploy (push) Has been cancelled
2025-06-30 15:38:24 +00:00
6596c2df99 typo fix
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 14s
2025-06-19 18:00:29 +00:00
24337cea48 Updated Project urls
Some checks failed
Run Python Tests / test (3.12) (pull_request) Successful in 10s
Run Python Tests / test (3.10) (pull_request) Successful in 14s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Failing after 14s
Signed-off-by: Jonathan Rampersad <jonathan@jono-rams.work>
2025-06-19 17:58:50 +00:00
ee18cc9e59 Added Branding (#14)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 19s
Reviewed-on: #14
2025-06-19 17:54:07 +00:00
ce464cffd4 FEAT: Added support for float coefficients (#13)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 13s
Reviewed-on: #13
Co-authored-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
Co-committed-by: Jonathan Rampersad <rampersad.jonathan@gmail.com>
2025-06-18 13:20:18 +00:00
c94d08498d Edited README to advise of function * function multiplication being available (#12)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 17s
Reviewed-on: #12
2025-06-18 12:55:37 +00:00
3aad9efb61 Merge pull request 'readme-patch' (#11) from readme-patch into main
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 17s
Reviewed-on: #11
2025-06-17 18:37:50 +00:00
32d6cfeeea Update pyproject.toml
All checks were successful
Run Python Tests / test (3.12) (pull_request) Successful in 9s
Run Python Tests / test (3.10) (pull_request) Successful in 13s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 18:37:33 +00:00
8d6fe7aca0 Update README.md
Signed-off-by: Jonathan Rampersad <jonathan@jono-rams.work>
2025-06-17 18:37:17 +00:00
7927845f17 Merge pull request 'v0.2.0' (#10) from v0.2.0-dev into main
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 13s
Reviewed-on: #10
2025-06-17 18:36:25 +00:00
ac591f49ec docs: Added documentation for nth_derivative function
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 13s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
2025-06-17 14:35:03 -04:00
ec97aefee1 feat: Added nth derivative showcase in __main__ 2025-06-17 14:34:16 -04:00
d27497488f fix: differential in README.md renamed to derivative 2025-06-17 14:30:40 -04:00
41daf4f7e0 Remove CONTRIBUTORS.md 2025-06-17 14:30:11 -04:00
36f51ca67e fix: Typo in test
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 13s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
2025-06-17 14:27:53 -04:00
25f20a4db2 v0.2.0
Some checks failed
Run Python Tests / test (3.12) (pull_request) Failing after 11s
Run Python Tests / test (3.10) (pull_request) Failing after 15s
Run Python Tests / test (3.8) (pull_request) Failing after 11s
2025-06-17 14:26:45 -04:00
ee414ea0dc feat: Added function * function multiplication 2025-06-17 14:26:26 -04:00
8656b558b4 feat: Added alternative degree property to return largest_exponent 2025-06-17 14:12:19 -04:00
30a5189928 fix: multiplying by 0 returns a function object representing 0 2025-06-17 14:08:36 -04:00
3d2c724ad4 feat: Add nth derivative function and fix: typo derivitive->derivative 2025-06-17 14:06:45 -04:00
a761efe28e fix: Renamed differential function to derivitive 2025-06-17 13:45:51 -04:00
GitHub Bridge Bot
1165c03955 Apply patch from GitHub PR #10 by jono-rams
Some checks failed
Run Python Tests / test (3.12) (pull_request) Successful in 9s
Run Python Tests / test (3.10) (pull_request) Successful in 14s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
Publish Python Package to PyPI / deploy (push) Has been cancelled
2025-06-17 16:13:43 +00:00
GitHub Bridge Bot
0a36e955a1 Apply patch from GitHub PR #9 by allcontributors[bot]
Some checks failed
Run Python Tests / test (3.10) (pull_request) Successful in 10s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
Publish Python Package to PyPI / deploy (push) Has been cancelled
2025-06-17 13:59:47 +00:00
c896ecaff8 Update .all-contributorsrc
Some checks failed
Run Python Tests / test (3.10) (pull_request) Successful in 10s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Publish Python Package to PyPI / deploy (push) Has been cancelled
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 13:57:37 +00:00
b7073287e5 Update README.md 2025-06-17 13:53:34 +00:00
9c47db4e6a [GitHub PR #7 by jono-rams] All contributors/add jono rams (#6)
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 13s
**Mirrored from GitHub PR `#7` by `jono-rams`**

Original PR: https://github.com/jono-rams/PolySolve/pull/7

---

None

Co-authored-by: GitHub Bridge Bot <bot@yourdomain.com>
Reviewed-on: #6
Co-authored-by: gitea-bot <bot@jono-rams.work>
Co-committed-by: gitea-bot <bot@jono-rams.work>
2025-06-17 13:48:34 +00:00
97e4259bfa Merge pull request '[GitHub PR #6 by allcontributors[bot]] docs: add jono-rams as a contributor for code, doc, and infra' (#5) from github-pr-6 into main
Some checks failed
Publish Python Package to PyPI / deploy (push) Has been cancelled
Reviewed-on: #5
2025-06-17 13:29:43 +00:00
GitHub Bridge Bot
a4b947ee07 Apply patch from GitHub PR #6 by allcontributors[bot]
All checks were successful
Run Python Tests / test (3.10) (pull_request) Successful in 9s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 13:28:43 +00:00
8e8462d9d8 Add contribution badges
Some checks failed
Run Python Tests / test (3.10) (pull_request) Successful in 9s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Has been cancelled
Run Python Tests / test (3.12) (pull_request) Successful in 12s
2025-06-17 09:23:26 -04:00
a4d9f657fe Merge pull request '[GitHub PR #4] Update Contributing and pyproject for GitHub' (#3) from github-pr-4 into main
All checks were successful
Publish Python Package to PyPI / deploy (push) Successful in 20s
Reviewed-on: #3
2025-06-17 13:06:56 +00:00
GitHub Bridge Bot
83f565c08c Apply patch from GitHub PR #4 by jono-rams
All checks were successful
Run Python Tests / test (3.10) (pull_request) Successful in 10s
Run Python Tests / test (3.12) (pull_request) Successful in 15s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 13:05:16 +00:00
78970c8288 Update LICENSE
Some checks failed
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Publish Python Package to PyPI / deploy (push) Has been cancelled
Run Python Tests / test (3.10) (pull_request) Successful in 16s
Run Python Tests / test (3.8) (pull_request) Successful in 14s
Signed-off-by: Jonathan Rampersad <jonathan@jono-rams.work>
2025-06-17 00:09:09 +00:00
30056dc2b5 Only run automated tests on PR
Some checks failed
Run Python Tests / test (3.10) (pull_request) Successful in 11s
Run Python Tests / test (3.12) (pull_request) Successful in 14s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Has been cancelled
2025-06-16 19:40:26 -04:00
2cf2126b90 Added Workflow to automatically deploy to pypi
All checks were successful
Run Python Tests / test (3.10) (push) Successful in 10s
Run Python Tests / test (3.12) (push) Successful in 9s
Publish Python Package to PyPI / deploy (push) Successful in 28s
Run Python Tests / test (3.8) (push) Successful in 10s
2025-06-16 19:28:50 -04:00
593a9de9e0 Removed cuda 11 version for consistency with automated tests
All checks were successful
Run Python Tests / test (3.10) (push) Successful in 11s
Run Python Tests / test (3.12) (push) Successful in 14s
Run Python Tests / test (3.8) (push) Successful in 10s
2025-06-16 19:27:24 -04:00
4fe11a1c31 FIXED: typo in test file
All checks were successful
Run Python Tests / test (3.12) (push) Successful in 10s
Run Python Tests / test (3.8) (push) Successful in 10s
Run Python Tests / test (3.10) (push) Successful in 54s
2025-06-16 19:15:46 -04:00
956c270762 FIXED: typo in test file
Some checks failed
Run Python Tests / test (3.10) (push) Failing after 1m36s
Run Python Tests / test (3.12) (push) Failing after 2m3s
Run Python Tests / test (3.8) (push) Failing after 1m29s
2025-06-16 19:08:51 -04:00
2dc39b6ae3 Initial Commit
Some checks failed
Run Python Tests / test (3.8) (push) Failing after 3s
Run Python Tests / test (3.10) (push) Failing after 12s
Run Python Tests / test (3.12) (push) Failing after 2m0s
2025-06-16 18:40:06 -04:00
d5c69cf285 Initial commit 2025-06-16 21:36:05 +00:00