modello documentation

Express a problem as named quantities and relationships, then supply the observations you have. The same model can calculate results, infer missing inputs, or keep a formula while an input is unknown.

Install with Python 3.10 or newer:

$ pip install modello

A small model already works in both directions:

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 == 6

Read Start modelling for a complete, runnable progression:

Express progressively richer problems

Concept

Question to express

Scalar models

Calculate a brace length or infer a missing measurement.

Component models

Use a parcel’s clearance to determine a quantity in its base.

Vector models

Evaluate a proposed calibration or fit its parameters to readings.

Recurrent models

Post account events or infer an event from a closing balance.

You can try the same progression in the interactive gallery. To choose by notation or finite versus unbounded scope, start with Choose a modelling approach. The guides below develop each approach; the API and diagnostic guarantees are separate reference material.