friendlysam.parts.Node¶
-
class
friendlysam.parts.Node(name=None)¶ A node with balance constraints.
Suitable for modeling nodes in a flow network. A
Nodeinstance produces balance constraints for all itsresources. The dictionariesconsumption,production,accumulation,inflows, andoutflows, are the basis for the balance constraints.Parameters: name (str, optional) – A name for the node. Examples
>>> class PowerPlant(Node): ... def __init__(self, efficiency): ... with namespace(self): ... x = VariableCollection('output') ... self.production['power'] = x ... self.consumption['fuel'] = lambda t: x(t) / efficiency ... >>> power_plant = PowerPlant(0.85) >>> constraints = power_plant.constraints.make(42) >>> constraints {<friendlysam.opt.Constraint at 0x...>, <friendlysam.opt.Constraint at 0x...>} >>> {c.desc for c in constraints} == {'Balance constraint (resource=power)', ... 'Balance constraint (resource=fuel)'} True
Node.add_part(part) |
Add a part to this part. |
Node.balance_constraints(index) |
Balance constraints for all resources. |
Node.cluster(resource) |
Get a Cluster this node is in. |
Node.find(name) |
Try to find a part by name. |
Node.iter_times(start, *range_args) |
A generator yielding a sequence of times. |
Node.iter_times_between(start, end) |
A generator yielding all times between two points. |
Node.parts([depth, include_self]) |
Get contained parts, recursively. |
Node.remove_part(part) |
Remove a part from this part. |
Node.set_cluster(cluster) |
Add this node to a Cluster. |
Node.state_variables(index) |
The state variables of the part. |
Node.step_time(index, num_steps) |
A function for stepping forward or backward in time. |
Node.times(start, *range_args) |
Get a sequence of times. |
Node.times_between(start, end) |
Get a tuple of all times between two points. |
Node.unset_cluster(cluster) |
Remove from a Cluster. |
Node.accumulation |
A dictionary of accumulation functions. |
Node.children |
Parts in this part, excluding self. |
Node.children_and_self |
Parts in this part, including self. |
Node.constraints |
For defining and generating constraints. |
Node.consumption |
A dictionary of consumption functions. |
Node.descendants |
All children, children of children, etc, excluding self. |
Node.descendants_and_self |
All children, children of children, etc, including self. |
Node.inflows |
A dictionary of sets of inflow functions. |
Node.name |
A name for the object. |
Node.outflows |
A dictionary of sets of outflow functions. |
Node.production |
A dictionary of production functions. |
Node.resources |
The set of resources this node handles. |
Node.time_unit |
The time unit used in step_time(). |