caelum0x 771f89b099 feat(v2-A/v2-B): weak-form, implicit dynamics, FROLS/SSR/trapping, SRBench harness
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>
2026-08-18 14:49:27 +03:00

25 lines
775 B
Rust

use lawsynth_sparse::{GroupConfig, RegressionProblem, group_stlsq};
use std::{hint::black_box, time::Instant};
fn main() {
let problem = RegressionProblem::new(
(0..1_000)
.map(|i| {
let x = i as f64 / 1_000.0;
vec![1.0, x, x * x, x * x * x]
})
.collect(),
(0..1_000).map(|i| 1.0 + 2.0 * i as f64 / 1_000.0).collect(),
)
.unwrap();
let config = GroupConfig::default();
let started = Instant::now();
let mut terms = 0;
for _ in 0..100 {
terms += black_box(group_stlsq(&problem, &[vec![0, 1], vec![2, 3]], &config).unwrap())
.coefficients
.len();
}
println!("fit {terms} grouped coefficients in {:?}", started.elapsed());
}