pywr / hydra-pywr

GNU General Public License v3.0
1 stars 2 forks source link

Add support for split links #11

Closed knoxsp closed 2 months ago

knoxsp commented 3 years ago

Currently there is no support for split links such as riversplit, riversplitwithgauge, and multisplitlink.

These nodes are specified a

        {
            "name": "Split",
            "type": "riversplit",
            "factors": [0.95, 0.05],
            "slot_names": ["slot_name_1", "slot_name_2"]
        },

which match up with names specified on the links like so:

        ["Split", "target_node_1", "slot_name_1", null],
        ["Split", "target_node_2", "slot_name_2", null],

In Hydra, we should formalise the names of the slotnames to be the to_node.name, like so:

        {
            "name": "Split",
            "type": "riversplit",
            "factors": [0.95, 0.05],
            "slot_names": ["target_node_1","target_node_2"]
        },

which match up with names specified on the links like so:

        ["Split", "target_node_1", "target_node_1", null],
        ["Split", "target_node_2", "target_node_2", null],

So when exporting, hydra-pywr needs to check if the source node is one of riversplit, riversplitwitgauge, multisplitlink.. If it is, then iterate through the list of slot names on that node, and if a match is found to the target node name, then add the slot to the link. Otherwise, ignore.

Pseudo Code:

if from_node.type in [riversplit, riversplitwitgauge, multisplitlink]:
    for split_name in from_node.slot_names:
        if split_name == to_node.name:
              #add the slot to edge