caelum0x 2335e9556d feat: v2-A engine breadth — structural reductions, MDL/Pareto, differentiable export, SRBench families
Batch 3 of the expansion-v2 roadmap, all deterministic/offline/std-only with
honest capability boundaries.

crates/lawsynth-reduce (new): deterministic symmetry & separability detection.
Numerical-derivative probe (finite differences replace AI-Feynman's trained NN
gradients) over a reconstructed Cartesian grid; additive/multiplicative
separability + difference/sum/product/ratio symmetries. Every detection is a
HYPOTHESIS verified by reconstruction residual, never a proof; non-grid data is
honestly rejected (NotReconstructed). 17 tests.

crates/lawsynth-score: two-part MDL objective (L_data + L_model in nats) and
O(n log n) pareto_front_2d (sort-then-sweep), verified equal to the O(n^2)
front across 12 deterministic sets. +5 tests; crate fmt-normalized to config.

python/lawsynth export.py (new): to_sympy/to_torch/to_jax + dep-free
numeric_derivatives anchor. Constants+params hoisted into one trainable vector
so autograd reaches every coefficient (Neural-ODE vector field). Backends
absent here degrade gracefully (MissingDependencyError subclasses ImportError).
Faithful to native simulate at 1.1e-16. 10 tests + 6 honest skips.

benchmarks: SRBench Feynman (15: 12 static algebraic relations as honest
capability-boundaries, 3 dynamics-framed ODEs executed at R2~=1.0) and
black-box (4 systems, predictive R2 + parsimony, no ground truth) families.
Fixes a pre-existing _runner.py failure where Strogatz cases leaked into the
legacy contract suite. 31 benchmark tests.

specs/structural-reductions: boundary spec (detection-is-a-hypothesis contract).
2026-08-18 15:04:43 +03:00

23 lines
860 B
Rust

use lawsynth_score::{CandidateMetrics, ScoringConfig, rank_candidates, weighted_rank};
#[test]
fn domination_and_weighted_ranking_use_the_documented_minimization_order() {
let simple = CandidateMetrics { mean_squared_error: 1.0, complexity: 1 };
let worse = CandidateMetrics { mean_squared_error: 2.0, complexity: 3 };
let accurate = CandidateMetrics { mean_squared_error: 0.5, complexity: 10 };
assert!(simple.dominates(worse));
assert!(!accurate.dominates(simple));
assert_eq!(rank_candidates(&[simple, worse, accurate]), vec![2, 0, 1]);
assert_eq!(
weighted_rank(
&[simple, worse, accurate],
ScoringConfig { error_weight: 1.0, complexity_weight: 0.2 },
)
.unwrap()
.into_iter()
.map(|(index, _)| index)
.collect::<Vec<_>>(),
vec![0, 2, 1]
);
}