epyt-flow 0.5.0__tar.gz → 0.6.0__tar.gz
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-0.5.0 → epyt_flow-0.6.0}/PKG-INFO +2 -2
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/REQUIREMENTS.txt +1 -1
- epyt_flow-0.6.0/epyt_flow/VERSION +1 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/battledim.py +6 -2
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/leakdb.py +11 -9
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/networks.py +1 -2
- epyt_flow-0.6.0/epyt_flow/gym/scenario_control_env.py +196 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/serialization.py +13 -3
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scada/advanced_control.py +1 -1
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scada/scada_data.py +159 -61
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scenario_config.py +6 -2
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scenario_simulator.py +274 -64
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/sensor_config.py +185 -14
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/topology.py +90 -2
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow.egg-info/PKG-INFO +2 -2
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow.egg-info/requires.txt +1 -1
- epyt_flow-0.6.0/epyt_flow.egg-info/top_level.txt +6 -0
- epyt_flow-0.5.0/epyt_flow/VERSION +0 -1
- epyt_flow-0.5.0/epyt_flow/gym/scenario_control_env.py +0 -101
- epyt_flow-0.5.0/epyt_flow.egg-info/top_level.txt +0 -12
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/CITATION.cff +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/CODE_OF_CONDUCT.md +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/LICENSE +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/MANIFEST.in +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/README.md +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hash.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hash.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/input1.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/input2.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/input3.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/output.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/project.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/quality.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/report.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/rules.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/text.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET/SRC_engines/types.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/hash.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/hash.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/newton.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/newton.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/EPANET-MSX/readme.txt +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/compile_linux.sh +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/EPANET/compile_macos.sh +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/batadal.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/batadal_data.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/battledim_data.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/gecco_water_quality.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/leakdb_data.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/data/benchmarks/water_usage.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/gym/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/gym/control_gyms.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/metrics.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/models/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/models/event_detector.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/models/sensor_interpolation_detector.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/base_handler.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/res_manager.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scada_data/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scada_data/data_handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scada_data/export_handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scada_data/handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scenario/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scenario/event_handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scenario/handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scenario/simulation_handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/scenario/uncertainty_handlers.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/rest_api/server.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/actuator_events.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/event.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/leakages.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/sensor_faults.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/sensor_reading_attack.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/sensor_reading_event.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/events/system_event.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/parallel_simulation.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scada/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scada/scada_data_export.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/simulation/scenario_visualizer.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/uncertainty/__init__.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/uncertainty/model_uncertainty.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/uncertainty/sensor_noise.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/uncertainty/uncertainties.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/uncertainty/utils.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow/utils.py +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow.egg-info/SOURCES.txt +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/epyt_flow.egg-info/dependency_links.txt +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/pyproject.toml +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/setup.cfg +0 -0
- {epyt_flow-0.5.0 → epyt_flow-0.6.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: epyt-flow
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: EPyT-Flow -- EPANET Python Toolkit - Flow
|
|
5
5
|
Author-email: André Artelt <aartelt@techfak.uni-bielefeld.de>, "Marios S. Kyriakou" <kiriakou.marios@ucy.ac.cy>, "Stelios G. Vrachimis" <vrachimis.stelios@ucy.ac.cy>
|
|
6
6
|
License: MIT License
|
|
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: epyt>=1.1.
|
|
23
|
+
Requires-Dist: epyt>=1.1.9
|
|
24
24
|
Requires-Dist: requests>=2.31.0
|
|
25
25
|
Requires-Dist: scipy>=1.11.4
|
|
26
26
|
Requires-Dist: u-msgpack-python>=2.8.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.6.0
|
|
@@ -458,10 +458,14 @@ def load_scenario(return_test_scenario: bool, download_dir: str = None,
|
|
|
458
458
|
ltown_config = load_ltown(use_realistic_demands=True, include_default_sensor_placement=True,
|
|
459
459
|
verbose=verbose)
|
|
460
460
|
|
|
461
|
-
# Set simulation duration
|
|
461
|
+
# Set simulation duration and other general parameters such as the demand model
|
|
462
462
|
general_params = {"simulation_duration": to_seconds(days=365), # One year
|
|
463
463
|
"hydraulic_time_step": to_seconds(minutes=5), # 5min time steps
|
|
464
|
-
"reporting_time_step": to_seconds(minutes=5)
|
|
464
|
+
"reporting_time_step": to_seconds(minutes=5),
|
|
465
|
+
"demand_model": {"type": "PDA", "pressure_min": 0,
|
|
466
|
+
"pressure_required": 0.1,
|
|
467
|
+
"pressure_exponent": 0.5}
|
|
468
|
+
} | ltown_config.general_params
|
|
465
469
|
|
|
466
470
|
# Add events
|
|
467
471
|
start_time = START_TIME_TEST if return_test_scenario is True else START_TIME_TRAIN
|
|
@@ -30,7 +30,7 @@ from .leakdb_data import NET1_LEAKAGES, HANOI_LEAKAGES
|
|
|
30
30
|
from ...utils import get_temp_folder, to_seconds, unpack_zip_archive, create_path_if_not_exist, \
|
|
31
31
|
download_if_necessary
|
|
32
32
|
from ...metrics import f1_score, true_positive_rate, true_negative_rate
|
|
33
|
-
from ...simulation import ScenarioSimulator
|
|
33
|
+
from ...simulation import ScenarioSimulator, ToolkitConstants
|
|
34
34
|
from ...simulation.events import AbruptLeakage, IncipientLeakage
|
|
35
35
|
from ...simulation import ScenarioConfig
|
|
36
36
|
from ...simulation.scada import ScadaData
|
|
@@ -424,14 +424,19 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
424
424
|
download_dir = download_dir if download_dir is not None else get_temp_folder()
|
|
425
425
|
network_config = load_network(download_dir)
|
|
426
426
|
|
|
427
|
-
# Set simulation duration
|
|
427
|
+
# Set simulation duration and other general parameters such as the demand model and flow units
|
|
428
428
|
hydraulic_time_step = to_seconds(minutes=30) # 30min time steps
|
|
429
429
|
general_params = {"simulation_duration": to_seconds(days=365), # One year
|
|
430
430
|
"hydraulic_time_step": hydraulic_time_step,
|
|
431
|
-
"reporting_time_step": hydraulic_time_step
|
|
431
|
+
"reporting_time_step": hydraulic_time_step,
|
|
432
|
+
"flow_units_id": ToolkitConstants.EN_CMH,
|
|
433
|
+
"demand_model": {"type": "PDA", "pressure_min": 0,
|
|
434
|
+
"pressure_required": 0.1,
|
|
435
|
+
"pressure_exponent": 0.5}
|
|
436
|
+
} | network_config.general_params
|
|
432
437
|
|
|
433
438
|
# Add demand patterns
|
|
434
|
-
def gen_dem(download_dir
|
|
439
|
+
def gen_dem(download_dir):
|
|
435
440
|
# Taken from https://github.com/KIOS-Research/LeakDB/blob/master/CCWI-WDSA2018/Dataset_Generator_Py3/demandGenerator.py
|
|
436
441
|
week_pat = scipy.io.loadmat(os.path.join(download_dir, "weekPat_30min.mat"))
|
|
437
442
|
a_w = week_pat['Aw']
|
|
@@ -503,10 +508,7 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
503
508
|
|
|
504
509
|
if not os.path.exists(f_inp_in):
|
|
505
510
|
with ScenarioSimulator(f_inp_in=network_config.f_inp_in) as wdn:
|
|
506
|
-
wdn.
|
|
507
|
-
wdn.epanet_api.setTimeSimulationDuration(general_params["simulation_duration"])
|
|
508
|
-
wdn.epanet_api.setTimePatternStep(general_params["hydraulic_time_step"])
|
|
509
|
-
wdn.epanet_api.setFlowUnitsCMH()
|
|
511
|
+
wdn.set_general_parameters(**general_params)
|
|
510
512
|
|
|
511
513
|
wdn.epanet_api.deletePatternsAll()
|
|
512
514
|
|
|
@@ -519,7 +521,7 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
519
521
|
node_idx = wdn.epanet_api.getNodeIndex(node_id)
|
|
520
522
|
base_demand = wdn.epanet_api.getNodeBaseDemands(node_idx)[1][0]
|
|
521
523
|
|
|
522
|
-
my_demand_pattern = np.array(gen_dem(download_dir
|
|
524
|
+
my_demand_pattern = np.array(gen_dem(download_dir))
|
|
523
525
|
|
|
524
526
|
wdn.set_node_demand_pattern(node_id=node_id, base_demand=base_demand,
|
|
525
527
|
demand_pattern_id=f"demand_{node_id}",
|
|
@@ -56,8 +56,7 @@ def get_default_hydraulic_options(flow_units_id: int = None) -> dict:
|
|
|
56
56
|
Dictionary with default hydraulics options that can be passed to
|
|
57
57
|
:func:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator.set_general_parameters`.
|
|
58
58
|
"""
|
|
59
|
-
params = {
|
|
60
|
-
"pressure_exponent": 0.5}}
|
|
59
|
+
params = {}
|
|
61
60
|
if flow_units_id is not None:
|
|
62
61
|
params |= {"flow_units_id": flow_units_id}
|
|
63
62
|
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module provides a base class for control environments.
|
|
3
|
+
"""
|
|
4
|
+
from abc import abstractmethod, ABC
|
|
5
|
+
from typing import Union
|
|
6
|
+
import warnings
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from ..simulation import ScenarioSimulator, ScenarioConfig, ScadaData
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ScenarioControlEnv(ABC):
|
|
13
|
+
"""
|
|
14
|
+
Base class for a control environment challenge.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
scenario_config : :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
19
|
+
Scenario configuration.
|
|
20
|
+
autoreset : `bool`, optional
|
|
21
|
+
If True, environment is automatically reset if terminated.
|
|
22
|
+
|
|
23
|
+
The default is False.
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, scenario_config: ScenarioConfig, autoreset: bool = False, **kwds):
|
|
26
|
+
self.__scenario_config = scenario_config
|
|
27
|
+
self._scenario_sim = None
|
|
28
|
+
self._sim_generator = None
|
|
29
|
+
self.__autoreset = autoreset
|
|
30
|
+
|
|
31
|
+
super().__init__(**kwds)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def autoreset(self) -> bool:
|
|
35
|
+
"""
|
|
36
|
+
True, if environment automatically resets after it terminated.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
`bool`
|
|
41
|
+
True, if environment automatically resets after it terminated.
|
|
42
|
+
"""
|
|
43
|
+
return self.__autoreset
|
|
44
|
+
|
|
45
|
+
def __enter__(self):
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def __exit__(self, *args):
|
|
49
|
+
self.close()
|
|
50
|
+
|
|
51
|
+
def close(self) -> None:
|
|
52
|
+
"""
|
|
53
|
+
Frees all resources.
|
|
54
|
+
"""
|
|
55
|
+
try:
|
|
56
|
+
if self._sim_generator is not None:
|
|
57
|
+
self._sim_generator.send(True)
|
|
58
|
+
next(self._sim_generator)
|
|
59
|
+
except StopIteration:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
if self._scenario_sim is not None:
|
|
63
|
+
self._scenario_sim.close()
|
|
64
|
+
|
|
65
|
+
def reset(self) -> ScadaData:
|
|
66
|
+
"""
|
|
67
|
+
Resets the environment (i.e. simulation).
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
:class:`~epyt_flow.simulation.scada.scada_data.ScadaData`
|
|
72
|
+
Current SCADA data (i.e. sensor readings).
|
|
73
|
+
"""
|
|
74
|
+
if self._scenario_sim is not None:
|
|
75
|
+
self._scenario_sim.close()
|
|
76
|
+
|
|
77
|
+
self._scenario_sim = ScenarioSimulator(
|
|
78
|
+
scenario_config=self.__scenario_config)
|
|
79
|
+
self._sim_generator = self._scenario_sim.run_simulation_as_generator(support_abort=True)
|
|
80
|
+
|
|
81
|
+
return self._next_sim_itr()
|
|
82
|
+
|
|
83
|
+
def _next_sim_itr(self) -> ScadaData:
|
|
84
|
+
try:
|
|
85
|
+
next(self._sim_generator)
|
|
86
|
+
r = self._sim_generator.send(False)
|
|
87
|
+
|
|
88
|
+
if self.autoreset is True:
|
|
89
|
+
return r
|
|
90
|
+
else:
|
|
91
|
+
return r, False
|
|
92
|
+
except StopIteration:
|
|
93
|
+
if self.__autoreset is True:
|
|
94
|
+
return self.reset()
|
|
95
|
+
else:
|
|
96
|
+
return None, True
|
|
97
|
+
|
|
98
|
+
def set_pump_status(self, pump_id: str, status: int) -> None:
|
|
99
|
+
"""
|
|
100
|
+
Sets the status of a pump.
|
|
101
|
+
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
pump_id : `str`
|
|
105
|
+
ID of the pump for which the status is set.
|
|
106
|
+
status : `int`
|
|
107
|
+
New status of the pump -- either active (i.e. open) or inactive (i.e. closed).
|
|
108
|
+
|
|
109
|
+
Must be one of the following constants defined in
|
|
110
|
+
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
111
|
+
|
|
112
|
+
- EN_CLOSED = 0
|
|
113
|
+
- EN_OPEN = 1
|
|
114
|
+
"""
|
|
115
|
+
pump_idx = self._scenario_sim.epanet_api.getLinkPumpNameID().index(pump_id)
|
|
116
|
+
pump_link_idx = self._scenario_sim.epanet_api.getLinkPumpIndex(pump_idx + 1)
|
|
117
|
+
self._scenario_sim.epanet_api.setLinkStatus(pump_link_idx, status)
|
|
118
|
+
|
|
119
|
+
def set_pump_speed(self, pump_id: str, speed: float) -> None:
|
|
120
|
+
"""
|
|
121
|
+
Sets the speed of a pump.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
pump_id : `str`
|
|
126
|
+
ID of the pump for which the pump speed is set.
|
|
127
|
+
speed : `float`
|
|
128
|
+
New pump speed.
|
|
129
|
+
"""
|
|
130
|
+
pump_idx = self._scenario_sim.epanet_api.getLinkPumpNameID().index(pump_id)
|
|
131
|
+
pattern_idx = self._scenario_sim.epanet_api.getLinkPumpPatternIndex(pump_idx + 1)
|
|
132
|
+
|
|
133
|
+
if pattern_idx == 0:
|
|
134
|
+
warnings.warn(f"No pattern for pump '{pump_id}' found -- a new pattern is created")
|
|
135
|
+
pattern_idx = self._scenario_sim.epanet_api.addPattern(f"pump_speed_{pump_id}")
|
|
136
|
+
self._scenario_sim.epanet_api.setLinkPumpPatternIndex(pattern_idx)
|
|
137
|
+
|
|
138
|
+
self._scenario_sim.epanet_api.setPattern(pattern_idx, np.array([speed]))
|
|
139
|
+
|
|
140
|
+
def set_valve_status(self, valve_id: str, status: int) -> None:
|
|
141
|
+
"""
|
|
142
|
+
Sets the status of a valve.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
valve_id : `str`
|
|
147
|
+
ID of the valve for which the status is set.
|
|
148
|
+
status : `int`
|
|
149
|
+
New status of the valve -- either open or closed.
|
|
150
|
+
|
|
151
|
+
Must be one of the following constants defined in
|
|
152
|
+
:class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
|
|
153
|
+
|
|
154
|
+
- EN_CLOSED = 0
|
|
155
|
+
- EN_OPEN = 1
|
|
156
|
+
"""
|
|
157
|
+
valve_idx = self._scenario_sim.epanet_api.getLinkValveNameID().index(valve_id)
|
|
158
|
+
valve_link_idx = self._scenario_sim.epanet_api.getLinkValveIndex()[valve_idx]
|
|
159
|
+
self._scenario_sim.epanet_api.setLinkStatus(valve_link_idx, status)
|
|
160
|
+
|
|
161
|
+
def set_node_quality_source_value(self, node_id: str, pattern_id: str,
|
|
162
|
+
qual_value: float) -> None:
|
|
163
|
+
"""
|
|
164
|
+
Sets the quality source at a particular node to a specific value -- e.g.
|
|
165
|
+
setting the chlorine concentration injection to a specified value.
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
node_id : `str`
|
|
170
|
+
ID of the node.
|
|
171
|
+
pattern_id : `str`
|
|
172
|
+
ID of the quality pattern at the specific node.
|
|
173
|
+
qual_value : `float`
|
|
174
|
+
New quality source value.
|
|
175
|
+
"""
|
|
176
|
+
node_idx = self._scenario_sim.epanet_api.getNodeIndex(node_id)
|
|
177
|
+
pattern_idx = self._scenario_sim.epanet_api.getPatternIndex(pattern_id)
|
|
178
|
+
self._scenario_sim.epanet_api.setNodeSourceQuality(node_idx, 1)
|
|
179
|
+
self._scenario_sim.epanet_api.setPattern(pattern_idx, np.array([qual_value]))
|
|
180
|
+
|
|
181
|
+
@abstractmethod
|
|
182
|
+
def step(self, *actions) -> Union[tuple[ScadaData, float, bool], tuple[ScadaData, float]]:
|
|
183
|
+
"""
|
|
184
|
+
Performs the next step by applying an action and observing
|
|
185
|
+
the consequences (SCADA data, reward, terminated).
|
|
186
|
+
|
|
187
|
+
Note that `terminated` is only returned if `autoreset=False` otherwise
|
|
188
|
+
only the current SCADA data and reward are returned.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
`(` :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` `, float, bool)` or `(` :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` `, float)`
|
|
193
|
+
Triple or tuple of observations (:class:`~epyt_flow.simulation.scada.scada_data.ScadaData`),
|
|
194
|
+
reward (`float`), and terminated (`bool`).
|
|
195
|
+
"""
|
|
196
|
+
raise NotImplementedError()
|
|
@@ -4,6 +4,7 @@ Module provides functions and classes for serialization.
|
|
|
4
4
|
from typing import Any, Union
|
|
5
5
|
from abc import abstractmethod, ABC
|
|
6
6
|
from io import BufferedIOBase
|
|
7
|
+
import pathlib
|
|
7
8
|
import importlib
|
|
8
9
|
import json
|
|
9
10
|
import gzip
|
|
@@ -97,7 +98,9 @@ class Serializable(ABC):
|
|
|
97
98
|
Base class for a serializable class -- must be used in conjunction with the
|
|
98
99
|
:func:`~epyt_flow.serialization.serializable` decorator.
|
|
99
100
|
"""
|
|
100
|
-
def __init__(self, **kwds):
|
|
101
|
+
def __init__(self, _parent_path: str = "", **kwds):
|
|
102
|
+
self._parent_path = _parent_path
|
|
103
|
+
|
|
101
104
|
super().__init__(**kwds)
|
|
102
105
|
|
|
103
106
|
@abstractmethod
|
|
@@ -376,12 +379,19 @@ def load_from_file(f_in: str, use_compression: bool = True) -> Any:
|
|
|
376
379
|
`Any`
|
|
377
380
|
Deserialized data.
|
|
378
381
|
"""
|
|
382
|
+
inst = None
|
|
383
|
+
|
|
379
384
|
if use_compression is False:
|
|
380
385
|
with open(f_in, "rb") as f:
|
|
381
|
-
|
|
386
|
+
inst = load(f.read())
|
|
382
387
|
else:
|
|
383
388
|
with gzip.open(f_in, "rb") as f:
|
|
384
|
-
|
|
389
|
+
inst = load(f.read())
|
|
390
|
+
|
|
391
|
+
if isinstance(inst, Serializable):
|
|
392
|
+
inst._parent_path = pathlib.Path(f_in).parent.resolve()
|
|
393
|
+
|
|
394
|
+
return inst
|
|
385
395
|
|
|
386
396
|
|
|
387
397
|
def save_to_file(f_out: str, data: Any, use_compression: bool = True) -> None:
|
|
@@ -98,7 +98,7 @@ class AdvancedControlModule(ABC):
|
|
|
98
98
|
- EN_OPEN = 1
|
|
99
99
|
"""
|
|
100
100
|
valve_idx = self._epanet_api.getLinkValveNameID().index(valve_id)
|
|
101
|
-
valve_link_idx = self._epanet_api.getLinkValveIndex(valve_idx
|
|
101
|
+
valve_link_idx = self._epanet_api.getLinkValveIndex()[valve_idx]
|
|
102
102
|
self._epanet_api.setLinkStatus(valve_link_idx, status)
|
|
103
103
|
|
|
104
104
|
def set_node_quality_source_value(self, node_id: str, pattern_id: str,
|