Skip to content

Models and metrics

Model declarations are public imports from paretorium. The optional single-attribute utility curves and the weighted geometric mean come from paretorium.utility and do not require the visualization extra.

paretorium.Model dataclass

A callable with declared input and output ports. The optional when selector activates it only for matching concepts.

Parameters:

Name Type Description Default
id str

Unique model ID within the study.

required
inputs tuple[Port, ...]

Declared numeric input ports supplied by parameters or upstream models. Use an empty tuple for no numeric inputs.

required
outputs tuple[Port, ...]

Nonempty tuple of numeric output ports. Each active quantity must have one producer.

required
evaluate ModelFunction

Function called as evaluate(concept, inputs). The inputs are a read-only mapping from declared port IDs to numbers. Return all and only the declared output IDs with finite numeric values.

required
when Mapping[str, str]

Optional decision-ID to option-ID mapping. Every entry must match for the model to run. Omit to activate it for all concepts.

dict()

paretorium.Port dataclass

A named numeric input or output with an exact-match unit string. Use 1 for dimensionless quantities.

Parameters:

Name Type Description Default
id str

Quantity ID used to connect producers and consumers.

required
units str

Exact unit string. Use "1" for dimensionless quantities.

required

paretorium.Metric dataclass

A reported quantity with optional inclusive limits and a min or max objective.

Parameters:

Name Type Description Default
id str

ID of a numeric quantity produced by a parameter or model.

required
units str

Units matching the producer exactly.

required
objective Literal['min', 'max'] | None

"min", "max", or None to omit from Pareto ranking.

None
minimum float | None

Inclusive lower feasibility limit, or None.

None
maximum float | None

Inclusive upper feasibility limit, or None.

None
name str

Optional display label.

''
utility Callable[[float], float] | None

Optional single-attribute utility function. It takes a value in the metric's units and returns a score in [0, 1]. Models may call it explicitly; attaching it does not affect evaluation, feasibility, or objectives.

None

port() -> Port

Return a port with this metric's ID and units for a model input or output.

paretorium.utility.LinearUtility dataclass

Score a value by linear interpolation between zero and one, clamped beyond the anchors.

Parameters:

Name Type Description Default
zero_at float

Finite metric value that scores 0.

required
one_at float

Distinct finite metric value that scores 1. May be lower than zero_at when smaller values are preferred.

required

__call__(value: float) -> float

Return the utility for a finite value in the anchors' units.

paretorium.utility.PiecewiseLinearUtility dataclass

Interpolate a utility curve and hold its endpoint scores outside the anchors.

Parameters:

Name Type Description Default
points tuple[tuple[float, float], ...]

At least two (value, score) pairs. Values are finite and strictly increasing in the metric's units. Scores are finite and in [0, 1]; they need not be monotonic or span that interval.

required

__call__(value: float) -> float

Return the utility for a finite value in the anchors' units.

paretorium.utility.PchipUtility dataclass

Smooth utility interpolation with no overshoot between anchors.

The piecewise cubic Hermite interpolant (PCHIP) preserves monotone segments, plateaus, and local extrema. The slope is continuous at interior anchors. Outside the anchors, hold the endpoint scores. With two anchors the interpolation is linear.

Parameters:

Name Type Description Default
points tuple[tuple[float, float], ...]

At least two (value, score) pairs. Values are finite and strictly increasing in the metric's units. Scores are finite and in [0, 1]; they need not be monotonic or span that interval.

required

__call__(value: float) -> float

Return the utility for a finite value in the anchors' units.

paretorium.utility.weighted_geometric_mean(scores: Iterable[float], weights: Iterable[float]) -> float

Combine utility scores with a weighted geometric mean.

Parameters:

Name Type Description Default
scores Iterable[float]

Finite utility scores in [0, 1], one per weight. All scores are validated, even those with zero weight.

required
weights Iterable[float]

Finite, nonnegative relative weights. At least one must be positive. Weights are normalized internally to sum to one.

required

Returns:

Type Description
float

A utility in [0, 1]. Any zero score with positive weight makes the

float

result zero. A zero weight contributes nothing, even for a zero score.

Raises:

Type Description
ValueError

The lengths differ, a score or weight is invalid, or there is no positive weight.