friendlysam.parts.Part.state_variables

Part.state_variables(index)

The state variables of the part.

Each subclass may define state_variables(), returning an iterable of the Varible instances that define the state of the part at the specified index.

friendlysam.models.MyopicDispatchModel is an example of how it can be used.

Parameters:index – The index of the state.

Examples

>>> from friendlysam import VariableCollection, Domain
>>> class ChocolateFactory(Node):
...     def __init__(self):
...         self.total = VariableCollection('total production')
...         self.mc = VariableCollection('milk chocolate production')
...         self.production['dark chocolate'] = lambda t: self.total(t) - self.mc(t)
...         self.production['milk chocolate'] = self.mc
...
...     def state_variables(self, t):
...         return (self.total, self.mc)