Architecture¶
PyMixEF’s central architectural rule is: represent scientific model meaning once in a versioned, immutable intermediate representation, then let compatible engines consume that representation.
Layer map¶
Layer |
Modules |
Responsibility |
|---|---|---|
Public model |
|
builders, safe formula parsing, validation, compilation, dispatch |
Data semantics |
|
adapters, schema, row identity, missingness and reconciliation |
Mathematical components |
|
probability, link, covariance, and constraint contracts |
Model representation |
|
typed nodes, schema validation/migration, semantic hashes, diffs |
Numerical engines |
|
LMM, GLMM, MMRM reference calculations |
Stable outputs |
|
fit/result/evidence contracts |
Inference/workflow |
|
bootstrap, parity, reports, bundles, deterministic streams |
Pharmacometrics |
|
DSL, event records, PK, ODE, population primitives |
Exchange |
|
conservative import/export plus compatibility reports |
Extensibility |
|
registries, discovery, and backend payload/protocol |
Semantic/compilation modules do not optimize. Backends do not redefine model meaning. Result modules do not infer an unstated estimator.
ModelIR¶
ModelIR contains versioned nodes for parameters, fixed/random effects,
predictors, likelihoods, covariance, transforms, priors, state equations,
events, and outputs. Dependencies are explicit.
The IR boundary enables:
model validation before numerical execution;
deterministic JSON round trips and semantic hashes;
structured model diffs and schema migration;
multiple authoring interfaces;
backend compatibility checks;
conservative interoperability.
Representability does not imply that a current engine can estimate the model.
Failure and warning policy¶
Backends raise typed PyMixEFError subclasses for invalid or incompatible
models. They never silently select a scientifically different estimator.
Completed calculations return structured convergence and stable warnings; a raw
optimizer success flag is not the interpretation gate.
Extension points¶
Plugin registries exist for families, links, covariance, estimators,
diagnostics, exporters, and ODE solvers. A new numerical backend implements the
Backend protocol, accepts the common CompiledData payload, validates its
mapping, emits the shared result keys, declares reproducibility, and registers
static compatibility.
The reusable fit-contract suite exercises the shared payload, deterministic
repeat fitting, row alignment, and input immutability against every built-in
backend. Its case-coverage assertion fails when a built-in backend is
registered without a case. ARCH-003 remains open: the public Backend Protocol
still needs separate objective, gradient, optional Hessian-vector product, and
simulation contracts for full backend conformance.
Capability policy¶
Capabilities carry maturity, implemented state, evidence, limitations, and reproducibility class. A partially specified or lower-level primitive can be present without being declared an integrated production path. Gated estimator entry points fail before optimization with stable unsupported codes and point to available primitives where appropriate.
The source architecture file is also available for download:
ARCHITECTURE.md.