Solvers
Basin ships a large catalog of optimization solvers driven by the same Executor loop, plus a direct scalar root-finding API. Pick an optimization
solver based on what your problem provides (a gradient? only costs? residuals?)
and whether it is constrained.
Each algorithm name links to its API page on docs.rs; the trailing note cites the paper it implements (or the source it ports).
Root Finding
BrentRoot: bracketed scalar root finding by bisection, secant steps, and inverse quadratic interpolation (Brent, 1971). It uses a direct fallible-closure API rather thanExecutor, preserving the signed function value and final bracket in a root-specific result.
First-Order
GradientDescent: steepest descent with a pluggable step rule (Constant,Backtracking,MoreThuente,Wolfe, orHagerZhangline searches) and optional heavy-ball momentum (Polyak, 1964).Sgd: mini-batch stochastic gradient descent with a constant learning rate and optional Polyak (1964) heavy-ball momentum.ProjectedGradientDescent: gradient descent for box-constrained problems, projecting each step back onto the feasible box.BrentDerivative: Brent’s method using first derivatives (“dbrent”): 1-D minimization on a bracketed interval, the gradient-using sibling ofBrent/GoldenSection(uses the sign off'to bracket and secant extrapolation onf'to step; Brent, 1973, as transcribed in Numerical Recipes §10.3).
Derivative-Free
NelderMead: the classic reflection, expansion, and contraction simplex; needs only aCostFunction. Implements Lagarias et al. (1998);NelderMead::adaptive()uses the dimension-aware coefficients of Gao & Han (2012). Its projected variant clamps trial points into box bounds; useGbnmfor the full Luersen–Le Riche restart algorithm.Mads: mesh adaptive direct search (the deterministic OrthoMADS instance): polls a positive spanning set of2ndirections on a shrinking mesh, generated from the Halton sequence and a scaled Householder reflection. Unlike Nelder-Mead it has a convergence guarantee on nonsmooth or non-continuous objectives, a box-constrained variant (Mads::bounded()) via the extreme barrier, and a nonlinearly-constrained variant (Mads::constrained()) handlingc(x) ≤ 0via the progressive barrier (which tolerates an infeasible start). Needs only aCostFunction(plusNonlinearInequalityConstraintsfor the constrained mode). Implements Audet & Dennis (2006), OrthoMADS (Abramson, Audet, Dennis & Le Digabel 2009), and the progressive barrier (Audet & Dennis 2009).Newuoa: Powell’s model-based trust-region method: maintains a quadratic surrogate interpolating the objective on2n+1points and updates it by the least-Frobenius-norm rule, so each iteration needs only one new value. Needs only aCostFunction. Implements Powell (2006), cross-validated against PRIMA v0.7.2.Bobyqa: the bound-constrained sibling ofNewuoa: the same least-Frobenius-norm quadratic model, with a box-aware trust-region step (TRSBOX) and geometry step (ALTMOV), plus the RESCUE restoration procedure. Needs aCostFunctionandBoxConstraints. Implements Powell (2009), cross-validated against PRIMA v0.7.2.Lincoa: the linearly-constrained sibling ofNewuoa: the same least-Frobenius-norm quadratic model, with a projected truncated-CG trust-region step (TRSTEP) and active-set QR (GETACT) that keep every iterate feasible underA x ≤ b. Needs aCostFunctionandLinearConstraints(the general linear form: box bounds, equalities, and inequalities, all folded intoA x ≤ b). Implements Powell (2015), ported from PRIMA v0.7.2.Cobyla: the nonlinearly-constrained Powell solver, and the odd one out: instead of a quadratic model it builds linear models by interpolation at then+1vertices of a simplex and steers by an L-infinity exact-penalty merit function, so it is the only one handling general nonlinear inequality constraintsc(x) ≤ 0. Needs aCostFunctionandNonlinearInequalityConstraints. Implements Powell (1994), ported from PRIMA.SolisWets: adaptive random local search: a randomized hill-climber testingx + b + dandx − b − dwithd ~ N(0, ρ²I), a success-direction biasb, and a step sizeρthat expands after 5 successive successes and contracts after 3 failures. The cheapest local search in the library (O(n) memory and time, cost evaluations only) and the classic memetic LS operator. Needs only aCostFunction. Implements Solis & Wets (1981).Brent: robust 1-D minimization on a bracketed interval (Brent, 1973, as transcribed in Numerical Recipes §10.2); also used inside line searches.GoldenSection: golden-section search: 1-D minimization on a bracketed interval, the robust linearly-converging companion toBrent(Kiefer, 1953; Numerical Recipes §10.1).
Quasi-Newton
Bfgs: dense quasi-Newton with a full approximate Hessian (Nocedal & Wright, 2006).Lbfgs: limited-memory BFGS for larger problems (two-loop recursion, Nocedal & Wright Alg. 7.4).Lbfgsb: L-BFGS with box bounds; a faithful port of the Nocedal–Zhu L-BFGS-B v3.0 Fortran source (Byrd, Lu & Nocedal, 1995; Zhu, Byrd, Lu & Nocedal, 1997, ACM TOMS Alg. 778).
Trust Region
For problems exposing a Hessian or, matrix-free, a HessianProduct (either
analytic, or synthesized by FiniteDiff):
TrustRegion: second-order trust-region Newton minimizer (Nocedal & Wright, 2006, Alg. 4.1). The subproblem strategy is pluggable:Steihaug(truncated CG, the default),Dogleg,MoreSorensen(the near-exact secular solve with hard-case treatment; Moré & Sorensen, 1983, “Computing a Trust Region Step”), orCauchyPoint.TrustRegion::matrix_free()drives the subproblem purely through Hessian-vector products (HessianProduct), never forming a matrix, so it scales to large problems (SteihaugandCauchyPointonly;DoglegandMoreSorensenneed the matrix).
Nonlinear Least Squares
For problems expressed as residuals (Residual + Jacobian):
GaussNewton: undamped normal-equations solver (Madsen, Nielsen & Tingleff, 2004, §3.1).LevenbergMarquardt: damped least squares; the workhorse for curve fitting. Marquardt (1963) with Nielsen’s (1999) smooth damping update and Moré (1978)/MINPACK column scaling (Madsen, Nielsen & Tingleff, 2004, §3.2).Trf: trust-region reflective: Levenberg–Marquardt with box bounds (Branch, Coleman & Li, 1999, affine scaling).
Global & Stochastic
Gbnm: Globalized Bounded Nelder-Mead over a feasible box. It combines projected local simplex searches with Parzen-density probabilistic restarts and the small-, flat-, and degenerate-simplex restart state machine. It retains the possible local optima found along the way and supports exact solver-aware resume. Implements M. A. Luersen and R. Le Riche, “Globalized Nelder–Mead method for engineering optimization,” Computers & Structures 82 (2004), 2251–2260 (doi:10.1016/j.compstruc.2004.03.072).SimulatedAnnealing: classical single-proposal simulated annealing with a user-suppliedNeighbor, explicit geometric, reciprocal, or normalized-log cooling, and optional independently composable schedule restart triggers. It accepts arbitrary cloneable parameter types, including discrete structures, and supports exact solver-aware resume. Uses Metropolis et al. (1953; DOI 10.1063/1.1699114), implements Kirkpatrick, Gelatt & Vecchi (1983; DOI 10.1126/science.220.4598.671), and takes its logarithmic-schedule context from Hajek (1988; DOI 10.1287/moor.13.2.311).CmaEs/BoundedCmaEs: covariance-matrix adaptation evolution strategy (Hansen, 2016), unconstrained and box-bounded; the bounded variant uses Hansen’s adaptiveBoundPenalty(thepycmadefault).De: differential evolution (DE/rand/1/bin) over a feasible box (Storn & Price, 1997).GlobalBestPso: synchronous inertia-weight global-best particle swarm optimization over a feasible box, with independent boundary-response and velocity-limit policies. Implements Kennedy & Eberhart’s (1995; DOI 10.1109/ICNN.1995.488968) update with Shi & Eberhart’s inertia formulation (1998; DOI 10.1109/ICEC.1998.699146) and the Standard PSO 2006 coefficient/population profile (Bratton & Kennedy, 2007; DOI 10.1109/SIS.2007.368035), and is cross-validated against Argmin 0.11.0 commitc94c32adefd6c2525ce05806092ca868ec85fba4. It remains distinct from SPSO-2011 (Zambrano-Bigiarini, Clerc & Rojas, 2013; DOI 10.1109/CEC.2013.6557848).RandomSearch: elitist (1+λ) uniform sampling over a box.Ssga: steady-state real-coded genetic algorithm (replace-worst) with BLX-α crossover (Eshelman & Schaffer, 1993), negative assortative mating (Fernandes & Rosa, 2001), and BGA mutation (Mühlenbein & Schlierkamp-Voosen, 1993); the SSGA component of Molina et al. (2010), §4.4.BasinHopping: basin-hopping (Wales & Doye, 1997): a Metropolis Monte-Carlo walk over theẼ(x) = min{f(x)}transform, wrapping any local solver with a pluggable step taker and acceptance test; adaptive step size on by default.
Memetic (Composed)
These run a local solver inside a global one, an example of Basin’s solver composition primitives:
CmaInject/BoundedCmaInject: CMA-ES with per-generation local polishing of the best individuals, re-injected via Hansen’s (2011) injection mechanism.DeInject: the DE-flavored sibling ofCmaInject: differential evolution (Storn & Price, 1997) with per-generation top-k local refinement and Hansen-style (2011) injection.MaLsChCma: a memetic algorithm with persistent local-search chains and a CMA-ES inner (Molina et al., 2010).MaLsChSw: the high-dimensional sibling ofMaLsChCma: the same local-search-chain framework with a Solis-Wets inner, whose O(n) chain snapshots keep chain-memetic search viable when the dimension grows (MA-SW-Chains: Molina, Lozano, and Herrera, 2010, winner of the CEC’2010 large-scale competition). Both are type aliases of the genericMaLsCh<V, LS>, which accepts any local-search operator implementing theResumableInner(seed + snapshot + resume) trait.
Constrained (Composed)
These wrap any gradient inner solver in an outer loop that handles linear constraints:
BarrierMethod: two-phase log-barrier interior-point continuation for linear inequality constraints (A x ≤ b); automatically finds a strictly feasible start when one exists (Boyd & Vandenberghe, Convex Optimization, §§11.3–11.4.1).AugmentedLagrangianMethod: quadratic penalty plus multiplier updates for linear equality constraints (A x = b); tolerates an infeasible start (Nocedal & Wright, §17.3, Alg. 17.4, LANCELOT-style).
The pluggable line searches are documented alongside the first-order solvers: Backtracking (Armijo; Nocedal & Wright §3.1), Wolfe (strong Wolfe; Nocedal & Wright Alg. 3.5/3.6), MoreThuente (Moré & Thuente, 1994; a port of MINPACK-2’s dcsrch), and HagerZhang (ordinary and approximate Wolfe; Hager & Zhang, 2005, DOI
10.1137/030601880).
Backends and Constraints
Two design rules shape which solver you can use where:
- Constraints are first-class and type-checked. Box bounds live on the problem (
BoxConstraints). Handing a constrained problem to an unconstrained solver is a compile error, not a runtime surprise. - Backends are tiered. First-order and derivative-free solvers stay generic
over the parameter type (
Vec<f64>, nalgebra, ndarray, faer). Linear-algebra heavy solvers (the quasi-Newton and least-squares families) require a backend that implements the richer math they need, so an unsupported parameter type fails to compile rather than at runtime.
The matrix below summarizes support: ✓ means it compiles and runs on that parameter type, ✗ means it is a compile-time error (the tiering rule above).
| Solver | Family | Vec<f64> | nalgebra | ndarray | faer |
|---|---|---|---|---|---|
GradientDescent | First-order | ✓ | ✓ | ✓ | ✓ |
Sgd | First-order | ✓ | ✓ | ✓ | ✓ |
ProjectedGradientDescent | First-order | ✓ | ✓ | ✓ | ✓ |
NelderMead | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Mads | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Newuoa | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Bobyqa | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Lincoa | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Cobyla | Derivative-free | ✓ | ✓ | ✓ | ✓ |
SolisWets | Derivative-free | ✓ | ✓ | ✓ | ✓ |
Brent | Derivative-free | — | — | — | — |
BrentRoot | Root finding | — | — | — | — |
GoldenSection | Derivative-free | — | — | — | — |
BrentDerivative | First-order | — | — | — | — |
Bfgs | Quasi-Newton | ✓ | ✓ | ✓ | ✓ |
Lbfgs | Quasi-Newton | ✓ | ✓ | ✓ | ✓ |
Lbfgsb | Quasi-Newton | ✓ | ✓ | ✓ | ✓ |
TrustRegion | Trust region | ✓ | ✓ | ✓‡ | ✓ |
GaussNewton | Least squares | ✓ | ✓ | ✓ | ✓ |
LevenbergMarquardt | Least squares | ✓ | ✓ | ✓ | ✓ |
Trf | Least squares | ✓ | ✓ | ✓ | ✓ |
Gbnm | Global | ✓ | ✓ | ✓ | ✓ |
SimulatedAnnealing | Global | ✓ | ✓ | ✓ | ✓ |
CmaEs | Global | ✓ | ✓ | ✓ | ✓ |
BoundedCmaEs | Global | ✓ | ✓ | ✓ | ✓ |
De | Global | ✓ | ✓ | ✓ | ✓ |
GlobalBestPso | Global | ✓ | ✓ | ✓ | ✓ |
RandomSearch | Global | ✓ | ✓ | ✓ | ✓ |
Ssga | Global | ✓ | ✓ | ✓ | ✓ |
BasinHopping | Global | ✓† | ✓ | ✓† | ✓ |
CmaInject | Memetic | ✓ | ✓ | ✓ | ✓ |
BoundedCmaInject | Memetic | ✓ | ✓ | ✓ | ✓ |
DeInject | Memetic | ✓† | ✓ | ✓† | ✓ |
MaLsChCma | Memetic | ✓ | ✓ | ✓ | ✓ |
MaLsChSw | Memetic | ✓§ | ✓§ | ✓§ | ✓§ |
BarrierMethod | Constrained | ✓ | ✓ | ✓ | ✓ |
AugmentedLagrangianMethod | Constrained | ✓ | ✓ | ✓ | ✓ |
Brent, GoldenSection, and BrentDerivative minimize over a scalar interval; BrentRoot finds a bracketed scalar zero directly. All four support f64 and f32, so the vector-backend choice does not apply.
† DeInject and BasinHopping are themselves backend-generic, but their
effective coverage is the intersection of the outer driver and the chosen inner
solver. The shipped inners (NelderMead, LevenbergMarquardt, Lbfgsb) are
all backend-generic, so a backend-specific inner of your own is the only thing
that would narrow it.
§ MaLsChSw bounds only on the vector tier—no matrix type is involved at all,
unlike MaLsChCma, whose inner CMA-ES needs each backend’s symmetric
eigendecomposition.
‡ TrustRegion’s coverage depends on the subproblem strategy: Steihaug (the
default) and CauchyPoint need only matrix-vector products, so they run on
every backend; Dogleg additionally needs a Cholesky solve (LinearSolveSpd),
now available on all four backends. MoreSorensen additionally needs a
symmetric eigendecomposition (SymmetricEigen), also available on all four
dense backends. In exact mode on ndarray the Hessian must be supplied
analytically as an Array2<f64>; FiniteDiff cannot synthesize one there (no
dense-matrix constructor). Matrix-free mode has no such caveat: no matrix type
is bound at all, and FiniteDiff synthesizes the Hessian-vector product on
every backend.
Each algorithm’s page on docs.rs carries a Backends note listing exactly which parameter types it supports.
See Getting Started for a worked example, or open the Visualizer to watch several of these solvers converge.