solverang
A silly solver for serious systems.
Domain-agnostic numerical solver for nonlinear equations (F(x) = 0) and least-squares problems (min ||F(x)||^2) in Rust. The core operates on parameter IDs and trait objects, so it works for any domain -- CAD, robotics, circuit simulation, whatever you need to make converge.
Ships with batteries-included 2D sketch, 3D sketch, and rigid-body assembly constraint modules.
Quick Start
Low-level: Problem Trait
use ;
;
let solver = new;
let result = solver.solve;
assert!;
High-level: Sketch2DBuilder
use Sketch2DBuilder;
use SystemStatus;
let mut b = new;
let p0 = b.add_fixed_point;
let p1 = b.add_fixed_point;
let p2 = b.add_point;
b.constrain_distance;
b.constrain_distance;
b.constrain_distance;
let mut system = b.build;
let result = system.solve;
assert!;
Solvers
| Solver | Best for | Notes |
|---|---|---|
Solver (Newton-Raphson) |
Square systems (m = n) | Fast quadratic convergence near solution |
LMSolver (Levenberg-Marquardt) |
Over-determined (m > n) | Robust, handles poor starting points |
AutoSolver |
General use | Auto-selects based on problem structure |
RobustSolver |
Unknown problems | Tries NR, falls back to LM |
ParallelSolver |
Independent sub-problems | Solves components in parallel |
SparseSolver |
Large, sparse systems | Efficient for 1000+ variables |
Constraint Modules
- sketch2d -- 2D points, lines, circles, arcs with 15 constraint types. Ergonomic
Sketch2DBuilderAPI. - sketch3d -- 3D points, line segments, planes, axes with 8 constraint types.
- assembly -- Rigid bodies with quaternion orientation. Mate, coaxial, insert, and gear ratio constraints.
Feature Flags
| Flag | Default | Purpose |
|---|---|---|
std |
yes | Standard library support |
macros |
yes | #[auto_jacobian] procedural macro |
sparse |
yes | Sparse matrix operations (faer) |
parallel |
yes | Parallel solving (rayon) |
jit |
yes | Cranelift JIT compilation |
nist |
yes | NIST StRD test problems |
License
Apache-2.0