sindy-rs is a high-performance Rust port of the popular PySINDy library. It brings the power of Sparse Identification of Nonlinear Dynamical Systems (SINDy) to the Rust ecosystem, offering significant performance improvements and memory safety.
- Performance: Up to 50x faster than Python for iterative optimizers and complex feature libraries.
- Concurrency: Native support for multithreading (via Rayon) without GIL bottlenecks.
- Type Safety: Leverage Rust's strict type system to catch numerical errors at compile time.
- Zero Dependencies (Python): Compiled to a single binary. No need for Python, NumPy, or scikit-learn in production.
- Memory Efficient: Direct control over memory allocation, ideal for massive PDE datasets.
- ✅ SINDy Model: Full
fit,predict,score, andsimulatefunctionality. - ✅ SINDYc: Support for control inputs and exogenous variables.
- ✅ DiscreteSINDy: Discovery of discrete mapping systems (e.g., Logistic Map).
- ✅ Multi-Trajectory: Support for non-continuous/disjoint experimental data.
- Polynomial: Efficient polynomial combinations.
- Fourier: Spectral basis functions (sin/cos).
- Custom: Flexible user-defined math functions.
- Generalized: Tensor products and mapping of multiple libraries.
- PDE / WeakPDE: Discovery of partial differential equations from spatial data.
- STLSQ: Sequentially Thresholded Least Squares.
- SR3: Sparse Relaxed Regularized Regression (with QR unbiasing).
- FROLS / SSR: Greedy forward and backward feature selection.
- EvidenceGreedy: Bayesian informed optimization.
- ConstrainedSR3: Support for linear equality and inequality constraints via
clarabel.
Add this to your Cargo.toml:
[dependencies]
sindy-rs = "0.1.0"
ndarray = "0.16"use sindy_rs::{SINDy, STLSQ, PolynomialLibrary};
use ndarray::array;
fn main() {
// 1. Prepare data (e.g., linear system x' = -2x)
let x = array![[0.0], [1.0], [2.0], [3.0]];
let y = array![[0.0], [2.0], [4.0], [6.0]];
// 2. Initialize SINDy model
let mut model = SINDy::new(
Box::new(PolynomialLibrary::new(2)),
Box::new(STLSQ::default())
);
// 3. Fit and Inspect
model.fit(&x, &y).unwrap();
println!("Identified Equations: {:?}", model.equations());
}In comparison to the original PySINDy (Python):
- SSR/FROLS: 10x - 50x faster.
- Large PDE Datasets: Significantly reduced memory usage and 5x speedup in feature generation.
- Phase 12: Advanced Differentiation (Savitzky-Golay, Spectral).
- Phase 12: Standard ODE Examples (Lorenz, Rossler, etc.).
Distributed under the MIT License. See LICENSE for more information.