[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81867":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":13,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":14,"forks30d":14,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":14,"starSnapshotCount":14,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},81867,"basin","jolars\u002Fbasin","jolars","Numerical optimization in pure Rust, with pluggable linear-algebra backends and WASM support.","https:\u002F\u002Fbasin.bz\u002F",null,"Rust",90,1,0,9,14,68,27,0.9,"MIT License",false,"main",true,[25,26,27,28,29],"minimization","nonlinear-optimization","numerical-optimization","numerics","solvers","2026-06-12 02:04:20","# Basin \u003Cpicture>\u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fjolars\u002Fbasin\u002Fmain\u002Fimages\u002Flogo-dark.png\" \u002F>\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fjolars\u002Fbasin\u002Fmain\u002Fimages\u002Flogo.png\" align=\"right\" width=\"189\" alt=\"basin logo\" \u002F>\u003C\u002Fpicture>\n\n[![CI](https:\u002F\u002Fgithub.com\u002Fjolars\u002Fbasin\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fjolars\u002Fbasin\u002Factions\u002Fworkflows\u002Fci.yml)\n[![crates.io](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fbasin.svg)](https:\u002F\u002Fcrates.io\u002Fcrates\u002Fbasin)\n[![docs.rs](https:\u002F\u002Fimg.shields.io\u002Fdocsrs\u002Fbasin)](https:\u002F\u002Fdocs.rs\u002Fbasin)\n\nA numerical optimization library for Rust, inspired by [argmin]. It pairs a\nsmall generic core, problem traits you implement, a pluggable termination layer,\nand a driver loop (`Executor`), with a growing set of solvers spanning\nfirst-order, derivative-free, nonlinear least-squares, and evolutionary methods.\nSolvers are generic over the linear-algebra backend, constraints are\nfirst-class, and the default build compiles to `wasm32-unknown-unknown` with no\nBLAS\u002FLAPACK or threads.\n\nNarrative documentation lives at [basin.bz\u002Fdocs]; the rustdoc reference is at\n[docs.rs\u002Fbasin]. There is also an in-browser [solver visualizer] and a\n[benchmarks site] comparing Basin against competing crates and across backends\nand solvers.\n\n## Install\n\n```sh\ncargo add basin\n```\n\nBasin works on plain `Vec\u003Cf64>` out of the box. Linear-algebra backends are\nopt-in, one feature each:\n\n```sh\ncargo add basin --features nalgebra  # or: ndarray, faer\n```\n\n## Example\n\nImplement `CostFunction` (and `Gradient`, when the solver needs derivatives),\nthen hand the problem, a solver, and an initial state to the `Executor`:\n\n```rust\nuse basin::{BasicState, CostFunction, Executor, Gradient, GradientDescent, GradientTolerance};\nuse std::convert::Infallible;\n\nstruct Rosenbrock;\n\nimpl CostFunction for Rosenbrock {\n    type Param = Vec\u003Cf64>;\n    type Output = f64;\n    type Error = Infallible;\n    fn cost(&self, x: &Vec\u003Cf64>) -> Result\u003Cf64, Self::Error> {\n        Ok((1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2))\n    }\n}\n\nimpl Gradient for Rosenbrock {\n    type Gradient = Vec\u003Cf64>;\n    fn gradient(&self, x: &Vec\u003Cf64>) -> Result\u003CVec\u003Cf64>, Self::Error> {\n        Ok(vec![\n            -2.0 * (1.0 - x[0]) - 400.0 * x[0] * (x[1] - x[0].powi(2)),\n            200.0 * (x[1] - x[0].powi(2)),\n        ])\n    }\n}\n\nlet result = Executor::new(Rosenbrock, GradientDescent::new(1e-3), BasicState::new(vec![-1.2, 1.0]))\n    .max_iter(50_000).terminate_on(GradientTolerance(1e-6))\n    .run()\n    .unwrap();\n\nprintln!(\"x = {:?}, f = {}, stopped: {:?}\", result.param(), result.cost(), result.reason);\n```\n\nTermination criteria are framework-level: the same ones compose across solvers,\nand they are bound to the state a solver actually exposes --- so asking for a\ngradient tolerance on a derivative-free solver is a compile error, not a runtime\nsurprise.\n\n## Solvers\n\n- **First-order\u002Fquasi-Newton:** gradient descent (with momentum and pluggable\n  line searches), BFGS, L-BFGS, L-BFGS-B.\n- **Derivative-free:** Nelder--Mead, Brent (1D).\n- **Nonlinear least squares:** Gauss--Newton, Levenberg--Marquardt, trust-region\n  reflective.\n- **Global\u002Fstochastic:** random search, CMA-ES, a steady-state genetic\n  algorithm, and memetic combinations.\n- **Constrained:** box bounds via projected gradient descent, bounded\n  Nelder--Mead, L-BFGS-B, and bounded CMA-ES; log-barrier and augmented\n  Lagrangian wrappers for more general constraints.\n\nSee [Solvers] for which backends each one supports.\n\n## Backends\n\nParameters and linear algebra are generic over the backend. `Vec\u003Cf64>` needs no\nfeatures; [nalgebra], [ndarray], and [faer] are enabled one feature each, each\npinning a single major version. First-order and derivative-free solvers run on\nany backend; linear-algebra-heavy solvers may require a specific one and say so\nin their docs.\n\nThe default build is wasm-friendly: no BLAS\u002FLAPACK and no threads. Parallelism\nand BLAS-backed paths are behind opt-in features (`parallel`).\n\n## Status\n\nThe public API is still iterating and breaking changes are expected. WebAssembly\nbindings (`basin-wasm`) power the visualizer but are not published to a package\nregistry yet.\n\n## Acknowledgements\n\nBasin owes a substantial intellectual debt to [argmin]: the overall shape of the\ncrate: the `Executor` driver loop, the `Solver` \u002F `Problem` trait split,\nper-solver `State`, and the pluggable termination layer is borrowed from it, and\nseveral solver implementations and test-problem conventions were modeled on\nargmin's. Thanks to the argmin authors and contributors for a library that is a\npleasure to learn from.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  \u003Chttps:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0>)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or\n  \u003Chttps:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT>)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n[argmin]: https:\u002F\u002Fgithub.com\u002Fargmin-rs\u002Fargmin\n[nalgebra]: https:\u002F\u002Fnalgebra.rs\n[ndarray]: https:\u002F\u002Fgithub.com\u002Frust-ndarray\u002Fndarray\n[faer]: https:\u002F\u002Ffaer.veganb.tw\n[basin.bz\u002Fdocs]: https:\u002F\u002Fbasin.bz\u002Fdocs\u002F\n[docs.rs\u002Fbasin]: https:\u002F\u002Fdocs.rs\u002Fbasin\n[solver visualizer]: https:\u002F\u002Fbasin.bz\u002Fvisualizer\u002F\n[benchmarks site]: https:\u002F\u002Fbasin.bz\u002Fbenchmarks\u002F\n[Solvers]: https:\u002F\u002Fbasin.bz\u002Fdocs\u002Fsolvers\u002F\n","Basin 是一个用纯 Rust 编写的数值优化库，支持可插拔的线性代数后端和 WebAssembly。它提供了一个小巧且通用的核心模块、用户自定义的问题特征、可插拔的终止层以及驱动循环（Executor），并配备了一组不断扩展的求解器，包括一阶、无导数、非线性最小二乘和进化方法。这些求解器对线性代数后端是泛型的，并将约束视为一等公民，默认构建目标为 `wasm32-unknown-unknown` 且无需 BLAS\u002FLAPACK 或线程支持。适用于需要高性能数值计算解决方案的各种科学与工程场景，尤其是在资源受限或希望利用 WebAssembly 进行跨平台部署的情况下。",2,"2026-06-11 04:07:01","CREATED_QUERY"]