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:
- model
Model The model holding the node.
- name
str Name of the node to optimize. Must carry named dims.
- bounds
Sequence[tuple] orNone Declared
(low, high)bounds per entry, in native units.- date_dim
str The model’s date dimension, which a lever may not vary over.
- flat_dim
str Name of the flat decision vector’s dimension.
- model
- Returns:
LeverVariableA lever over
name.
- Raises:
ValueErrorIf
namehas no named dims in the model, or does not have exactly one dim other thandate_dim.