Express a modelling question as quantities and relationships, then supply what you know. The same model can calculate a result, infer missing inputs, or retain a symbolic formula. SymPy handles the algebra.
pip install modelloRequires Python 3.10+ and SymPy 1.14+.
A brace spans a right-angle opening. Declare positive side lengths and their relationship; choose the solving direction through the observations:
from sympy import sqrt
from modello import InstanceDummy, Modello
class Triangle(Modello):
a = InstanceDummy("a", positive=True)
b = InstanceDummy("b", positive=True)
c = sqrt(a**2 + b**2)
assert Triangle("brace", a=3, b=4).c == 5
assert Triangle("run", b=8, c=10).a == 6Omit a quantity to leave it unknown. Construct another case to try different observations; changing an attribute does not recalculate the model.
The getting-started guide develops four concepts in order:
| Concept | How it helps express a question |
|---|---|
| Scalar models | Relate quantities, declare domains, and solve in either direction. |
| Component models | Reuse smaller models; parent observations can determine child quantities. |
| Vector models | Express predictions across observations and fit parameters with an objective. |
| Recurrent models | Relate typed states over time and infer missing events from boundary observations. |
The examples progress from a brace and parcel to sensor calibration and account reconciliation. Each uses the same questions: calculate results, infer inputs, try different observations, leave unknowns, and check conflicting claims.
Use solution families to retain alternatives or add bounds. Use inspection and diagnostics when observations disagree or a calculation remains unresolved. The solver boundaries record what the current implementation supports.
The optional GUI follows the same four-step progression:
pip install 'modello[gui]'
python -m examples.galleryFrom a checkout, run uv run --extra gui python -m examples.gallery.
Open http://127.0.0.1:5070 to inspect formulas and try the guided questions.
The gallery guide explains the controls;
the GUI quickstart shows how to explore your own model.
Domain extensions are opt-in. For example,
modello.contrib.stochastic adds one-state Itô
formulas while using the same observations and modelling interface.
- Documentation and API reference.
- Practical applications: invoices, production, and circuits.
- Research examples: portfolio reporting and calibration.
- Reconciliation: compare source data and infer suspect inputs.
- Contributing: setup, checks, documentation, and releases.