LeverVariable.from_model#

classmethod LeverVariable.from_model(model, name, bounds=None, *, date_dim='date', flat_dim='budgets_flat')[source]#

Build a lever by reading a named node’s dim, coords and value off a model.

Everything a lever needs besides its bounds already lives in the model, so callers name the node and this reads the rest, raising if the node cannot serve as a lever.

Parameters:
modelModel

The model holding the node.

namestr

Name of the node to optimize. Must carry named dims.

boundsSequence[tuple] or None

Declared (low, high) bounds per entry, in native units.

date_dimstr

The model’s date dimension, which a lever may not vary over.

flat_dimstr

Name of the flat decision vector’s dimension.

Returns:
LeverVariable

A lever over name.

Raises:
ValueError

If name has no named dims in the model, or does not have exactly one dim other than date_dim.