|
| 1 | + |
| 2 | + |
| 3 | +# Scalable and Robust Physics-Informed Graph Neural Networks for Water Distribution Systems. |
| 4 | + |
| 5 | +Official Code for the paper "Scalable and Robust Physics-Informed Graph Neural Networks for Water Distribution Systems" (under submission, preprint available at arXiv: ). \ |
| 6 | +All system and package requirements are listed in the document 'environment.yml'. A corresponding conda environment can be setup via `conda env create -f environment.yml`. |
| 7 | + |
| 8 | +## Simulating scenarios to generate data |
| 9 | + |
| 10 | +WDS datasets can be generated (Vrachimis et al. https://github.com/KIOS-Research/BattLeDIM) using: |
| 11 | + |
| 12 | +``` python |
| 13 | +python utils/dataset_generator.py |
| 14 | +``` |
| 15 | + |
| 16 | +A number of arguments can be passed to dataset generation parameters: |
| 17 | + |
| 18 | +``` python |
| 19 | +'--wds' "Specify the WDS for which you want to simulate the scenarios; default is anytown. Choices are ['anytown', 'hanoi', 'pescara', 'area_c', 'zhijiang', 'modena', 'pa1', 'balerma', 'area_a', 'l_town', 'kl']." |
| 20 | +'--sim_start_time' "Specify the start time of the simulation; default is 2018-01-01 00:00, the simulation will be done every 30 minutes starting from this time." |
| 21 | +'--sim_end_time' "Specify the end time of the simulation; default is 2018-01-01 02:30." |
| 22 | +'--start_scenario' "Specify the start scenario name, must be an integer; default is 1000" |
| 23 | +'--end_scenario' "Specify the end scenario name, must be an integer; default is 1999" |
| 24 | +``` |
| 25 | + |
| 26 | +The simulation will produce an xlsx file for each scenario in the folder 'results' in the respective directories. These xlsx files will be used for training the models. |
| 27 | + |
| 28 | +## Training and Evaluation |
| 29 | + |
| 30 | + |
| 31 | +Models can be trained using |
| 32 | +```python |
| 33 | +python run.py |
| 34 | +``` |
| 35 | +A number of arguments can be passed to specify model types and hyperparameters: |
| 36 | + |
| 37 | +``` python |
| 38 | +'--wds' "Specify the WDS for which you want to simulate the scenarios; default is anytown. Choices are ['anytown', 'hanoi', 'pescara', 'area_c', 'zhijiang', 'modena', 'pa1', 'balerma', 'area_a', 'l_town', 'kl']." |
| 39 | +'--mode' "train_test i.e. train and test a new model, or evaluate i.e. evaluate on an already trained model; default is train_test. " |
| 40 | +'--warm_start' "Specify True if you want to further train a partially trained model. model_path must also be specified; default is False." |
| 41 | +'--model_path' "Specify model path in case of re-training or evaluation; default is None." |
| 42 | +'--model' "Choose the model between PI_GNN and SPI_GNN; default is SPI_GNN." |
| 43 | +'--start_scenario' "Specify the start scenario name, must be an integer; default is 1" |
| 44 | +'--end_scenario' "Specify the end scenario name, must be an integer; default is 20" |
| 45 | +'--n_samples' "Specify the number of samples for each scenario to be used for training; default is 6." |
| 46 | +'--batch_size' "Specify the mini-batch size; default is 96." |
| 47 | +'--n_epochs' "Specify the number of epochs of training; default is 1500." |
| 48 | +'--lr' "Specify the learning rate; default is 1e-4." |
| 49 | +'--decay_step' "Specify the step size of the lr scheduler; default is 150." |
| 50 | +'--decay_rate' "Specify the decay rate of the lr scheduler; default is 0.75." |
| 51 | +'--I' "Specify the number of GCN layers; default is 5." |
| 52 | +'--n_iter' "Specify the minimum number of iterations; default is 5." |
| 53 | +'--r_iter' "Specify the maximum number of additional (random) iterations; default is 5." |
| 54 | +'--n_mlp' "Specify the number of layers in the MLP; default is 1." |
| 55 | +'--M_l' "Specify the latent dimension; default is 128." |
| 56 | +'--wandb' "Specify True if you want to use Weights and Biases during training; default is False." |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | +Trained models can be used for evaluation using run.py by specifying the 'evaluate' mode and 'model_path'. |
| 61 | + |
| 62 | +## Robustness Evaluation |
| 63 | + |
| 64 | +Trained models can be evaluated for robustness using |
| 65 | + |
| 66 | +```python |
| 67 | +python robustness_eval.py |
| 68 | +``` |
| 69 | +A number of arguments can be passed: |
| 70 | + |
| 71 | +``` python |
| 72 | +'--wds' "Specify the WDS for which you want to simulate the scenarios; default is anytown. Choices are ['anytown', 'hanoi', 'pescara', 'area_c', 'zhijiang', 'modena', 'pa1', 'balerma', 'area_a', 'l_town', 'kl']." |
| 73 | +'--mode' "'demands' or 'diameters', evaluate robustness by changing demands or diameters; default is demands. " |
| 74 | +'--model_path' "Specify the trained model path; default is the trained model for Anytown." |
| 75 | +'--model' "Choose the model between PI_GNN and SPI_GNN; default is SPI_GNN." |
| 76 | +'--batch_size' "Specify the mini-batch size; default is 1000." |
| 77 | +'--I' "Specify the number of GCN layers; default is 5." |
| 78 | +'--n_iter' "Specify the minimum number of iterations; default is 5." |
| 79 | +'--r_iter' "Specify the maximum number of additional iterations; default is 5." |
| 80 | +'--n_mlp' "Specify the number of layers in the MLP; default is 1." |
| 81 | +'--M_l' "Specify the latent dimension; default is 128." |
| 82 | + |
| 83 | +``` |
| 84 | +The robustness evaluation results can further be analyzed using the notebooks in 'results' directory. |
| 85 | + |
| 86 | +## Important Information |
| 87 | + |
| 88 | +Every WDS is specified by an '.inp' file. We have included those files for all WDSs. Moreover, we also include trained models for all WDSs. |
| 89 | + |
| 90 | +## Citation |
| 91 | +### Preprint: |
| 92 | +``` |
| 93 | +@misc{ashraf2025spignn_wds, |
| 94 | + author = {Ashraf, Inaam and Artelt, Andr{\'{e}} and Hammer, Barbara}, |
| 95 | + title = {Scalable and Robust Physics-Informed Graph Neural Networks for Water Distribution Systems.}, |
| 96 | + year = {2025}, |
| 97 | + month = feb, |
| 98 | + archiveprefix = {arXiv}, |
| 99 | + eprint = {}, |
| 100 | + copyright = {Creative Commons Attribution Share Alike 4.0 International} |
| 101 | +} |
| 102 | +``` |
| 103 | +### Repository: |
| 104 | +``` |
| 105 | +@misc{SPIGNNs_for_WDSs, |
| 106 | + author = {Ashraf, Inaam and Artelt, Andr{\'{e}} and Hammer, Barbara}, |
| 107 | + title = {{SPIGNNs_for_WDSs}}, |
| 108 | + year = {2025}, |
| 109 | + publisher = {GitHub} |
| 110 | + journal = {GitHub repository}, |
| 111 | + organization = {CITEC, Bielefeld University, Germany}, |
| 112 | + howpublished = {\url{https://github.com/inaamashraf/SPIGNNs_for_WDSs}}, |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | + |
| 117 | +## Acknowledgments |
| 118 | +We gratefully acknowledge funding from the European |
| 119 | +Research Council (ERC) under the ERC Synergy Grant Water-Futures (Grant |
| 120 | +agreement No. 951424). |
0 commit comments