Skip to content

Choose a model and design a measurement

Twindex certifies compatibility for the equations and discrepancy bounds you supply. A VALID pair proves a lower bound on a parameter coordinate's compatible range. It does not validate the mechanism, imply confidence coverage, prove uniqueness, or give a global upper bound for ODE systems.

Field Starting model Certified scope and limits
Epidemic dynamics SIR, with R0 and gamma Polynomial mass action, fractions, fixed initial conditions; prevalence observation assumed. Counts of bed confinement need an explicit observation assumption.
Pharmacokinetics Two-compartment PK Linear elimination/exchange, normalized amounts; fixed bolus and no time-varying dosing. Concentration requires a stated volume conversion.
Reaction kinetics Enzyme-complex mass action Explicit substrate, free enzyme, complex and product; no reduced rational Michaelis–Menten rate.
Stationary diffusion/reaction 1-D or rectangular 2-D elliptic backend Polynomial coefficients and monotone reaction with the documented boundary assumptions.
Transient diffusion Heat backend Polynomial candidates, exact initial data and zero lateral boundaries.
Other simulators, PINNs, FEM Numerical audit adapter Numerical evidence only, unless an explicit supported certification bridge is used.

These are mathematical applicability mappings, not validated industry models. Arbitrary event-driven, delay, stochastic and rational ODE systems are outside the certified polynomial backend. The numerical audit accepts arbitrary forward models and must retain its evidence-only label.

Three editable templates

The repository's examples/ode_templates/ contains sir.json, pk2.json and enzyme.json. Each uses the certificate model schema, with a separate NAME.manifest.json recording units, prior, nominal vector, assumed noise, schedule, future noise and data construction. Priors follow model parameter order. SIR uses days, PK hours, enzyme minutes; these are separate examples. Initial values are in the model file. These are synthetic demonstrations, not clinical recommendations or calibrated physical systems.

Run this from the repository root after installing pip install -e '.[general,report]':

import json
from pathlib import Path
from twindex.identify import read_ode_model
from twindex.design import design_ode

root = Path('examples/ode_templates')
m = json.loads((root / 'pk2.manifest.json').read_text())
r = design_ode(
    read_ode_model(root / m['model']), None, m['epsilon'], m['box'],
    m['candidate_times'], m['target'], nominal=m['nominal'],
    measurement_times=m['measurement_times'], observable=m['observable'],
    future_noise=m['future_noise'], output='pk2-evidence',
    starts=1, max_iter=20,
)
print(r.data_construction)
print(r.identification.status, r.identification.lower)
print(r.ranking)

Synthetic observations are numerical integration samples rounded to 12 decimal places. They are not exact nominal trajectories. Change the manifest to explore another model, keeping its units consistent. Supplied observations can replace None; identify_ode(..., noise=[...]) accepts one positive exact bound per row. The CLI accepts t,observable,y,noise CSV as well as the original three columns; --eps remains required as the fallback and default future-datum allowance. read_ode_data(path, with_noise=True) returns (measurements, noise_or_None).

What a suggested measurement means

design_ode runs identify_ode and ranks times only after fresh VALID pair replay. It returns the observations, their construction, identification result and ranking. No pair means an empty ranking, never a separation claim. All candidate times must lie within the measured horizon and both certified candidate horizons. To inspect later times, first construct witnesses certified through those times, then call rank_measurement_times directly.

The score is a heuristic polynomial difference divided by the future noise. separates_twins is exact: the difference exceeds twice the future absolute noise plus both proved observable errors. Any future datum at that allowance then excludes at least one of these two fixed vectors. It promises no global range reduction, optimal schedule or uniqueness. Historical per-row noise does not set future noise: pass future_noise explicitly, or epsilon is used. A timeout, failed search or INCONCLUSIVE replay proves no global exclusion.

The editable Colab walkthrough is notebooks/ode_discovery.ipynb in the repository.

Try the browser demo

Replay the real-data discovery loop locally in your browser. The 1978 flu example treats bed confinement as SIR prevalence and states its discrepancy allowance explicitly. Each slider position proves that two named parameter vectors fit a prefix; it gives no global Râ‚€ interval. The later-day separation calculation and the hindsight incompatibility checks use separately stated future and historical allowances. This is a retrospective demonstration.

Start from sir.json to edit epidemic dynamics, or pk2.json for the two-compartment model shown in the demo gallery. enzyme.json illustrates another polynomial mass-action model to explore in the notebook. Generate a certificate with the template workflow above, then drop it into the demo for fresh exact replay. The browser verifies certificates; searching for twins runs in Python. Saved verdicts and fresh browser verdicts have separate labels.