pywr.nodes.BreakLink
- class pywr.nodes.BreakLink(*args, **kwargs)
Compound node used to reduce the number of routes in a model
- Parameters:
- modelpywr.model.Model
- namestring
- min_flowfloat or pywr.parameters.Parameter
- max_flowfloat or pywr.parameters.Parameter
- costfloat or pywr.parameters.Parameter
Notes
In a model with form (3, 1, 3), i.e. 3 (A,B,C) inputs connected to 3 outputs (D,E,F) via a bottleneck (X), there are 3*3 routes = 9 routes.
A -->\ /--> D B --> X --> E C -->/ \--> F
If X is a storage, there are only 6 routes: A->X_o, B->X_o, C->X_o and X_i->D_o, X_i->E_o, X_i->F_o.
The BreakLink node is a compound node composed of a Storage with zero volume and a Link. It can be used in place of a normal Link, but with the benefit that it reduces the number of routes in the model (in the situation described above). The resulting LP is easier to solve.
- __init__(model, name, **kwargs)
Initialise a new Node object
- Parameters:
- modelModel
The model the node belongs to
- namestring
A unique name for the node
Methods
__init__
(model, name, **kwargs)Initialise a new Node object
after
(self, Timestep ts)before
(self, Timestep ts)Called at the beginning of the timestep
check
()Check the node is valid
commit
(self, int scenario_index, double value)Called once for each route the node is a member of
commit_all
(self, double[)Called once for each route the node is a member of
connect
(node[, from_slot, to_slot])Create an edge from this Node to another Node
disconnect
([node, slot_name, all_slots])Remove a connection from this Node to another Node
finalise_load
()Finish loading a node by converting parameter name references to instance references.
finish
(self)get_all_cost
(self, double[)get_all_max_flow
(self, double[)get_all_min_flow
(self, double[)get_constant_max_flow
(self)Returns max_flow value if it is a constant parameter or fixed value otherwise returns NaN.
get_constant_min_flow
(self)Returns min_flow value if it is a constant parameter or fixed value otherwise returns NaN.
get_conversion_factor
(self)Get the conversion factor
get_cost
(self, ScenarioIndex scenario_index)Get the cost per unit flow at a given timestep
get_fixed_max_flow
(self)Returns max_flow value if it is fixed value otherwise returns NaN.
get_fixed_min_flow
(self)Returns min_flow value if it is a fixed value otherwise returns NaN.
get_max_flow
(self, ScenarioIndex scenario_index)Get the maximum flow at a given timestep
get_min_flow
(self, ScenarioIndex scenario_index)Get the minimum flow at a given timestep
iter_slots
([slot_name, is_connector])Returns the object(s) wich should be connected to given slot_name
pre_load
(model, data)Create a node instance from data.
reset
(self)Called at the beginning of a run
setup
(self, model)Called before the first run of the model
Attributes
allow_isolated
comment
comment: basestring
component_attrs
components
Generator that returns all of the Components attached to the Node
conversion_factor
The conversion between inflow and outflow for the node
cost
The cost per unit flow via the node
domain
flow
Total flow via this node in the current timestep
fully_qualified_name
has_constant_flows
Returns true if both min_flow and max_flow are literal constants or "constant" Parameters.
has_fixed_cost
Returns true if cost is not a Parameter.
has_fixed_flows
Returns true if both min_flow and max_flow are not Parameters.
max_flow
The maximum flow constraint on the node
min_flow
The minimum flow constraint on the node
model
The recorder for the node, e.g. a NumpyArrayRecorder.
name
Name of the node.
parent
The parent Node/Storage of this object.
prev_flow
Total flow via this node in the previous timestep
recorders
Returns a list of pywr.recorders.Recorder objects attached to this node.
virtual
virtual: 'bool'