Solvers

Basin ships a growing catalogue of solvers, all driven by the same Executor loop. Pick one based on what your problem provides (a gradient? only costs? residuals?) and whether it is constrained.

Each solver name links to its API page on docs.rs; the trailing note cites the paper it implements (or the source it ports).

First-order

  • GradientDescent — steepest descent with a pluggable step rule (Constant, Backtracking, MoreThuente, or Wolfe line 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 of Brent / GoldenSection (uses the sign of f' to bracket and secant extrapolation on f' to step; Brent, 1973, as transcribed in Numerical Recipes §10.3).

Derivative-free

  • NelderMead — the classic reflection / expansion / contraction simplex; needs only a CostFunction. Implements Lagarias et al. (1998); NelderMead::adaptive() uses the dimension-aware coefficients of Gao & Han (2012), and the projected variant follows Luersen & Le Riche (2004).
  • 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 to Brent (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).

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

  • CmaEs / BoundedCmaEs — covariance-matrix adaptation evolution strategy (Hansen, 2016), unconstrained and box-bounded; the bounded variant uses Hansen’s adaptive BoundPenalty (the pycma default).
  • De — differential evolution (DE/rand/1/bin) over a feasible box (Storn & Price, 1997).
  • 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.

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 of CmaInject: 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).

Constrained (composed)

These wrap any gradient inner solver in an outer loop that handles linear constraints:

  • BarrierMethod — log-barrier interior-point continuation for linear inequality constraints (A x ≤ b); needs a strictly feasible start (Boyd & Vandenberghe, Convex Optimization, §11.3, Alg. 11.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), and MoreThuente (Moré & Thuente, 1994; a port of MINPACK-2’s dcsrch).

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).

SolverFamilyVec<f64>nalgebrandarrayfaer
GradientDescentFirst-order
SgdFirst-order
ProjectedGradientDescentFirst-order
NelderMeadDerivative-free
BrentDerivative-free
GoldenSectionDerivative-free
BrentDerivativeFirst-order
BfgsQuasi-Newton
LbfgsQuasi-Newton
LbfgsbQuasi-Newton
GaussNewtonLeast squares
LevenbergMarquardtLeast squares
TrfLeast squares
CmaEsGlobal
BoundedCmaEsGlobal
DeGlobal
RandomSearchGlobal
SsgaGlobal
CmaInjectMemetic
BoundedCmaInjectMemetic
DeInjectMemetic✓†✓†
MaLsChCmaMemetic
BarrierMethodConstrained
AugmentedLagrangianMethodConstrained

Brent, GoldenSection, and BrentDerivative minimize over a scalar f64 interval (1-D), so the vector-backend choice does not apply.

DeInject is itself backend-generic, but its effective coverage is the intersection of De and the chosen inner solver: a LevenbergMarquardt or Lbfgsb inner narrows it to nalgebra / faer.

Each solver’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.