Basin: Efficient and Extensible Numerical Optimization in Rust

Larsson, Johan

–arXiv.org Artificial Intelligence 

Basin is a numerical optimization library for the Rust programming language (Matsakis & Klock, 2014). Numerical optimization is the task of finding the inputs that minimize a function, and it is a fundamental element across the sciences: fitting a model to data, calibrating a simulation, training a machine learning model, or choosing engineering parameters that minimize cost. Basin gives users a single, consistent way to both state and solve such problems, with a broad catalog of solvers and first-class support for constraints. To use Basin, a user implements one or more small traits describing their objective--at minimum a CostFunction that returns a value for a given input, and optionally its derivatives (Gradient, Jacobian, or Hessian). The user then hands the problem, a solver, and a starting point to an Executor, which drives the optimization loop, handles stopping criteria, and returns the result. Basin works out of the box on plain Rust vectors and, optionally, with faster linearalgebra backends available behind feature flags. The default build compiles to WebAssembly, which means that Basin can be used in a browser without a native toolchain or BLAS/LAPACK support. Documentation is published at basin.rs, which includes a user guide, interactive visualizer, and a benchmark suite comparing Basin to other optimization libraries.