epyt-flow 0.14.1__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epyt_flow/VERSION +1 -1
- epyt_flow/__init__.py +0 -37
- epyt_flow/data/benchmarks/battledim.py +2 -2
- epyt_flow/data/benchmarks/leakdb.py +12 -9
- epyt_flow/gym/scenario_control_env.py +32 -33
- epyt_flow/simulation/events/actuator_events.py +24 -18
- epyt_flow/simulation/events/leakages.py +59 -57
- epyt_flow/simulation/events/quality_events.py +21 -30
- epyt_flow/simulation/events/system_event.py +3 -3
- epyt_flow/simulation/scada/complex_control.py +14 -12
- epyt_flow/simulation/scada/custom_control.py +22 -21
- epyt_flow/simulation/scada/scada_data.py +108 -105
- epyt_flow/simulation/scada/simple_control.py +38 -31
- epyt_flow/simulation/scenario_simulator.py +368 -395
- epyt_flow/simulation/sensor_config.py +31 -32
- epyt_flow/topology.py +11 -10
- epyt_flow/uncertainty/model_uncertainty.py +146 -122
- epyt_flow/utils.py +66 -0
- epyt_flow/visualization/visualization_utils.py +4 -2
- {epyt_flow-0.14.1.dist-info → epyt_flow-0.15.0.dist-info}/METADATA +14 -19
- epyt_flow-0.15.0.dist-info/RECORD +65 -0
- epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +0 -60
- epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +0 -21
- epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +0 -151
- epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +0 -5930
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +0 -961
- epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +0 -79
- epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +0 -186
- epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +0 -219
- epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +0 -1000
- epyt_flow/EPANET/EPANET/SRC_engines/hash.c +0 -177
- epyt_flow/EPANET/EPANET/SRC_engines/hash.h +0 -28
- epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +0 -1303
- epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +0 -1172
- epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +0 -781
- epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +0 -442
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +0 -464
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +0 -1960
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +0 -518
- epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +0 -884
- epyt_flow/EPANET/EPANET/SRC_engines/input1.c +0 -672
- epyt_flow/EPANET/EPANET/SRC_engines/input2.c +0 -735
- epyt_flow/EPANET/EPANET/SRC_engines/input3.c +0 -2265
- epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +0 -527
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +0 -146
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +0 -24
- epyt_flow/EPANET/EPANET/SRC_engines/output.c +0 -853
- epyt_flow/EPANET/EPANET/SRC_engines/project.c +0 -1691
- epyt_flow/EPANET/EPANET/SRC_engines/quality.c +0 -695
- epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +0 -800
- epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +0 -696
- epyt_flow/EPANET/EPANET/SRC_engines/report.c +0 -1557
- epyt_flow/EPANET/EPANET/SRC_engines/rules.c +0 -1500
- epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +0 -871
- epyt_flow/EPANET/EPANET/SRC_engines/text.h +0 -508
- epyt_flow/EPANET/EPANET/SRC_engines/types.h +0 -928
- epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +0 -59
- epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +0 -38
- epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +0 -92
- epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +0 -39
- epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +0 -212
- epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +0 -81
- epyt_flow/EPANET/EPANET/SRC_engines/validate.c +0 -408
- epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +0 -53
- epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +0 -27
- epyt_flow/EPANET/EPANET-MSX/Src/hash.c +0 -107
- epyt_flow/EPANET/EPANET-MSX/Src/hash.h +0 -28
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +0 -102
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +0 -42
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +0 -937
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +0 -39
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +0 -204
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +0 -24
- epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +0 -1285
- epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +0 -368
- epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +0 -42
- epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +0 -586
- epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +0 -116
- epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +0 -260
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +0 -175
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +0 -35
- epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +0 -1504
- epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +0 -401
- epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +0 -791
- epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +0 -2010
- epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +0 -400
- epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +0 -422
- epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +0 -1164
- epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +0 -551
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +0 -524
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +0 -56
- epyt_flow/EPANET/EPANET-MSX/Src/newton.c +0 -158
- epyt_flow/EPANET/EPANET-MSX/Src/newton.h +0 -34
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +0 -287
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +0 -39
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +0 -293
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +0 -35
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +0 -816
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +0 -29
- epyt_flow/EPANET/EPANET-MSX/readme.txt +0 -14
- epyt_flow/EPANET/compile_linux.sh +0 -4
- epyt_flow/EPANET/compile_macos.sh +0 -4
- epyt_flow/simulation/backend/__init__.py +0 -1
- epyt_flow/simulation/backend/my_epyt.py +0 -1101
- epyt_flow-0.14.1.dist-info/RECORD +0 -148
- {epyt_flow-0.14.1.dist-info → epyt_flow-0.15.0.dist-info}/WHEEL +0 -0
- {epyt_flow-0.14.1.dist-info → epyt_flow-0.15.0.dist-info}/licenses/LICENSE +0 -0
- {epyt_flow-0.14.1.dist-info → epyt_flow-0.15.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
The module contains classes for representing simple control rules as used in EPANET.
|
|
3
3
|
"""
|
|
4
4
|
from typing import Union
|
|
5
|
-
from
|
|
5
|
+
from epanet_plus import EpanetConstants
|
|
6
6
|
|
|
7
7
|
from ..events import ActuatorConstants
|
|
8
8
|
from ...serialization import JsonSerializable, SIMPLE_CONTROL_ID, serializable
|
|
@@ -27,8 +27,10 @@ class SimpleControlModule(JsonSerializable):
|
|
|
27
27
|
must be one of the followig costants defined in
|
|
28
28
|
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
29
29
|
|
|
30
|
-
- EN_CLOSED
|
|
31
|
-
- EN_OPEN
|
|
30
|
+
- EN_CLOSED = 0
|
|
31
|
+
- EN_OPEN = 1
|
|
32
|
+
- EN_SET_CLOSED = -1e10
|
|
33
|
+
- EN_SET_OPEN = 1e10
|
|
32
34
|
cond_type : `int`
|
|
33
35
|
Condition/Rule type.
|
|
34
36
|
|
|
@@ -57,27 +59,25 @@ class SimpleControlModule(JsonSerializable):
|
|
|
57
59
|
**kwds):
|
|
58
60
|
if not isinstance(link_id, str):
|
|
59
61
|
raise TypeError(f"'link_id' must be an instance of 'str' but not of '{type(link_id)}'")
|
|
60
|
-
if isinstance(link_status, int):
|
|
61
|
-
if link_status not in [ActuatorConstants.EN_OPEN, ActuatorConstants.EN_CLOSED]:
|
|
62
|
-
raise ValueError(f"Invalid link status {link_status} in 'link_status'")
|
|
63
|
-
elif isinstance(link_status, float):
|
|
64
|
-
if link_status < 0:
|
|
65
|
-
raise TypeError("'link_status' can not be negative")
|
|
66
|
-
else:
|
|
62
|
+
if not isinstance(link_status, int) and not isinstance(link_status, float):
|
|
67
63
|
raise TypeError("'link_status' must be an instance of 'int' or 'float' but not " +
|
|
68
64
|
f"of '{type(link_status)}'")
|
|
69
|
-
if
|
|
70
|
-
|
|
65
|
+
if link_status not in [ActuatorConstants.EN_OPEN, ActuatorConstants.EN_CLOSED,
|
|
66
|
+
ActuatorConstants.EN_SET_OPEN, ActuatorConstants.EN_SET_CLOSED]:
|
|
67
|
+
if link_status < 0:
|
|
68
|
+
raise TypeError("'link_status' can not be negative")
|
|
69
|
+
if cond_type not in [EpanetConstants.EN_TIMEOFDAY, EpanetConstants.EN_TIMER,
|
|
70
|
+
EpanetConstants.EN_LOWLEVEL, EpanetConstants.EN_HILEVEL]:
|
|
71
71
|
raise ValueError(f"Invalid control type '{cond_type}' in 'cond_type'")
|
|
72
72
|
|
|
73
|
-
if cond_type ==
|
|
73
|
+
if cond_type == EpanetConstants.EN_TIMEOFDAY:
|
|
74
74
|
if not isinstance(cond_var_value, str):
|
|
75
75
|
raise TypeError("EN_TIMEOFDAY requires that 'cond_var_value' must be an instance " +
|
|
76
76
|
f"of 'str' but not of '{type(cond_var_value)}'")
|
|
77
77
|
if not cond_var_value.endswith("AM") and not cond_var_value.endswith("PM"):
|
|
78
78
|
raise ValueError(f"Invalid time of day format '{cond_var_value}' in " +
|
|
79
79
|
"'cond_var_value'")
|
|
80
|
-
elif cond_type ==
|
|
80
|
+
elif cond_type == EpanetConstants.EN_TIMER:
|
|
81
81
|
if not isinstance(cond_var_value, int):
|
|
82
82
|
raise TypeError("EN_TIMER requires that 'cond_var_value' must be an instance " +
|
|
83
83
|
f"of 'int' but not of '{type(cond_var_value)}'")
|
|
@@ -121,11 +121,14 @@ class SimpleControlModule(JsonSerializable):
|
|
|
121
121
|
Returns
|
|
122
122
|
-------
|
|
123
123
|
`int` or `float`
|
|
124
|
-
Pump speed if the link is a pump, otherwise one of the followig
|
|
124
|
+
Pump speed if the link is a pump, otherwise one of the followig constants defined in
|
|
125
125
|
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
126
126
|
|
|
127
|
-
- EN_CLOSED
|
|
128
|
-
- EN_OPEN
|
|
127
|
+
- EN_CLOSED = 0
|
|
128
|
+
- EN_OPEN = 1
|
|
129
|
+
- EN_SET_CLOSED = -1e10
|
|
130
|
+
- EN_SET_OPEN = 1e10
|
|
131
|
+
|
|
129
132
|
"""
|
|
130
133
|
return self.__link_status
|
|
131
134
|
|
|
@@ -193,18 +196,18 @@ class SimpleControlModule(JsonSerializable):
|
|
|
193
196
|
def __str__(self) -> str:
|
|
194
197
|
control_rule_str = f"LINK {self.__link_id} "
|
|
195
198
|
if isinstance(self.__link_status, int):
|
|
196
|
-
control_rule_str += "OPEN " if self.__link_status == ActuatorConstants.EN_OPEN \
|
|
197
|
-
else "CLOSED "
|
|
199
|
+
control_rule_str += "OPEN " if self.__link_status == ActuatorConstants.EN_OPEN or \
|
|
200
|
+
self.__link_status == ActuatorConstants.EN_SET_OPEN else "CLOSED "
|
|
198
201
|
else:
|
|
199
202
|
control_rule_str += f"{self.__link_status} "
|
|
200
203
|
|
|
201
|
-
if self.__cond_type ==
|
|
204
|
+
if self.__cond_type == EpanetConstants.EN_TIMER:
|
|
202
205
|
control_rule_str += f"AT TIME {self.__cond_var_value}"
|
|
203
|
-
elif self.__cond_type ==
|
|
206
|
+
elif self.__cond_type == EpanetConstants.EN_TIMEOFDAY:
|
|
204
207
|
control_rule_str += f"AT CLOCKTIME {self.__cond_var_value}"
|
|
205
|
-
elif self.__cond_type ==
|
|
208
|
+
elif self.__cond_type == EpanetConstants.EN_LOWLEVEL:
|
|
206
209
|
control_rule_str += f"IF NODE {self.__cond_var_value} BELOW {self.__cond_comp_value}"
|
|
207
|
-
elif self.__cond_type ==
|
|
210
|
+
elif self.__cond_type == EpanetConstants.EN_HILEVEL:
|
|
208
211
|
control_rule_str += f"IF NODE {self.__cond_var_value} ABOVE {self.__cond_comp_value}"
|
|
209
212
|
|
|
210
213
|
return control_rule_str
|
|
@@ -226,8 +229,8 @@ class SimplePumpSpeedTimeControl(SimpleControlModule):
|
|
|
226
229
|
"""
|
|
227
230
|
def __init__(self, pump_id: str, pump_speed: float, time: Union[str, int]):
|
|
228
231
|
super().__init__(link_id=pump_id, link_status=pump_speed,
|
|
229
|
-
cond_type=
|
|
230
|
-
else
|
|
232
|
+
cond_type=EpanetConstants.EN_TIMER if isinstance(time, int)
|
|
233
|
+
else EpanetConstants.EN_TIMEOFDAY,
|
|
231
234
|
cond_var_value=time, cond_comp_value=None)
|
|
232
235
|
|
|
233
236
|
|
|
@@ -273,16 +276,18 @@ class SimpleValveTimeControl(SimpleControlModule):
|
|
|
273
276
|
Valve status -- must be one of the followig costants defined in
|
|
274
277
|
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
275
278
|
|
|
276
|
-
- EN_CLOSED
|
|
277
|
-
- EN_OPEN
|
|
279
|
+
- EN_CLOSED = 0
|
|
280
|
+
- EN_OPEN = 1
|
|
281
|
+
- EN_SET_CLOSED = -1e10
|
|
282
|
+
- EN_SET_OPEN = 1e10
|
|
278
283
|
time : `str` or `int`
|
|
279
284
|
Time of the day (in AM/PM format) in the case or
|
|
280
285
|
number of hours (as an integer) since simulation start.
|
|
281
286
|
"""
|
|
282
287
|
def __init__(self, valve_id: str, valve_status: int, time: Union[str, int]):
|
|
283
288
|
super().__init__(link_id=valve_id, link_status=valve_status,
|
|
284
|
-
cond_type=
|
|
285
|
-
else
|
|
289
|
+
cond_type=EpanetConstants.EN_TIMER if isinstance(time, int)
|
|
290
|
+
else EpanetConstants.EN_TIMEOFDAY,
|
|
286
291
|
cond_var_value=time, cond_comp_value=None)
|
|
287
292
|
|
|
288
293
|
|
|
@@ -298,8 +303,10 @@ class SimpleValveConditionControl(SimpleControlModule):
|
|
|
298
303
|
Valve status -- must be one of the followig costants defined in
|
|
299
304
|
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
300
305
|
|
|
301
|
-
- EN_CLOSED
|
|
302
|
-
- EN_OPEN
|
|
306
|
+
- EN_CLOSED = 0
|
|
307
|
+
- EN_OPEN = 1
|
|
308
|
+
- EN_SET_CLOSED = -1e10
|
|
309
|
+
- EN_SET_OPEN = 1e10
|
|
303
310
|
node_id : `str`
|
|
304
311
|
Node ID.
|
|
305
312
|
comp_type : `int`
|