basin
Library Listed
Numerical optimization in pure Rust, with pluggable linear-algebra backends and WASM support.
- Downloads
- 22,519
- Dependents
- 9
- Stars
- 128
- Forks
- 6
- Contributors
- 6
- Commits
- 728
- Latest release
- 3.2.0 ·
About
Basin is a numerical optimization library for Rust. Solve problems with or without derivatives, fit models with nonlinear least squares, and handle bounds and other constraints with algorithms suited to your problem. Basin also provides a solver for bracketed scalar equations.
Define the function you want to minimize, choose a solver, and supply a starting point. Use plain Rust vectors or your choice of nalgebra, ndarray, or faer. Basin runs natively and in the browser, with no BLAS/LAPACK or threads required by the default build. Its design is inspired by argmin.
See the documentation at basin.rs/guide or browse the API reference at docs.rs/basin. There is also an in-browser solver visualizer and a benchmarks site comparing Basin against competing crates and across backends and solvers.
To port an existing Argmin project, see Migrating from Argmin.
Install
cargo add basin
Basin works on plain Vec<f64> out of the box. Linear-algebra backends are
opt-in. Use a moving alias to follow the newest supported release:
cargo add basin --features nalgebra # or: ndarray, faer
Read the full README
Exact version features, such as nalgebra_v0_34, keep dependency resolution
stable. Basin's package minimum supported Rust version (MSRV) is 1.87.0. The
one exception is nalgebra 0.35: nalgebra_v0_35 and nalgebra require Rust
1.89.
Example
Implement CostFunction (and Gradient when the solver needs derivatives),
then hand the problem, a solver, and an initial state to the Executor:
use basin::{
CostFunction, Executor, FirstOrderState, Gradient, GradientDescent,
};
use std::convert::Infallible;
struct Rosenbrock;
fn main() {
impl CostFunction for Rosenbrock {
type Param = Vec<f64>;
type Output = f64;
type Error = Infallible;
fn cost(&self, x: &Vec<f64>) -> Result<f64, Self::Error> {
Ok((1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2))
}
}
impl Gradient for Rosenbrock {
type Gradient = Vec<f64>;
fn gradient(&self, x: &Vec<f64>) -> Result<Vec<f64>, Self::Error> {
Ok(vec![
-2.0 * (1.0 - x[0]) - 400.0 * x[0] * (x[1] - x[0].powi(2)),
200.0 * (x[1] - x[0].powi(2)),
])
}
}
let result = Executor::new(
Rosenbrock,
(GradientDescent::new(1e-3)).with_absolute_gradient_tolerance(1e-6),
FirstOrderState::new(vec![-1.2, 1.0]),
)
.max_iter(50_000)
.run()
.unwrap();
println!(
"x = {:?}, f = {}, stopped: {:?}",
result.param(),
result.cost(),
result.report.termination
);
}
Solvers
- First-order, quasi-Newton, and Newton: gradient descent (with momentum and pluggable line searches), SGD, BFGS, L-BFGS, L-BFGS-B, and a Newton trust-region method.
- Derivative-free: Nelder-Mead; Brent, Brent-with-derivatives, and golden-section search (1D); Powell's model-based family (NEWUOA, BOBYQA, LINCOA, COBYLA); and MADS (OrthoMADS).
- Nonlinear least squares: Gauss-Newton, Levenberg-Marquardt, trust-region reflective.
- Global and stochastic: Globalized Bounded Nelder-Mead, simulated annealing, random search, CMA-ES, differential evolution, a steady-state genetic algorithm, and memetic combinations (MA-LS-Chain, plus CMA-ES and DE injection wrappers).
- Constrained: box bounds via projected gradient descent, bounded Nelder-Mead, Globalized Bounded Nelder-Mead, L-BFGS-B, and bounded CMA-ES; LINCOA for linear constraints and COBYLA for nonlinear inequalities; log-barrier and augmented Lagrangian wrappers for more general constraints.
- Root finding: Brent's bracketed scalar method through the direct
BrentRoot::solveAPI.
See Solvers for which backends each one supports.
Backends
Parameters and linear algebra are generic over the backend. Vec<f64> needs no
features. Each external backend has exact version features and an unversioned
alias that tracks the newest supported release:
| Backend | Exact features | Moving alias |
|---|---|---|
| nalgebra | nalgebra_v0_32 through nalgebra_v0_35 | nalgebra |
| ndarray | ndarray_v0_15 through ndarray_v0_17 | ndarray |
| faer | faer_v0_22 through faer_v0_24 | faer |
Every nalgebra feature includes its matching nalgebra-sparse release:
0.32/0.9, 0.33/0.10, 0.34/0.11, and 0.35/0.12. Exact acceleration features
follow the same naming scheme—nalgebra_v0_34-lapack and ndarray_v0_16-blas,
for example. The moving aliases are nalgebra-lapack and ndarray-blas.
Citation
If you use Basin in your research, please cite the paper:
Larsson, J. (2026). Basin: Efficient and Extensible Numerical Optimization in Rust (arXiv:2608.11279). arXiv. https://doi.org/10.48550/arXiv.2608.11279
@misc{larsson2026basin,
title = {Basin: Efficient and Extensible Numerical Optimization in {{Rust}}},
shorttitle = {Basin},
author = {Larsson, Johan},
year = {2026},
month = aug,
number = {arXiv:2608.11279},
eprint = {2608.11279},
primaryclass = {cs.LG},
publisher = {arXiv},
doi = {10.48550/arXiv.2608.11279},
archiveprefix = {arXiv}
}
BibLaTeX
@online{larsson2026basin,
title = {Basin: Efficient and Extensible Numerical Optimization in {{Rust}}},
shorttitle = {Basin},
author = {Larsson, Johan},
date = {2026-08-11},
eprint = {2608.11279},
eprinttype = {arXiv},
eprintclass = {cs.LG},
doi = {10.48550/arXiv.2608.11279},
pubstate = {prepublished}
}
For reproducibility, also cite the software release you used. Select that
release in the Zenodo archive and
export its citation. The concept DOI 10.5281/zenodo.20610944 identifies Basin
across all releases.
CITATION.cff contains the software metadata and preferred paper citation, and basin.rs/guide renders the paper in APA, BibTeX, and BibLaTeX.
Acknowledgements
Basin owes a substantial intellectual debt to argmin: the Executor driver
loop, the Solver/Problem trait split, and per-solver State are borrowed
from it, and several solver implementations and test-problem conventions were
modeled on argmin's. Thanks to the argmin authors and contributors for a library
that is a pleasure to learn from.
The Powell-family derivative-free solvers (COBYLA, NEWUOA, BOBYQA, LINCOA) are derived from PRIMA, Zaikun Zhang's modern-Fortran reference implementation of M. J. D. Powell's methods, used as the authoritative source for the exact formulas and as the cross-validation oracle. PRIMA is distributed under the BSD 3-Clause License; its notice is retained in COPYRIGHT.
The bound-constrained L-BFGS-B solver is a port of the L-BFGS-B version 3.0 Fortran code by Ciyou Zhu, Richard H. Byrd, Peihuang Lu, and Jorge Nocedal (ACM TOMS Algorithm 778), with the v3.0 improvements by José Luis Morales and Jorge Nocedal. It is released under the New BSD (BSD 3-Clause) License; its notice is likewise retained in COPYRIGHT.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your convenience.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- Optional
- Binds native code: blas-sys (feature nalgebra_latest-lapack), lapack-sys (feature nalgebra_latest-lapack)
- Python bindings
- No Python binding crate found
- License
- Apache-2.0 OR MIT
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Numerical optimization in pure Rust, with pluggable linear-algebra backends and WASM support. |
22,519 downloads over 30 days | 9 | 128 | 3.2.0 | GPU support unknown | Binds native code: blas-sys (feature nalgebra_latest-lapack), lapack-sys (feature nalgebra_latest-lapack) | Apache-2.0 OR MIT |
|
nalgebra Featured
General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices. |
6,251,820 downloads over 30 days | 2,119 | 4,810 | 0.35.0 | GPU support unknown | Binds native code: blas-sys, lapack-sys, defmt (feature defmt) | Apache-2.0 |
|
argmin Featured
Numerical optimization in pure Rust |
310,783 downloads over 30 days | 98 | 1,278 | 0.11.0 | GPU support unknown | Binds native code: lapack-sys (feature ndarray_v0_15) | Apache-2.0 OR MIT |
|
Pure-Rust implementation of linear algebra routines for ndarray |
198,623 downloads over 30 days | 20 | 39 | 0.2.1 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
peroxide Listed
Rust comprehensive scientific computation library contains linear algebra, numerical analysis, statistics and machine learning tools with familiar syntax Python bindings |
56,548 downloads over 30 days | 9 | 732 | 0.43.1 | GPU support unknown | Binds native code: openblas-src (feature O3-openblas-system), blas-sys (feature O3), hdf5-metno-sys (feature nc), lapack-sys (feature O3), libz-sys (feature nc) and 1 more | Apache-2.0 OR MIT |
|
numr Listed
The base for numerical code in Rust, in the role NumPy has in Python: n-dimensional tensors, linear algebra, FFT, statistics and autograd on CPU, CUDA and WebGPU. The backends use native kernels, with no cuBLAS, MKL or other vendor math library. |
1,673 downloads over 30 days | 7 | 59 | 0.15.2 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- It has 6 active dependents and 6 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 128 stars, 6 forks and 6 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.
What else the check found
- The last activity is on 6 Nov 2026, 3 days ago. The rules expect an update within 365 days. Dormancy rule
Exact rules: Listed, Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 3.2.0 base 200, raised to the 365-day floor: E = 365 daysdormancy: last activity 2026-11-06, 3 days ago, E = 365: activefeatured: not featured: active_users 6 < 11 and new_adopters 6 < 9 and repository route stars 128 (needs 4539), forks 6 (needs 434), contributors 6 (needs 79)listed: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption6 active dependents, 6 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 6 | crates.io database dump | Yes | |
| New dependents (365 days) | 6 | crates.io database dump | Yes | |
| Peak active dependents | 6.5 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 3 days ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-11-06 | GitHub repository | Yes | |
| Latest release | 2026-11-02 | crates.io database dump | Yes | |
| First release | 2026-04-30 | crates.io database dump | Yes | |
| Latest version | 3.2.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 0 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 28 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution37 releases, 22,519 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 37 | crates.io database dump | Yes | |
| Downloads over 30 days | 22519 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository128 stars, 6 forks, 6 contributors, 728 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 128 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 6 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 6 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 728 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 OR MIT | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | Binds native code: blas-sys (feature nalgebra_latest-lapack), lapack-sys (feature nalgebra_latest-lapack) | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 9 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.