Four expansion-v2 items (finished after a session-limit interruption): Weak/integral-form discovery (crates/lawsynth-weakform, specs/weak-form) — the top noise-robustness technique from PySINDy: integrate candidates against compactly- supported test functions, NO differentiation of noisy data. ~23x lower coefficient error than finite-difference strong-form under noise. 20 tests, deterministic. Implicit/rational dynamics (crates/lawsynth-implicit, specs/implicit-dynamics) — SINDy-PI alternating-LHS nullspace solve; recovers rational laws (Michaelis-Menten) explicit regression can't express. Honest degree-2 identifiability limit documented (multi-dimensional nullspace); residual-floor + derivative-preferring tie-break for canonical selection. 10 tests. Optimizer breadth (lawsynth-sparse) — FROLS (orthogonal-least-squares, ERR ordering), SSR (stepwise), trapping (stability-biased); --solver frols|ssr|trapping. 24 tests; default path byte-identical. SRBench harness (benchmarks/) — 18 Strogatz ODE systems + scoring + a determinism column (byte-identical on replay — a metric no stochastic competitor can report). 3/3 Strogatz recovered at R²=1.0. srbench_report.py + 5 tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16 lines
606 B
Rust
16 lines
606 B
Rust
use lawsynth_sparse::{RegressionProblem, SparseConfig, sr3};
|
|
|
|
#[test]
|
|
fn sr3_is_deterministic_and_eliminates_subthreshold_features() {
|
|
let problem = RegressionProblem::new(
|
|
vec![vec![1.0, 0.0], vec![1.0, 1.0], vec![1.0, 2.0], vec![1.0, 3.0]],
|
|
vec![0.0, 2.0, 4.0, 6.0],
|
|
)
|
|
.unwrap();
|
|
let config = SparseConfig { threshold: 0.1, ridge: 1e-4, max_iterations: 100 };
|
|
let first = sr3(&problem, &config).unwrap();
|
|
assert_eq!(first, sr3(&problem, &config).unwrap());
|
|
assert!(first.coefficients[0].abs() < 0.1);
|
|
assert!((first.coefficients[1] - 2.0).abs() < 1e-3);
|
|
}
|