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>
31 lines
1.2 KiB
Rust
31 lines
1.2 KiB
Rust
//! Linear-system sanity: implicit discovery must degrade gracefully to ordinary
|
|
//! explicit dynamics when the denominator is a constant.
|
|
|
|
mod support;
|
|
|
|
use lawsynth_implicit::{ImplicitConfig, implicit_discover};
|
|
use support::{coefficient, dataset_x, integrate, linear_decay};
|
|
|
|
#[test]
|
|
fn recovers_linear_decay_with_constant_denominator() {
|
|
let k = 0.8;
|
|
let (time, xs) = integrate(linear_decay(k), 1.0, 0.01, 400);
|
|
let dataset = dataset_x(time, xs);
|
|
|
|
let config = ImplicitConfig { degree: 2, ..Default::default() };
|
|
let result = implicit_discover(&dataset, &config).unwrap();
|
|
|
|
assert!(result.relation.consistent);
|
|
let law = result.rational_law.expect("rational law reconstructed");
|
|
|
|
// ẋ = -k·x means Q(x) = 1 (constant) and P(x) = -k·x.
|
|
assert!((coefficient(&law.denominator.terms, "1") - 1.0).abs() < 1e-9);
|
|
assert!(coefficient(&law.denominator.terms, "x").abs() < 1e-6);
|
|
let recovered_k = -coefficient(&law.numerator.terms, "x");
|
|
assert!((recovered_k - k).abs() < 5e-3, "k recovered {recovered_k}");
|
|
|
|
// A constant, non-vanishing denominator is the ordinary explicit case.
|
|
assert!(law.denominator_nonvanishing);
|
|
assert!((law.min_abs_denominator - 1.0).abs() < 1e-9);
|
|
}
|