r/optimization • • 1h ago

Parameter fitting where a unit-scale error fails instead of producing a nicer curve

Fitting a model to data has an unpleasant property: a wrong parameterisation can still fit well. If a rate is declared per second while the integrator steps in days, the optimiser will happily find a value that compensates, the residual looks fine, and the fitted parameter is meaningless. Nothing throws, because dimensions and magnitudes are checked by nobody.

axiomize is a modelling layer that makes the fitted model explicit before any numbers are produced: mandatory units on every parameter and variable, a versioned Model IR, dimensional and scale validation, and export to formats someone else can rerun. A rate declared 1/s against an independent variable in day is a scale mismatch that fails closed, rather than a value 86,400 times off that looks converged.

The failure surface is deliberate. Simulation and fitting route through the same validation as axiomize model --action validate, and a mismatch raises ModelDimensionMismatch carrying the failing checks instead of returning an array of numbers. unit_declaration_audit reports every symbol that would silently default to dimensionless, which is where an unlabeled constant or an unset bound usually hides.

The actions under axiomize model cover the fitting lifecycle rather than just one endpoint: plan, validate, simulate, fit, compare, repair, export, plus verification actions numerical-verify, stop-check and surrogate. compare is the one I use most, because it records why one model family was chosen over another instead of leaving that decision in a notebook cell, and numerical-verify separates numerical error from stochastic variability before claiming convergence.

Outputs are portable: canonical JSON, Python, YAML, notebooks, SBML Level 3, CellML 2.0, Modelica, GraphML, Graphviz DOT and a SHA-256 bundle, with values and units round-tripping bit-exactly, which the test suite asserts rather than assumes. A run ledger keeps provenance so a stored result can be checked before reuse, and axiomize-to-latex converts a standardised report to LaTeX.

Install is pip install axiomize, or npm install -g axiomize. The CLI also exposes axiomize solve, axiomize fit and axiomize capabilities for sizing, fitting and backend discovery.

What it does not do: it does not make a bad model good, it makes a bad model fail loudly. Dimensional checking catches unit and scale errors, not a wrong functional form, and if your equations are wrong it will verify them consistently. Bayesian sampling needs the full extra with PyMC and JAX, FEM needs FEniCS, and both are reported unavailable rather than silently substituted. MIT, 1.15.0: https://github.com/Furox-Art/axiomize

1 Upvotes

0 comments sorted by