Pywr
  • Installing Pywr
  • Tutorial
  • Problem formulation
  • JSON model format
  • GLPK error handling and performance
  • Cookbook
  • Extending Pywr
  • Python API reference
    • Core classes
    • Nodes
      • Nodes classes
        • pywr.nodes.Node
        • pywr.nodes.Link
        • pywr.nodes.Input
        • pywr.nodes.Output
        • pywr.nodes.BreakLink
        • pywr.nodes.LossLink
        • pywr.nodes.PiecewiseLink
        • pywr.nodes.MultiSplitLink
        • pywr.nodes.Storage
        • pywr.nodes.VirtualStorage
        • pywr.nodes.RollingVirtualStorage
        • pywr.nodes.MonthlyVirtualStorage
        • pywr.nodes.AnnualVirtualStorage
        • pywr.nodes.SeasonalVirtualStorage
        • pywr.nodes.AggregatedStorage
        • pywr.nodes.AggregatedNode
        • pywr.nodes.DelayNode
        • pywr.domains.river.Catchment
        • pywr.domains.river.Reservoir
        • pywr.domains.river.River
        • pywr.domains.river.RiverSplit
        • pywr.domains.river.RiverSplitWithGauge
        • pywr.domains.river.RiverGauge
    • Optimisation
    • Parameters
    • Recorders
    • Solvers
    • Notebook Utilities
    • Utilities
  • License
Pywr
  • Pywr reference documentation.
  • Nodes
  • pywr.nodes.MultiSplitLink
  • View page source

pywr.nodes.MultiSplitLink

class pywr.nodes.MultiSplitLink(*args, **kwargs)

An extension of PiecewiseLink that includes additional slots to connect from.

Conceptually this node looks like the following internally,

         / -->-- X0 -->-- \
A -->-- Xo -->-- X1 -->-- Xi -->-- C
         \ -->-- X2 -->-- /
                 |
                 Bo -->-- Bi --> D

An additional sublink in the PiecewiseLink (i.e. X2 above) and nodes (i.e. Bo and Bi) in this class are added for each extra slot.

Finally a mechanism is provided to (optionally) fix the ratio between the last non-split sublink (i.e. X1) and each of the extra sublinks (i.e. X2). This mechanism uses AggregatedNode internally.

Parameters:
max_flowsiterable

A monotonic increasing list of maximum flows for the piece wise function

costsiterable

A list of costs corresponding to the max_flow steps

extra_slotsint, optional (default 1)

Number of additional slots (and sublinks) to provide. Must be greater than zero.

slot_namesiterable, optional (default range of ints)

The names by which to refer to the slots during connection to other nodes. Length must be one more than the number of extra_slots. The first item refers to the PiecewiseLink connection with the following items for each extra slot.

factorsiterable, optional (default None)

If given, the length must be equal to one more than the number of extra_slots. Each item is the proportion of total flow to pass through the additional sublinks. If no factor is required for a particular sublink then use None for its items. Factors are normalised prior to use in the solver.

Notes

Users must be careful when using the factor mechanism. Factors use the last non-split sublink (i.e. X1 but not X0). If this link is constrained with a maximum or minimum flow, or if it there is another unconstrained link (i.e. if X0 is unconstrained) then ratios across this whole node may not be enforced as expected.

__init__(model, nsteps, *args, **kwargs)

Initialise a new Node object

Parameters:
modelModel

The model the node belongs to

namestring

A unique name for the node

Methods

__init__(model, nsteps, *args, **kwargs)

Initialise a new Node object

after(timestep)

Set total flow on this link as sum of sublinks

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

A property to flag whether this Node can be unconnected in a network.

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

costs

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

max_flows

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'

Previous Next

© Copyright Copyright (C) 2014-19 Joshua Arnott, James E. Tomlinson, Atkins, University of Manchester.

Built with Sphinx using a theme provided by Read the Docs.