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.
49 lines
1.5 KiB
TOML
49 lines
1.5 KiB
TOML
[build-system]
|
|
requires = ["setuptools>=61.0"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
# --- Core Metadata ---
|
|
name = "polysolve"
|
|
version = "0.5.0"
|
|
authors = [
|
|
{ name="Jonathan Rampersad", email="jonathan@jono-rams.work" },
|
|
]
|
|
description = "A Python library for representing, manipulating, and solving exponential functions using analytical methods and genetic algorithms, with optional CUDA acceleration."
|
|
readme = "README.md"
|
|
requires-python = ">=3.8"
|
|
license = { file="LICENSE" }
|
|
keywords = ["math", "polynomial", "genetic algorithm", "cuda", "equation solver"]
|
|
|
|
# --- Classifiers ---
|
|
classifiers = [
|
|
"Development Status :: 4 - Beta",
|
|
"Intended Audience :: Developers",
|
|
"Intended Audience :: Science/Research",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Operating System :: OS Independent",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.8",
|
|
"Programming Language :: Python :: 3.9",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Topic :: Scientific/Engineering :: Mathematics",
|
|
]
|
|
|
|
# --- Dependencies ---
|
|
dependencies = [
|
|
"numpy>=1.21"
|
|
]
|
|
|
|
# --- Optional Dependencies (Extras) ---
|
|
[project.optional-dependencies]
|
|
cuda12 = ["cupy-cuda12x"]
|
|
dev = ["pytest"]
|
|
|
|
[project.urls]
|
|
Homepage = "https://polysolve.jono-rams.work"
|
|
Documentation = "https://polysolve.jono-rams.work/docs"
|
|
Repository = "https://github.com/jono-rams/PolySolve"
|
|
"Bug Tracker" = "https://github.com/jono-rams/PolySolve/issues"
|