Batch 7 of expansion-v2. Extends the product across surfaces and adds an
analysis primitive. Deterministic/offline/std-only (Rust) or graceful-absence
(Python).
python/lawsynth analysis.py (new): Python client for the engine's stability,
control, and domains analyses — shells out to the lawsynth CLI (--json) and
parses to typed dataclasses. No numerics re-implemented in Python; the Rust
engine is the single source of truth. Locates the binary like the benchmarks,
raises MissingBinaryError/CliError honestly, and is fully parse-testable
offline. 20 tests; full SDK suite 114 passed.
crates/lawsynth-features: opt-in std::thread-parallel feature-library
evaluation, bit-identical to serial for ALL thread counts (row-chunked via
thread::scope, ordered assembly, no parallel float reduction). Verified via
f64::to_bits across {1,2,3,4,7,8} threads x 10 library variants x uneven row
counts. Measured 3.6x at 8 threads; honestly sublinear (allocation-bound,
~few-thousand-row crossover). 28 tests + benchmark.
crates/lawsynth-sensitivity (new): forward sensitivity analysis. Integrates the
variational equations Ṡ_j = J_x·S_j + f_θj (J_x from the analytic Jacobian, f_θ
by symbolic differentiation) on the augmented system with fixed-step RK4.
Analytic check to <1e-6; finite-difference cross-check at 1e-6 for every
parameter on logistic + Lotka-Volterra. 22 tests.
docs/guide (new): verified end-to-end guide — getting-started, workflow
(discover→simplify→stability→control→export→validate→uncertainty), and a
determinism demo. All 17 documented commands run exit-0 via run_all.sh; honest
about real behaviors (already-minimal law simplifies to 0 nodes saved, CLI
bootstrap doesn't surface per-coef intervals, center points are inconclusive).
README links the guide.
specs/{parallel-evaluation,sensitivity-analysis}: boundary specs.
27 lines
1.0 KiB
Rust
27 lines
1.0 KiB
Rust
use lawsynth_core::Identifier;
|
|
use lawsynth_data::{Dataset, NumericColumn, TimeAxis};
|
|
use lawsynth_features::{FeatureConstraint, FeatureLibrary};
|
|
|
|
#[test]
|
|
fn constrained_extended_library_builds_a_design_matrix_from_dataset_rows() {
|
|
let x = Identifier::new("x").unwrap();
|
|
let y = Identifier::new("y").unwrap();
|
|
let data = Dataset::new(
|
|
TimeAxis::new(vec![0.0, 1.0]).unwrap(),
|
|
[
|
|
NumericColumn::new(x.clone(), vec![2.0, 3.0]),
|
|
NumericColumn::new(y.clone(), vec![5.0, 7.0]),
|
|
],
|
|
)
|
|
.unwrap();
|
|
let mut library = FeatureLibrary::polynomial([x.clone(), y.clone()], 1, true).unwrap();
|
|
library.extend(FeatureLibrary::interactions([x.clone(), y.clone()]).unwrap());
|
|
let constrained = library.constrained(&[
|
|
FeatureConstraint::AllowedSymbols([x, y].into_iter().collect()),
|
|
FeatureConstraint::RequireSymbol,
|
|
]);
|
|
let matrix = constrained.evaluate(&data).unwrap();
|
|
assert_eq!(matrix.terms.len(), 3);
|
|
assert_eq!(matrix.rows, vec![vec![5.0, 2.0, 10.0], vec![7.0, 3.0, 21.0]]);
|
|
}
|