-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autogenerate the validation tables for Python (#1797)
Fixes #1779
- Loading branch information
Showing
8 changed files
with
171 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,123 @@ | ||
# Table for connectivity between different node types | ||
# Automatically generated file. Do not modify. | ||
|
||
# Table for connectivity | ||
# "Basin": ["LinearResistance"] means that the downstream of basin can be LinearResistance only | ||
node_type_connectivity: dict[str, list[str]] = { | ||
"Basin": [ | ||
"LinearResistance", | ||
"ManningResistance", | ||
"TabulatedRatingCurve", | ||
"Pump", | ||
"PidControl": [ | ||
"Outlet", | ||
"UserDemand", | ||
], | ||
"LinearResistance": ["Basin", "LevelBoundary"], | ||
"ManningResistance": ["Basin"], | ||
"TabulatedRatingCurve": ["Basin", "Terminal", "LevelBoundary"], | ||
"LevelBoundary": ["LinearResistance", "Pump", "Outlet", "TabulatedRatingCurve"], | ||
"FlowBoundary": ["Basin", "Terminal", "LevelBoundary"], | ||
"Pump": ["Basin", "Terminal", "LevelBoundary"], | ||
"Outlet": ["Basin", "Terminal", "LevelBoundary"], | ||
"Terminal": [], | ||
"DiscreteControl": [ | ||
"Pump", | ||
], | ||
"LevelBoundary": [ | ||
"Outlet", | ||
"TabulatedRatingCurve", | ||
"LinearResistance", | ||
"ManningResistance", | ||
"PidControl", | ||
"Pump", | ||
], | ||
"Pump": [ | ||
"LevelBoundary", | ||
"Basin", | ||
"Terminal", | ||
], | ||
"UserDemand": [ | ||
"LevelBoundary", | ||
"Basin", | ||
"Terminal", | ||
], | ||
"TabulatedRatingCurve": [ | ||
"LevelBoundary", | ||
"Basin", | ||
"Terminal", | ||
], | ||
"ContinuousControl": ["Pump", "Outlet"], | ||
"PidControl": ["Pump", "Outlet"], | ||
"UserDemand": ["Basin", "Terminal", "LevelBoundary"], | ||
"LevelDemand": ["Basin"], | ||
"FlowDemand": [ | ||
"LinearResistance", | ||
"Outlet", | ||
"TabulatedRatingCurve", | ||
"ManningResistance", | ||
"Pump", | ||
], | ||
"FlowBoundary": [ | ||
"LevelBoundary", | ||
"Basin", | ||
"Terminal", | ||
], | ||
"Basin": [ | ||
"LinearResistance", | ||
"UserDemand", | ||
"Outlet", | ||
"TabulatedRatingCurve", | ||
"ManningResistance", | ||
"Pump", | ||
], | ||
"ManningResistance": [ | ||
"Basin", | ||
], | ||
"LevelDemand": [ | ||
"Basin", | ||
], | ||
"DiscreteControl": [ | ||
"LinearResistance", | ||
"PidControl", | ||
"Outlet", | ||
"TabulatedRatingCurve", | ||
"ManningResistance", | ||
"Pump", | ||
], | ||
"Outlet": [ | ||
"LevelBoundary", | ||
"Basin", | ||
"Terminal", | ||
], | ||
"ContinuousControl": [ | ||
"Outlet", | ||
"Pump", | ||
], | ||
"LinearResistance": [ | ||
"LevelBoundary", | ||
"Basin", | ||
], | ||
"Terminal": [], | ||
} | ||
|
||
|
||
# Function to validate connectivity between two node types | ||
# Function to validate connection | ||
def can_connect(node_type_up: str, node_type_down: str) -> bool: | ||
if node_type_up in node_type_connectivity: | ||
return node_type_down in node_type_connectivity[node_type_up] | ||
return False | ||
|
||
|
||
flow_edge_neighbor_amount: dict[str, list[int]] = { | ||
# list[int] = [in_min, in_max, out_min, out_max] | ||
"Basin": [0, int(1e9), 0, int(1e9)], | ||
"LinearResistance": [1, 1, 1, 1], | ||
"ManningResistance": [1, 1, 1, 1], | ||
"TabulatedRatingCurve": [1, 1, 1, int(1e9)], | ||
"LevelBoundary": [0, int(1e9), 0, int(1e9)], | ||
"FlowBoundary": [0, 0, 1, int(1e9)], | ||
"Pump": [1, 1, 1, int(1e9)], | ||
"Outlet": [1, 1, 1, 1], | ||
"Terminal": [1, int(1e9), 0, 0], | ||
"DiscreteControl": [0, 0, 0, 0], | ||
"ContinuousControl": [0, 0, 0, 0], | ||
"PidControl": [0, 0, 0, 0], | ||
"LevelBoundary": [0, 9223372036854775807, 0, 9223372036854775807], | ||
"Pump": [1, 1, 1, 1], | ||
"UserDemand": [1, 1, 1, 1], | ||
"LevelDemand": [0, 0, 0, 0], | ||
"TabulatedRatingCurve": [1, 1, 1, 1], | ||
"FlowDemand": [0, 0, 0, 0], | ||
"FlowBoundary": [0, 0, 1, 9223372036854775807], | ||
"Basin": [0, 9223372036854775807, 0, 9223372036854775807], | ||
"ManningResistance": [1, 1, 1, 1], | ||
"LevelDemand": [0, 0, 0, 0], | ||
"DiscreteControl": [0, 0, 0, 0], | ||
"Outlet": [1, 1, 1, 1], | ||
"ContinuousControl": [0, 0, 0, 0], | ||
"LinearResistance": [1, 1, 1, 1], | ||
"Terminal": [1, 9223372036854775807, 0, 0], | ||
} | ||
|
||
control_edge_neighbor_amount: dict[str, list[int]] = { | ||
# list[int] = [in_min, in_max, out_min, out_max] | ||
"Basin": [0, 1, 0, 0], | ||
"LinearResistance": [0, 1, 0, 0], | ||
"ManningResistance": [0, 1, 0, 0], | ||
"TabulatedRatingCurve": [0, 1, 0, 0], | ||
"PidControl": [0, 1, 1, 1], | ||
"LevelBoundary": [0, 0, 0, 0], | ||
"FlowBoundary": [0, 0, 0, 0], | ||
"Pump": [0, 1, 0, 0], | ||
"Outlet": [0, 1, 0, 0], | ||
"Terminal": [0, 0, 0, 0], | ||
"DiscreteControl": [0, 0, 1, int(1e9)], | ||
"ContinuousControl": [0, 0, 1, int(1e9)], | ||
"PidControl": [0, 1, 1, 1], | ||
"UserDemand": [0, 0, 0, 0], | ||
"LevelDemand": [0, 0, 1, int(1e9)], | ||
"TabulatedRatingCurve": [0, 1, 0, 0], | ||
"FlowDemand": [0, 0, 1, 1], | ||
"FlowBoundary": [0, 0, 0, 0], | ||
"Basin": [0, 1, 0, 0], | ||
"ManningResistance": [0, 1, 0, 0], | ||
"LevelDemand": [0, 0, 1, 9223372036854775807], | ||
"DiscreteControl": [0, 0, 1, 9223372036854775807], | ||
"Outlet": [0, 1, 0, 0], | ||
"ContinuousControl": [0, 0, 1, 9223372036854775807], | ||
"LinearResistance": [0, 1, 0, 0], | ||
"Terminal": [0, 0, 0, 0], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Automatically generated file. Do not modify. | ||
|
||
# Table for connectivity | ||
# "Basin": ["LinearResistance"] means that the downstream of basin can be LinearResistance only | ||
node_type_connectivity: dict[str, list[str]] = { | ||
{% for n in nodes %} | ||
'{{n[:name]}}': [{% for value in n[:connectivity] %} | ||
'{{ value }}', | ||
{% end %}], | ||
{% end %} | ||
} | ||
|
||
# Function to validate connection | ||
def can_connect(node_type_up: str, node_type_down: str) -> bool: | ||
if node_type_up in node_type_connectivity: | ||
return node_type_down in node_type_connectivity[node_type_up] | ||
return False | ||
|
||
flow_edge_neighbor_amount: dict[str, list[int]] = { | ||
{% for n in nodes %} | ||
'{{n[:name]}}': | ||
[{{ n[:flow_neighbor_bound].in_min }}, {{ n[:flow_neighbor_bound].in_max }}, {{ n[:flow_neighbor_bound].out_min }}, {{ n[:flow_neighbor_bound].out_max }}], | ||
{% end %} | ||
} | ||
|
||
control_edge_neighbor_amount: dict[str, list[int]] = { | ||
{% for n in nodes %} | ||
'{{n[:name]}}': | ||
[{{ n[:control_neighbor_bound].in_min }}, {{ n[:control_neighbor_bound].in_max }}, {{ n[:control_neighbor_bound].out_min }}, {{ n[:control_neighbor_bound].out_max }}], | ||
{% end %} | ||
} |