├── .gitattributes ├── Dataset Generator ├── .gitattributes ├── L-TOWN_v2_Model.inp ├── L-TOWN_v2_Real.inp ├── README.txt ├── dataset_configuration.yalm ├── dataset_configuration_evaluation.yalm ├── dataset_configuration_historical.yalm ├── dataset_generator.exe └── dataset_generator.py ├── LICENSE.md ├── README.md └── Scoring Algorithm ├── SUBMITTED_files ├── PERFECT_TEAM.txt ├── test_team.txt └── test_team_multiple.txt ├── Scoring_Algorithm.m ├── competition_data ├── D_Mat_L-TOWN.mat ├── L-TOWN.inp ├── leak_info.mat ├── leakage_evolution.png ├── leakage_placement.png └── leakages_info.yalm ├── competition_leakages ├── Leak_p123.xlsx ├── Leak_p142.xlsx ├── Leak_p193.xlsx ├── Leak_p257.xlsx ├── Leak_p277.xlsx ├── Leak_p280.xlsx ├── Leak_p331.xlsx ├── Leak_p426.xlsx ├── Leak_p427.xlsx ├── Leak_p455.xlsx ├── Leak_p514.xlsx ├── Leak_p523.xlsx ├── Leak_p586.xlsx ├── Leak_p653.xlsx ├── Leak_p654.xlsx ├── Leak_p680.xlsx ├── Leak_p710.xlsx ├── Leak_p721.xlsx ├── Leak_p762.xlsx ├── Leak_p800.xlsx ├── Leak_p810.xlsx ├── Leak_p827.xlsx └── Leak_p879.xlsx ├── epanet_matlab ├── 32bit │ ├── epanet2.dll │ ├── epanet2.exe │ ├── epanet2.h │ ├── epanet2_enums.h │ ├── epanetmsx.dll │ ├── epanetmsx.exe │ └── epanetmsx.h ├── 64bit │ ├── epanet2.dll │ ├── epanet2.exe │ ├── epanet2.h │ ├── epanet2_enums.h │ ├── epanetmsx.dll │ ├── epanetmsx.exe │ └── epanetmsx.h ├── epanet.m └── glnx │ ├── epanet2_enums.h │ ├── libepanet.h │ ├── libepanet.so │ └── runepanet ├── functions ├── EPAsimulation.m ├── barvalues.m ├── chooseDataFile.m ├── chooseNetwork.m ├── nodeTopologicalDistance.m ├── readLeakageFile.m ├── readResultsFile.m ├── scoring_function.m ├── selectResultsFile.m ├── steps2time.m ├── tightfig.m └── time2steps.m ├── results_mat ├── PERFECT_TEAM.mat ├── test_team.mat └── test_team_multiple.mat └── results_reports ├── PERFECT_TEAM_report.txt ├── test_team_multiple_report.txt └── test_team_report.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | L-TOWN_v2_Real.inp filter=lfs diff=lfs merge=lfs -text 2 | .inp filter=lfs diff=lfs merge=lfs -text 3 | *.inp filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /Dataset Generator/.gitattributes: -------------------------------------------------------------------------------- 1 | L-TOWN_v2_Real.inp filter=lfs diff=lfs merge=lfs -text 2 | dataset_generator.exe filter=lfs diff=lfs merge=lfs -text 3 | -------------------------------------------------------------------------------- /Dataset Generator/L-TOWN_v2_Model.inp: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1b9ba161e3aebe02a916876d60c2126ee76f75e9f0d23c9ec4dfffd59cc0c366 3 | size 409786 4 | -------------------------------------------------------------------------------- /Dataset Generator/L-TOWN_v2_Real.inp: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0570538d93246d452e740316ffec66dabc17526b18c47384a083e76061551023 3 | size 177151858 4 | -------------------------------------------------------------------------------- /Dataset Generator/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Dataset Generator/README.txt -------------------------------------------------------------------------------- /Dataset Generator/dataset_configuration.yalm: -------------------------------------------------------------------------------- 1 | Comments: 2 | - Configuration file for HISTORICAL and EVALUATION DATASET 3 | 4 | Network: 5 | filename: L-TOWN_v2_Real.inp 6 | 7 | times: 8 | StartTime: 2018-01-01 00:00 9 | EndTime: 2019-12-31 23:55 10 | 11 | leakages: 12 | - # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 13 | - p257, 2018-01-08 13:30, 2019-12-31 23:55, 0.011843, incipient, 2018-01-25 08:30 14 | - p461, 2018-01-23 04:25, 2018-04-02 11:40, 0.021320, incipient, 2018-03-27 20:35 15 | - p232, 2018-01-31 02:35, 2018-02-10 09:20, 0.020108, incipient, 2018-02-03 16:05 16 | - p427, 2018-02-13 08:25, 2019-12-31 23:55, 0.0090731, incipient, 2018-05-14 19:25 17 | - p673, 2018-03-05 15:45, 2018-03-23 10:25, 0.022916, abrupt, 2018-03-05 15:45 18 | - p810, 2018-07-28 03:05, 2019-12-31 23:55, 0.010028, incipient, 2018-11-02 22:25 19 | - p628, 2018-05-02 14:55, 2018-05-29 21:20, 0.022318, incipient, 2018-05-16 08:00 20 | - p538, 2018-05-18 08:35, 2018-06-02 06:05, 0.021731, abrupt, 2018-05-18 08:35 21 | - p866, 2018-06-01 09:05, 2018-06-12 03:00, 0.018108, abrupt, 2018-06-01 09:05 22 | - p31, 2018-06-28 10:35, 2018-08-12 17:30, 0.016389, incipient, 2018-08-03 02:45 23 | - p654, 2018-07-05 03:40, 2019-12-31 23:55, 0.0087735, incipient, 2018-09-16 21:05 24 | - p183, 2018-08-07 02:35, 2018-09-01 17:10, 0.015853, abrupt, 2018-08-07 02:35 25 | - p158, 2018-10-06 02:35, 2018-10-23 13:35, 0.019364, abrupt, 2018-10-06 02:35 26 | - p369, 2018-10-26 02:05, 2018-11-08 20:25, 0.019363, abrupt, 2018-10-26 02:05 27 | - p523, 2019-01-15 23:00, 2019-02-01 09:50, 0.020246, abrupt, 2019-01-15 23:00 28 | - p827, 2019-01-24 18:30, 2019-02-07 09:05, 0.02025, abrupt, 2019-01-24 18:30 29 | - p280, 2019-02-10 13:05, 2019-12-31 23:55, 0.0095008, abrupt, 2019-02-10 13:05 30 | - p653, 2019-03-03 13:10, 2019-05-05 12:10, 0.016035, incipient, 2019-04-21 19:00 31 | - p710, 2019-03-24 14:15, 2019-12-31 23:55, 0.0092936, abrupt, 2019-03-24 14:15 32 | - p514, 2019-04-02 20:40, 2019-05-23 14:55, 0.014979, abrupt, 2019-04-02 20:40 33 | - p331, 2019-04-20 10:10, 2019-12-31 23:55, 0.014053, abrupt, 2019-04-20 10:10 34 | - p193, 2019-05-19 10:40, 2019-12-31 23:55, 0.01239, incipient, 2019-07-25 03:20 35 | - p277, 2019-05-30 21:55, 2019-12-31 23:55, 0.012089, incipient, 2019-08-11 15:05 36 | - p142, 2019-06-12 19:55, 2019-07-17 09:25, 0.019857, abrupt, 2019-06-12 19:55 37 | - p680, 2019-07-10 08:45, 2019-12-31 23:55, 0.0097197, abrupt, 2019-07-10 08:45 38 | - p586, 2019-07-26 14:40, 2019-09-16 03:20, 0.017184, incipient, 2019-08-28 07:55 39 | - p721, 2019-08-02 03:00, 2019-12-31 23:55, 0.01408, incipient, 2019-09-23 05:40 40 | - p800, 2019-08-16 14:00, 2019-10-01 16:35, 0.018847, incipient, 2019-09-07 21:05 41 | - p123, 2019-09-13 20:05, 2019-12-31 23:55, 0.011906, incipient, 2019-11-29 22:10 42 | - p455, 2019-10-03 14:00, 2019-12-31 23:55, 0.012722, incipient, 2019-12-16 05:25 43 | - p762, 2019-10-09 10:15, 2019-12-31 23:55, 0.01519, incipient, 2019-12-03 01:15 44 | - p426, 2019-10-25 13:25, 2019-12-31 23:55, 0.015008, abrupt, 2019-10-25 13:25 45 | - p879, 2019-11-20 11:55, 2019-12-31 23:55, 0.013195, incipient, 2019-12-31 23:55 46 | 47 | 48 | pressure_sensors: 49 | - n1 50 | - n4 51 | - n31 52 | - n54 53 | - n105 54 | - n114 55 | - n163 56 | - n188 57 | - n215 58 | - n229 59 | - n288 60 | - n296 61 | - n332 62 | - n342 63 | - n410 64 | - n415 65 | - n429 66 | - n458 67 | - n469 68 | - n495 69 | - n506 70 | - n516 71 | - n519 72 | - n549 73 | - n613 74 | - n636 75 | - n644 76 | - n679 77 | - n722 78 | - n726 79 | - n740 80 | - n752 81 | - n769 82 | 83 | flow_sensors: 84 | - PUMP_1 85 | - p227 86 | - p235 87 | 88 | level_sensors: 89 | - T1 90 | 91 | amrs: 92 | - n1 93 | - n2 94 | - n3 95 | - n4 96 | - n6 97 | - n7 98 | - n8 99 | - n9 100 | - n10 101 | - n11 102 | - n13 103 | - n16 104 | - n17 105 | - n18 106 | - n19 107 | - n20 108 | - n21 109 | - n22 110 | - n23 111 | - n24 112 | - n25 113 | - n26 114 | - n27 115 | - n28 116 | - n29 117 | - n30 118 | - n31 119 | - n32 120 | - n33 121 | - n34 122 | - n35 123 | - n36 124 | - n39 125 | - n40 126 | - n41 127 | - n42 128 | - n43 129 | - n44 130 | - n45 131 | - n343 132 | - n344 133 | - n345 134 | - n346 135 | - n347 136 | - n349 137 | - n350 138 | - n351 139 | - n352 140 | - n353 141 | - n354 142 | - n355 143 | - n356 144 | - n357 145 | - n358 146 | - n360 147 | - n361 148 | - n362 149 | - n364 150 | - n365 151 | - n366 152 | - n367 153 | - n368 154 | - n369 155 | - n370 156 | - n371 157 | - n372 158 | - n373 159 | - n374 160 | - n375 161 | - n376 162 | - n377 163 | - n378 164 | - n379 165 | - n381 166 | - n382 167 | - n383 168 | - n384 169 | - n385 170 | - n386 171 | - n387 172 | - n388 173 | - n389 -------------------------------------------------------------------------------- /Dataset Generator/dataset_configuration_evaluation.yalm: -------------------------------------------------------------------------------- 1 | Comments: 2 | - Configuration file for EVALUATION DATASET 3 | 4 | Network: 5 | filename: L-TOWN_v2_Real.inp 6 | 7 | times: 8 | StartTime: 2019-01-01 00:00 9 | EndTime: 2019-12-31 23:55 10 | 11 | leakages: 12 | - # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 13 | - p257, 2019-01-01 00:00, 2019-12-31 23:55, 0.011843, incipient, 2019-01-01 00:00 14 | - p427, 2019-01-01 00:00, 2019-12-31 23:55, 0.0090731, incipient, 2019-01-01 00:00 15 | - p810, 2019-01-01 00:00, 2019-12-31 23:55, 0.010028, incipient, 2019-01-01 00:00 16 | - p654, 2019-01-01 00:00, 2019-12-31 23:55, 0.0087735, incipient, 2019-01-01 00:00 17 | - p523, 2019-01-15 23:00, 2019-02-01 09:50, 0.020246, abrupt, 2019-01-15 23:00 18 | - p827, 2019-01-24 18:30, 2019-02-07 09:05, 0.02025, abrupt, 2019-01-24 18:30 19 | - p280, 2019-02-10 13:05, 2019-12-31 23:55, 0.0095008, abrupt, 2019-02-10 13:05 20 | - p653, 2019-03-03 13:10, 2019-05-05 12:10, 0.016035, incipient, 2019-04-21 19:00 21 | - p710, 2019-03-24 14:15, 2019-12-31 23:55, 0.0092936, abrupt, 2019-03-24 14:15 22 | - p514, 2019-04-02 20:40, 2019-05-23 14:55, 0.014979, abrupt, 2019-04-02 20:40 23 | - p331, 2019-04-20 10:10, 2019-12-31 23:55, 0.014053, abrupt, 2019-04-20 10:10 24 | - p193, 2019-05-19 10:40, 2019-12-31 23:55, 0.01239, incipient, 2019-07-25 03:20 25 | - p277, 2019-05-30 21:55, 2019-12-31 23:55, 0.012089, incipient, 2019-08-11 15:05 26 | - p142, 2019-06-12 19:55, 2019-07-17 09:25, 0.019857, abrupt, 2019-06-12 19:55 27 | - p680, 2019-07-10 08:45, 2019-12-31 23:55, 0.0097197, abrupt, 2019-07-10 08:45 28 | - p586, 2019-07-26 14:40, 2019-09-16 03:20, 0.017184, incipient, 2019-08-28 07:55 29 | - p721, 2019-08-02 03:00, 2019-12-31 23:55, 0.01408, incipient, 2019-09-23 05:40 30 | - p800, 2019-08-16 14:00, 2019-10-01 16:35, 0.018847, incipient, 2019-09-07 21:05 31 | - p123, 2019-09-13 20:05, 2019-12-31 23:55, 0.011906, incipient, 2019-11-29 22:10 32 | - p455, 2019-10-03 14:00, 2019-12-31 23:55, 0.012722, incipient, 2019-12-16 05:25 33 | - p762, 2019-10-09 10:15, 2019-12-31 23:55, 0.01519, incipient, 2019-12-03 01:15 34 | - p426, 2019-10-25 13:25, 2019-12-31 23:55, 0.015008, abrupt, 2019-10-25 13:25 35 | - p879, 2019-11-20 11:55, 2019-12-31 23:55, 0.013195, incipient, 2019-12-31 23:55 36 | 37 | 38 | pressure_sensors: 39 | - n1 40 | - n4 41 | - n31 42 | - n54 43 | - n105 44 | - n114 45 | - n163 46 | - n188 47 | - n215 48 | - n229 49 | - n288 50 | - n296 51 | - n332 52 | - n342 53 | - n410 54 | - n415 55 | - n429 56 | - n458 57 | - n469 58 | - n495 59 | - n506 60 | - n516 61 | - n519 62 | - n549 63 | - n613 64 | - n636 65 | - n644 66 | - n679 67 | - n722 68 | - n726 69 | - n740 70 | - n752 71 | - n769 72 | 73 | flow_sensors: 74 | - PUMP_1 75 | - p227 76 | - p235 77 | 78 | level_sensors: 79 | - T1 80 | 81 | amrs: 82 | - n1 83 | - n2 84 | - n3 85 | - n4 86 | - n6 87 | - n7 88 | - n8 89 | - n9 90 | - n10 91 | - n11 92 | - n13 93 | - n16 94 | - n17 95 | - n18 96 | - n19 97 | - n20 98 | - n21 99 | - n22 100 | - n23 101 | - n24 102 | - n25 103 | - n26 104 | - n27 105 | - n28 106 | - n29 107 | - n30 108 | - n31 109 | - n32 110 | - n33 111 | - n34 112 | - n35 113 | - n36 114 | - n39 115 | - n40 116 | - n41 117 | - n42 118 | - n43 119 | - n44 120 | - n45 121 | - n343 122 | - n344 123 | - n345 124 | - n346 125 | - n347 126 | - n349 127 | - n350 128 | - n351 129 | - n352 130 | - n353 131 | - n354 132 | - n355 133 | - n356 134 | - n357 135 | - n358 136 | - n360 137 | - n361 138 | - n362 139 | - n364 140 | - n365 141 | - n366 142 | - n367 143 | - n368 144 | - n369 145 | - n370 146 | - n371 147 | - n372 148 | - n373 149 | - n374 150 | - n375 151 | - n376 152 | - n377 153 | - n378 154 | - n379 155 | - n381 156 | - n382 157 | - n383 158 | - n384 159 | - n385 160 | - n386 161 | - n387 162 | - n388 163 | - n389 -------------------------------------------------------------------------------- /Dataset Generator/dataset_configuration_historical.yalm: -------------------------------------------------------------------------------- 1 | Comments: 2 | - Configuration file for HISTORICAL DATASET 3 | 4 | Network: 5 | filename: L-TOWN_v2_Real.inp 6 | 7 | times: 8 | StartTime: 2018-01-01 00:00 9 | EndTime: 2018-12-31 23:55 10 | 11 | leakages: 12 | - # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 13 | - p257, 2018-01-08 13:30, 2018-12-31 23:55, 0.011843, incipient, 2018-01-25 08:30 14 | - p461, 2018-01-23 04:25, 2018-04-02 11:40, 0.021320, incipient, 2018-03-27 20:35 15 | - p232, 2018-01-31 02:35, 2018-02-10 09:20, 0.020108, incipient, 2018-02-03 16:05 16 | - p427, 2018-02-13 08:25, 2018-12-31 23:55, 0.0090731, incipient, 2018-05-14 19:25 17 | - p673, 2018-03-05 15:45, 2018-03-23 10:25, 0.022916, abrupt, 2018-03-05 15:45 18 | - p810, 2018-07-28 03:05, 2018-12-31 23:55, 0.010028, incipient, 2018-11-02 22:25 19 | - p628, 2018-05-02 14:55, 2018-05-29 21:20, 0.022318, incipient, 2018-05-16 08:00 20 | - p538, 2018-05-18 08:35, 2018-06-02 06:05, 0.021731, abrupt, 2018-05-18 08:35 21 | - p866, 2018-06-01 09:05, 2018-06-12 03:00, 0.018108, abrupt, 2018-06-01 09:05 22 | - p31, 2018-06-28 10:35, 2018-08-12 17:30, 0.016389, incipient, 2018-08-03 02:45 23 | - p654, 2018-07-05 03:40, 2018-12-31 23:55, 0.0087735, incipient, 2018-09-16 21:05 24 | - p183, 2018-08-07 02:35, 2018-09-01 17:10, 0.015853, abrupt, 2018-08-07 02:35 25 | - p158, 2018-10-06 02:35, 2018-10-23 13:35, 0.019364, abrupt, 2018-10-06 02:35 26 | - p369, 2018-10-26 02:05, 2018-11-08 20:25, 0.019363, abrupt, 2018-10-26 02:05 27 | 28 | pressure_sensors: 29 | - n1 30 | - n4 31 | - n31 32 | - n54 33 | - n105 34 | - n114 35 | - n163 36 | - n188 37 | - n215 38 | - n229 39 | - n288 40 | - n296 41 | - n332 42 | - n342 43 | - n410 44 | - n415 45 | - n429 46 | - n458 47 | - n469 48 | - n495 49 | - n506 50 | - n516 51 | - n519 52 | - n549 53 | - n613 54 | - n636 55 | - n644 56 | - n679 57 | - n722 58 | - n726 59 | - n740 60 | - n752 61 | - n769 62 | 63 | flow_sensors: 64 | - PUMP_1 65 | - p227 66 | - p235 67 | 68 | level_sensors: 69 | - T1 70 | 71 | amrs: 72 | - n1 73 | - n2 74 | - n3 75 | - n4 76 | - n6 77 | - n7 78 | - n8 79 | - n9 80 | - n10 81 | - n11 82 | - n13 83 | - n16 84 | - n17 85 | - n18 86 | - n19 87 | - n20 88 | - n21 89 | - n22 90 | - n23 91 | - n24 92 | - n25 93 | - n26 94 | - n27 95 | - n28 96 | - n29 97 | - n30 98 | - n31 99 | - n32 100 | - n33 101 | - n34 102 | - n35 103 | - n36 104 | - n39 105 | - n40 106 | - n41 107 | - n42 108 | - n43 109 | - n44 110 | - n45 111 | - n343 112 | - n344 113 | - n345 114 | - n346 115 | - n347 116 | - n349 117 | - n350 118 | - n351 119 | - n352 120 | - n353 121 | - n354 122 | - n355 123 | - n356 124 | - n357 125 | - n358 126 | - n360 127 | - n361 128 | - n362 129 | - n364 130 | - n365 131 | - n366 132 | - n367 133 | - n368 134 | - n369 135 | - n370 136 | - n371 137 | - n372 138 | - n373 139 | - n374 140 | - n375 141 | - n376 142 | - n377 143 | - n378 144 | - n379 145 | - n381 146 | - n382 147 | - n383 148 | - n384 149 | - n385 150 | - n386 151 | - n387 152 | - n388 153 | - n389 -------------------------------------------------------------------------------- /Dataset Generator/dataset_generator.exe: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7a34d7fa7a1d385c0e247b1d6cc90b9957cc6568596669978b01487312a1e1ea 3 | size 103312071 4 | -------------------------------------------------------------------------------- /Dataset Generator/dataset_generator.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Dataset Generator 4 | Copyright: (C) 2019, KIOS Research Center of Excellence 5 | """ 6 | import pandas as pd 7 | import numpy as np 8 | import wntr 9 | import pickle 10 | import os 11 | import sys 12 | import yaml 13 | import shutil 14 | import time 15 | from math import sqrt 16 | 17 | # Read input arguments from yalm file 18 | try: 19 | with open(f'{os.getcwd()}\\dataset_configuration.yalm', 'r') as f: 20 | leak_pipes = yaml.load(f.read()) 21 | except: 22 | print('"dataset_configuration" file not found.') 23 | sys.exit() 24 | 25 | start_time = leak_pipes['times']['StartTime'] 26 | end_time = leak_pipes['times']['EndTime'] 27 | leakages = leak_pipes['leakages'] 28 | leakages = leakages[1:] 29 | number_of_leaks = len(leakages) 30 | inp_file = leak_pipes['Network']['filename'] 31 | print(f'Run input file: "{inp_file}"') 32 | results_folder = f'{os.getcwd()}\\Results\\' 33 | pressure_sensors = leak_pipes['pressure_sensors'] 34 | 35 | def get_sensors(leak_pipes, field): 36 | sensors = [] 37 | [sensors.append(str(sens)) for sens in leak_pipes[field]] 38 | return sensors 39 | 40 | flow_sensors = get_sensors(leak_pipes, 'flow_sensors') 41 | pressure_sensors = get_sensors(leak_pipes, 'pressure_sensors') 42 | amrs = get_sensors(leak_pipes, 'amrs') 43 | flow_sensors = get_sensors(leak_pipes, 'flow_sensors') 44 | level_sensors = get_sensors(leak_pipes, 'level_sensors') 45 | 46 | # demand-driven (DD) or pressure dependent demand (PDD) 47 | Mode_Simulation = 'PDD' # 'PDD'#'PDD' 48 | 49 | 50 | class LeakDatasetCreator: 51 | def __init__(self): 52 | 53 | # Create Results folder 54 | self.create_folder(results_folder) 55 | 56 | self.scenario_num = 1 57 | self.unc_range = np.arange(0, 0.25, 0.05) 58 | 59 | # Load EPANET network file 60 | self.wn = wntr.network.WaterNetworkModel(inp_file) 61 | 62 | for name, node in self.wn.junctions(): 63 | node.nominal_pressure = 25 64 | #print(node.nominal_pressure) 65 | #print(node.minimum_pressure) 66 | 67 | self.inp = os.path.basename(self.wn.name)[0:-4] 68 | 69 | # Get the name of input file 70 | self.net_name = f'{results_folder}{self.inp}' 71 | 72 | # Get time step 73 | self.time_step = round(self.wn.options.time.hydraulic_timestep) 74 | # Create time_stamp 75 | self.time_stamp = pd.date_range(start_time, end_time, freq=str(self.time_step / 60) + "min") 76 | 77 | # Simulation duration in steps 78 | self.wn.options.time.duration = (len(self.time_stamp) - 1) * 300 # 5min step 79 | self.TIMESTEPS = int(self.wn.options.time.duration / self.wn.options.time.hydraulic_timestep) 80 | 81 | def create_csv_file(self, values, time_stamp, columnname, pathname): 82 | 83 | file = pd.DataFrame(values) 84 | file['time_stamp'] = time_stamp 85 | file = file.set_index(['time_stamp']) 86 | file.columns.values[0] = columnname 87 | file.to_csv(pathname) 88 | del file, time_stamp, values 89 | 90 | def create_folder(self, _path_): 91 | 92 | try: 93 | if os.path.exists(_path_): 94 | shutil.rmtree(_path_) 95 | os.makedirs(_path_) 96 | except Exception as error: 97 | pass 98 | 99 | def dataset_generator(self): 100 | # Path of EPANET Input File 101 | print(f"Dataset Generator run...") 102 | 103 | # Initialize parameters for the leak 104 | leak_node = {} 105 | leak_diameter = {} 106 | leak_area = {} 107 | leak_type = {} 108 | leak_starts = {} 109 | leak_ends = {} 110 | leak_peak_time = {} 111 | leak_param = {} 112 | 113 | for leak_i in range(0, number_of_leaks): 114 | # Split pipe and add a leak node 115 | # leakages: pipeID, startTime, endTime, leakDiameter, leakType (abrupt, incipient) 116 | leakage_line = leakages[leak_i].split(',') 117 | 118 | # Start time of leak 119 | ST = self.time_stamp.get_loc(leakage_line[1]) 120 | 121 | # End Time of leak 122 | ET = self.time_stamp.get_loc(leakage_line[2]) 123 | 124 | # Get leak type 125 | leak_type[leak_i] = leakage_line[4] 126 | 127 | # Split pipe to add a leak 128 | pipe_id = self.wn.get_link(leakage_line[0]) 129 | node_leak = f'{pipe_id}_leaknode' 130 | self.wn = wntr.morph.split_pipe(self.wn, pipe_id, f'{pipe_id}_Bleak', node_leak) 131 | leak_node[leak_i] = self.wn.get_node(self.wn.node_name_list[self.wn.node_name_list.index(node_leak)]) 132 | 133 | if 'incipient' in leak_type[leak_i]: 134 | # END TIME 135 | ET = ET + 1 136 | PT = self.time_stamp.get_loc(leakage_line[5])+1 137 | 138 | # Leak diameter as max magnitude for incipient 139 | nominal_pres = 100 140 | leak_diameter[leak_i] = float(leakage_line[3]) 141 | leak_area[leak_i] = 3.14159 * (leak_diameter[leak_i] / 2) ** 2 142 | 143 | # incipient 144 | leak_param[leak_i] = 'demand' 145 | increment_leak_diameter = leak_diameter[leak_i] / (PT - ST) 146 | increment_leak_diameter = np.arange(increment_leak_diameter, leak_diameter[leak_i], increment_leak_diameter) 147 | increment_leak_area = 0.75 * sqrt(2 / 1000) * 990.27 * 3.14159 * (increment_leak_diameter/2)**2 148 | leak_magnitude = 0.75 * sqrt(2 / 1000) * 990.27 * leak_area[leak_i] 149 | pattern_array = [0] * (ST) + increment_leak_area.tolist() + [leak_magnitude] * (ET - PT + 1) + [0] * (self.TIMESTEPS - ET) 150 | 151 | # basedemand 152 | leak_node[leak_i].demand_timeseries_list[0]._base = 1 153 | pattern_name = f'{str(leak_node[leak_i])}' 154 | self.wn.add_pattern(pattern_name, pattern_array) 155 | leak_node[leak_i].demand_timeseries_list[0].pattern_name = pattern_name 156 | leak_node[leak_i].nominal_pressure = nominal_pres 157 | leak_node[leak_i].minimum_pressure = 0 158 | 159 | # save times of leak 160 | leak_starts[leak_i] = self.time_stamp[ST] 161 | leak_starts[leak_i] = leak_starts[leak_i]._date_repr + ' ' + leak_starts[leak_i]._time_repr 162 | leak_ends[leak_i] = self.time_stamp[ET - 1] 163 | leak_ends[leak_i] = leak_ends[leak_i]._date_repr + ' ' + leak_ends[leak_i]._time_repr 164 | leak_peak_time[leak_i] = self.time_stamp[PT - 1]._date_repr + ' ' + self.time_stamp[PT - 1]._time_repr 165 | 166 | else: 167 | leak_param[leak_i] = 'leak_demand' 168 | PT = ST 169 | leak_diameter[leak_i] = float(leakage_line[3]) 170 | leak_area[leak_i] = 3.14159 * (leak_diameter[leak_i] / 2) ** 2 171 | 172 | leak_node[leak_i]._leak_end_control_name = str(leak_i) + 'end' 173 | leak_node[leak_i]._leak_start_control_name = str(leak_i) + 'start' 174 | 175 | leak_node[leak_i].add_leak(self.wn, discharge_coeff=0.75, 176 | area=leak_area[leak_i], 177 | start_time=ST * self.time_step, 178 | end_time=(ET+1) * self.time_step) 179 | 180 | leak_starts[leak_i] = self.time_stamp[ST] 181 | leak_starts[leak_i] = leak_starts[leak_i]._date_repr + ' ' + leak_starts[leak_i]._time_repr 182 | leak_ends[leak_i] = self.time_stamp[ET] 183 | leak_ends[leak_i] = leak_ends[leak_i]._date_repr + ' ' + leak_ends[leak_i]._time_repr 184 | leak_peak_time[leak_i] = self.time_stamp[PT]._date_repr + ' ' + self.time_stamp[PT]._time_repr 185 | 186 | # Save/Write input file with new settings 187 | leakages_folder = f'{results_folder}Leakages' 188 | self.create_folder(leakages_folder) 189 | #self.wn.write_inpfile(f'{leakages_folder}\\{self.inp}_with_leaknodes.inp') 190 | 191 | # Save the water network model to a file before using it in a simulation 192 | with open('self.wn.pickle', 'wb') as f: 193 | pickle.dump(self.wn, f) 194 | 195 | # Run wntr simulator 196 | sim = wntr.sim.WNTRSimulator(self.wn, mode=Mode_Simulation) 197 | results = sim.run_sim() 198 | if results.node["pressure"].empty: 199 | print("Negative pressures.") 200 | return -1 201 | 202 | if results: 203 | # Create CSV files 204 | for leak_i in range(0, number_of_leaks): 205 | if 'leaknode' in str(leak_node[leak_i]): 206 | NODEID = str(leak_node[leak_i]).split('_')[0] 207 | totals_info = {'Description': ['Leak Pipe', 'Leak Area', 'Leak Diameter', 'Leak Type', 'Leak Start', 208 | 'Leak End', 'Peak Time'], 209 | 'Value': [NODEID, str(leak_area[leak_i]), str(leak_diameter[leak_i]), 210 | leak_type[leak_i], 211 | str(leak_starts[leak_i]), str(leak_ends[leak_i]), str(leak_peak_time[leak_i])]} 212 | 213 | # Create leak XLS files 214 | decimal_size = 2 215 | 216 | leaks = results.node[leak_param[leak_i]][str(leak_node[leak_i])].values 217 | # Convert m^3/s (wntr default units) to m^3/h 218 | # https://wntr.readthedocs.io/en/latest/units.html#epanet-unit-conventions 219 | leaks = [elem * 3600 for elem in leaks] 220 | leaks = [round(elem, decimal_size) for elem in leaks] 221 | leaks = leaks[:len(self.time_stamp)] 222 | 223 | total_Leaks = {'Timestamp': self.time_stamp} 224 | total_Leaks[NODEID] = leaks 225 | #self.create_csv_file(leaks, self.time_stamp, 'Description', f'{leakages_folder}\\Leak_{str(leak_node[leak_i])}_demand.csv') 226 | df1 = pd.DataFrame(totals_info) 227 | df2 = pd.DataFrame(total_Leaks) 228 | writer = pd.ExcelWriter(f'{leakages_folder}\\Leak_{NODEID}.xlsx', engine='xlsxwriter') 229 | df1.to_excel(writer, sheet_name='Info', index=False) 230 | df2.to_excel(writer, sheet_name='Demand (m3_h)', index=False) 231 | writer.save() 232 | 233 | 234 | # Create xlsx file with Measurements 235 | total_pressures = {'Timestamp': self.time_stamp} 236 | total_demands = {'Timestamp': self.time_stamp} 237 | total_flows = {'Timestamp': self.time_stamp} 238 | total_levels = {'Timestamp': self.time_stamp} 239 | for j in range(0, self.wn.num_nodes): 240 | node_id = self.wn.node_name_list[j] 241 | if node_id in pressure_sensors: 242 | pres = results.node['pressure'][node_id] 243 | pres = pres[:len(self.time_stamp)] 244 | pres = [round(elem, decimal_size) for elem in pres] 245 | total_pressures[node_id] = pres 246 | 247 | if node_id in amrs: 248 | dem = results.node['demand'][node_id] 249 | dem = dem[:len(self.time_stamp)] 250 | dem = [elem * 3600 * 1000 for elem in dem] #CMH / L/s 251 | dem = [round(elem, decimal_size) for elem in dem] #CMH / L/s 252 | total_demands[node_id] = dem 253 | 254 | if node_id in level_sensors: 255 | level_pres = results.node['pressure'][node_id] 256 | level_pres = level_pres[:len(self.time_stamp)] 257 | level_pres = [round(elem, decimal_size) for elem in level_pres] 258 | total_levels[node_id] = level_pres 259 | 260 | for j in range(0, self.wn.num_links): 261 | link_id = self.wn.link_name_list[j] 262 | 263 | if link_id not in flow_sensors: 264 | continue 265 | flows = results.link['flowrate'][link_id] 266 | flows = [elem * 3600 for elem in flows] 267 | flows = [round(elem, decimal_size) for elem in flows] 268 | flows = flows[:len(self.time_stamp)] 269 | total_flows[link_id] = flows 270 | 271 | # Create a Pandas dataframe from the data. 272 | df1 = pd.DataFrame(total_pressures) 273 | df2 = pd.DataFrame(total_demands) 274 | df3 = pd.DataFrame(total_flows) 275 | df4 = pd.DataFrame(total_levels) 276 | # Create a Pandas Excel writer using XlsxWriter as the engine. 277 | writer = pd.ExcelWriter(f'{results_folder}Measurements.xlsx', engine='xlsxwriter') 278 | 279 | # Convert the dataframe to an XlsxWriter Excel object. 280 | # Pressures (m), Demands (m^3/h), Flows (m^3/h), Levels (m) 281 | df1.to_excel(writer, sheet_name='Pressures (m)', index=False) 282 | df2.to_excel(writer, sheet_name='Demands (L_h)', index=False) 283 | df3.to_excel(writer, sheet_name='Flows (m3_h)', index=False) 284 | df4.to_excel(writer, sheet_name='Levels (m)', index=False) 285 | 286 | # Close the Pandas Excel writer and output the Excel file. 287 | writer.save() 288 | 289 | os.remove('self.wn.pickle') 290 | else: 291 | print('Results empty.') 292 | return -1 293 | 294 | 295 | if __name__ == '__main__': 296 | 297 | # Create tic / toc 298 | t = time.time() 299 | 300 | # Call leak dataset creator 301 | L = LeakDatasetCreator() 302 | # Create scenario one-by-one 303 | L.dataset_generator() 304 | 305 | print(f'Total Elapsed time is {str(time.time() - t)} seconds.') 306 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | EUROPEAN UNION PUBLIC LICENCE v. 1.2 2 | EUPL © the European Union 2007, 2016 3 | 4 | This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the 5 | terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such 6 | use is covered by a right of the copyright holder of the Work). 7 | The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following 8 | notice immediately following the copyright notice for the Work: 9 | Licensed under the EUPL 10 | or has expressed by any other means his willingness to license under the EUPL. 11 | 12 | 1.Definitions 13 | In this Licence, the following terms have the following meaning: 14 | — ‘The Licence’:this Licence. 15 | — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available 16 | as Source Code and also as Executable Code as the case may be. 17 | — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or 18 | modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work 19 | required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in 20 | the country mentioned in Article 15. 21 | — ‘The Work’:the Original Work or its Derivative Works. 22 | — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and 23 | modify. 24 | — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by 25 | a computer as a program. 26 | — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. 27 | — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to 28 | the creation of a Derivative Work. 29 | — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the 30 | Licence. 31 | — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, 32 | transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential 33 | functionalities at the disposal of any other natural or legal person. 34 | 35 | 2.Scope of the rights granted by the Licence 36 | The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for 37 | the duration of copyright vested in the Original Work: 38 | — use the Work in any circumstance and for all usage, 39 | — reproduce the Work, 40 | — modify the Work, and make Derivative Works based upon the Work, 41 | — communicate to the public, including the right to make available or display the Work or copies thereof to the public 42 | and perform publicly, as the case may be, the Work, 43 | — distribute the Work or copies thereof, 44 | — lend and rent the Work or copies thereof, 45 | — sublicense rights in the Work or copies thereof. 46 | Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the 47 | applicable law permits so. 48 | In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed 49 | by law in order to make effective the licence of the economic rights here above listed. 50 | The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the 51 | extent necessary to make use of the rights granted on the Work under this Licence. 52 | 53 | 3.Communication of the Source Code 54 | The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as 55 | Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with 56 | each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to 57 | the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to 58 | distribute or communicate the Work. 59 | 60 | 4.Limitations on copyright 61 | Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the 62 | exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations 63 | thereto. 64 | 65 | 5.Obligations of the Licensee 66 | The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those 67 | obligations are the following: 68 | 69 | Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to 70 | the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the 71 | Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work 72 | to carry prominent notices stating that the Work has been modified and the date of modification. 73 | 74 | Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this 75 | Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless 76 | the Original Work is expressly distributed only under this version of the Licence — for example by communicating 77 | ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the 78 | Work or Derivative Work that alter or restrict the terms of the Licence. 79 | 80 | Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both 81 | the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done 82 | under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed 83 | in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with 84 | his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. 85 | 86 | Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide 87 | a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available 88 | for as long as the Licensee continues to distribute or communicate the Work. 89 | Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names 90 | of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and 91 | reproducing the content of the copyright notice. 92 | 93 | 6.Chain of Authorship 94 | The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or 95 | licensed to him/her and that he/she has the power and authority to grant the Licence. 96 | Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or 97 | licensed to him/her and that he/she has the power and authority to grant the Licence. 98 | Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions 99 | to the Work, under the terms of this Licence. 100 | 101 | 7.Disclaimer of Warranty 102 | The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work 103 | and may therefore contain defects or ‘bugs’ inherent to this type of development. 104 | For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind 105 | concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or 106 | errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this 107 | Licence. 108 | This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. 109 | 110 | 8.Disclaimer of Liability 111 | Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be 112 | liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the 113 | Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss 114 | of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, 115 | the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. 116 | 117 | 9.Additional agreements 118 | While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services 119 | consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole 120 | responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, 121 | defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by 122 | the fact You have accepted any warranty or additional liability. 123 | 124 | 10.Acceptance of the Licence 125 | The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window 126 | displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of 127 | applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms 128 | and conditions. 129 | Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You 130 | by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution 131 | or Communication by You of the Work or copies thereof. 132 | 133 | 11.Information to the public 134 | In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, 135 | by offering to download the Work from a remote location) the distribution channel or media (for example, a website) 136 | must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence 137 | and the way it may be accessible, concluded, stored and reproduced by the Licensee. 138 | 139 | 12.Termination of the Licence 140 | The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms 141 | of the Licence. 142 | Such a termination will not terminate the licences of any person who has received the Work from the Licensee under 143 | the Licence, provided such persons remain in full compliance with the Licence. 144 | 145 | 13.Miscellaneous 146 | Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the 147 | Work. 148 | If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or 149 | enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid 150 | and enforceable. 151 | The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of 152 | the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. 153 | New versions of the Licence will be published with a unique version number. 154 | All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take 155 | advantage of the linguistic version of their choice. 156 | 157 | 14.Jurisdiction 158 | Without prejudice to specific agreement between parties, 159 | — any litigation resulting from the interpretation of this License, arising between the European Union institutions, 160 | bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice 161 | of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, 162 | — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to 163 | the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. 164 | 165 | 15.Applicable Law 166 | Without prejudice to specific agreement between parties, 167 | — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, 168 | resides or has his registered office, 169 | — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside 170 | a European Union Member State. 171 | 172 | 173 | Appendix 174 | 175 | ‘Compatible Licences’ according to Article 5 EUPL are: 176 | — GNU General Public License (GPL) v. 2, v. 3 177 | — GNU Affero General Public License (AGPL) v. 3 178 | — Open Software License (OSL) v. 2.1, v. 3.0 179 | — Eclipse Public License (EPL) v. 1.0 180 | — CeCILL v. 2.0, v. 2.1 181 | — Mozilla Public Licence (MPL) v. 2 182 | — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 183 | — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software 184 | — European Union Public Licence (EUPL) v. 1.1, v. 1.2 185 | — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). 186 | 187 | The European Commission may update this Appendix to later versions of the above licences without producing 188 | a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the 189 | covered Source Code from exclusive appropriation. 190 | All other changes or additions to this Appendix require the production of a new EUPL version. 191 | 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BattLeDIM 2 | The Battle of the Leakage Detection and Isolation Methods (BattLeDIM) 2020, organized initially as part of the 2nd International CCWI/WDSA Joint Conference in Beijing, China (http://www.ccwi-wdsa2020.com/), aims at objectively comparing the performance of methods for the detection and localization of leakage events, relying on SCADA measurements of flow and pressure sensors installed within water distribution networks. Participants may use different types of tools and methods, including (but not limited to) engineering judgement, machine learning, statistical methods, signal processing, and model-based fault diagnosis approaches. 3 | 4 | # Cite as: 5 | S. G. Vrachimis, D. G. Eliades, R. Taormina, Z. Kapelan, A. Ostfeld, S. Liu, M. Kyriakou, P. Pavlou, M. Qiu, and M. M. Polycarpou. Forthcoming. “Battle of the Leakage Detection and Isolation Methods,” Journal of Water Resources Planning and Management, 10.1061/(ASCE)WR.1943-5452.0001601 6 | 7 | 8 | # Website 9 | http://battledim.ucy.ac.cy/ 10 | 11 | # Organizing committee/Contributors 12 | Stelios G. Vrachimis, KIOS Center of Excellence, University of Cyprus, Cyprus
13 | Demetrios G. Eliades, KIOS Center of Excellence, University of Cyprus, Cyprus
14 | Riccardo Taormina, Technical University Delft, the Netherlands
15 | Avi Ostfeld, Technion - Israel Institute of Technology, Israel
16 | Zoran Kapelan, Technical University Delft, the Netherlands
17 | Shuming Liu, Tsinghua University, China
18 | Marios Kyriakou, KIOS Center of Excellence, University of Cyprus, Cyprus
19 | Pavlos Pavlou, KIOS Center of Excellence, University of Cyprus, Cyprus
20 | Mengning Qiu, Technion - Israel Institute of Technology, Israel
21 | Marios M. Polycarpou, KIOS Center of Excellence, University of Cyprus, Cyprus 22 | 23 | # Requirements 24 | This work uses the EPANET-Matlab-Toolkit which is a Matlab class for EPANET libraries. 25 | Please install the toolkit before use. 26 | For more information see https://github.com/OpenWaterAnalytics/EPANET-Matlab-Toolkit#EPANET-MATLAB-Toolkit . 27 | 28 | # Instructions for scoring result files 29 | 1. Download and install required software: MATLAB, EPANET-MATLAB toolkit 30 | 2. Download code 31 | 3. Insert your resutls file in the correct format (see Results Template) in Scoring_Algorithm/SUBMITTED_files 32 | 4. Run Scoring_Algorithm.m 33 | 5. Follow Command Window instructions to get your score 34 | 35 | # Results template 36 | Please submit your results in the following format (including spaces): 37 | 38 | \# linkID, startTime\ 39 | p1, 2019-02-03 10:00
40 | p23, 2019-05-19 02:05
41 | p234, 2019-08-21 03:00
42 | 43 | # CodeOcean - Instructions 44 | 45 | In case you don't have access to the required software, e.g. MATLAB, try evaluating your results through the CodeOcean computational research platform: 46 | 47 | Note: Pending approval of code from CodeOcean. Please retry in a few days 48 | 49 | 1. https://codeocean.com/
50 | 2. Create a codeocean account - Sign up
51 | 3. Activate your codeocean account
52 | 4. Go to https://codeocean.com/capsule/2366240
53 | 5. Create your results file in the correct format (Results template)
54 | 6. Select the folder `data` and then press the upload icon
55 | 7. Upload your results in a file named `results_data.txt`
56 | 8. You get the message: "The following files already exist and will be overwritten if you proceed". Press "Proceed". 57 | (In case the file is not in the folder 'data', drag and drop the `results_data.txt` file in folder `data`)
58 | 9. Press Re-Run in the upper right
59 | -------------------------------------------------------------------------------- /Scoring Algorithm/SUBMITTED_files/PERFECT_TEAM.txt: -------------------------------------------------------------------------------- 1 | # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 2 | p257, 2019-01-01 00:05 3 | p427, 2019-01-01 00:05 4 | p810, 2019-01-01 00:05 5 | p654, 2019-01-01 00:05 6 | p523, 2019-01-15 23:00 7 | p827, 2019-01-24 18:30 8 | p280, 2019-02-10 13:05 9 | p653, 2019-03-03 13:10 10 | p710, 2019-03-24 14:15 11 | p514, 2019-04-02 20:40 12 | p331, 2019-04-20 10:10 13 | p193, 2019-05-19 10:40 14 | p277, 2019-05-30 21:55 15 | p142, 2019-06-12 19:55 16 | p680, 2019-07-10 08:45 17 | p586, 2019-07-26 14:40 18 | p721, 2019-08-02 03:00 19 | p800, 2019-08-16 14:00 20 | p123, 2019-09-13 20:05 21 | p455, 2019-10-03 14:00 22 | p762, 2019-10-09 10:15 23 | p426, 2019-10-25 13:25 24 | p879, 2019-11-20 11:55 -------------------------------------------------------------------------------- /Scoring Algorithm/SUBMITTED_files/test_team.txt: -------------------------------------------------------------------------------- 1 | # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 2 | p257, 2019-01-01 00:05 3 | p257, 2019-01-01 00:10 4 | p427, 2019-01-01 00:05 5 | p810, 2019-01-01 00:05 6 | p654, 2019-01-01 00:05 7 | p523, 2019-01-15 23:00 8 | p827, 2019-01-24 18:30 9 | p280, 2019-02-10 13:05 10 | p653, 2019-03-03 13:10 11 | p710, 2019-03-24 14:15 12 | p514, 2019-04-02 20:40 13 | p331, 2019-04-20 10:10 14 | p193, 2019-05-19 10:40 15 | p277, 2019-05-30 21:55 16 | p142, 2019-06-12 19:55 17 | p680, 2019-07-10 08:45 18 | p586, 2019-07-26 14:40 19 | p721, 2019-08-02 03:00 20 | p800, 2019-08-16 14:00 21 | p123, 2019-09-13 20:05 22 | p455, 2019-10-03 14:00 23 | p762, 2019-10-09 10:15 24 | p426, 2019-10-25 13:25 25 | p879, 2019-11-20 11:55 -------------------------------------------------------------------------------- /Scoring Algorithm/SUBMITTED_files/test_team_multiple.txt: -------------------------------------------------------------------------------- 1 | # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 2 | p632, 2019-03-04 13:10 3 | p632, 2019-03-05 13:10 4 | p632, 2019-03-05 13:10 5 | p632, 2019-05-05 12:05 6 | p632, 2019-05-05 12:15 -------------------------------------------------------------------------------- /Scoring Algorithm/Scoring_Algorithm.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/Scoring_Algorithm.m -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/D_Mat_L-TOWN.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_data/D_Mat_L-TOWN.mat -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/L-TOWN.inp: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6cc586edcb18d7aa094f653bf2e45608950559e7c1f151c96c80a67f635283e2 3 | size 412164 4 | -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/leak_info.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_data/leak_info.mat -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/leakage_evolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_data/leakage_evolution.png -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/leakage_placement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_data/leakage_placement.png -------------------------------------------------------------------------------- /Scoring Algorithm/competition_data/leakages_info.yalm: -------------------------------------------------------------------------------- 1 | # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 2 | p257, 2018-01-08 13:30, 2019-12-31 23:55, 0.011843, incipient, 2018-01-25 08:30 3 | p427, 2018-02-13 08:25, 2019-12-31 23:55, 0.0090731, incipient, 2018-05-14 19:25 4 | p810, 2018-07-28 03:05, 2019-12-31 23:55, 0.010028, incipient, 2018-11-02 22:25 5 | p654, 2018-07-05 03:40, 2019-12-31 23:55, 0.0087735, incipient, 2018-09-16 21:05 6 | p523, 2019-01-15 23:00, 2019-02-01 09:50, 0.020246, abrupt, 2019-01-15 23:00 7 | p827, 2019-01-24 18:30, 2019-02-07 09:05, 0.02025, abrupt, 2019-01-24 18:30 8 | p280, 2019-02-10 13:05, 2019-12-31 23:55, 0.0095008, abrupt, 2019-02-10 13:05 9 | p653, 2019-03-03 13:10, 2019-05-05 12:10, 0.016035, incipient, 2019-04-21 19:00 10 | p710, 2019-03-24 14:15, 2019-12-31 23:55, 0.0092936, abrupt, 2019-03-24 14:15 11 | p514, 2019-04-02 20:40, 2019-05-23 14:55, 0.014979, abrupt, 2019-04-02 20:40 12 | p331, 2019-04-20 10:10, 2019-12-31 23:55, 0.014053, abrupt, 2019-04-20 10:10 13 | p193, 2019-05-19 10:40, 2019-12-31 23:55, 0.01239, incipient, 2019-07-25 03:20 14 | p277, 2019-05-30 21:55, 2019-12-31 23:55, 0.012089, incipient, 2019-08-11 15:05 15 | p142, 2019-06-12 19:55, 2019-07-17 09:25, 0.019857, abrupt, 2019-06-12 19:55 16 | p680, 2019-07-10 08:45, 2019-12-31 23:55, 0.0097197, abrupt, 2019-07-10 08:45 17 | p586, 2019-07-26 14:40, 2019-09-16 03:20, 0.017184, incipient, 2019-08-28 07:55 18 | p721, 2019-08-02 03:00, 2019-12-31 23:55, 0.01408, incipient, 2019-09-23 05:40 19 | p800, 2019-08-16 14:00, 2019-10-01 16:35, 0.018847, incipient, 2019-09-07 21:05 20 | p123, 2019-09-13 20:05, 2019-12-31 23:55, 0.011906, incipient, 2019-11-29 22:10 21 | p455, 2019-10-03 14:00, 2019-12-31 23:55, 0.012722, incipient, 2019-12-16 05:25 22 | p762, 2019-10-09 10:15, 2019-12-31 23:55, 0.01519, incipient, 2019-12-03 01:15 23 | p426, 2019-10-25 13:25, 2019-12-31 23:55, 0.015008, abrupt, 2019-10-25 13:25 24 | p879, 2019-11-20 11:55, 2019-12-31 23:55, 0.013195, incipient, 2019-12-31 23:55 -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p123.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p123.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p142.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p142.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p193.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p193.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p257.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p257.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p277.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p277.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p280.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p280.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p331.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p331.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p426.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p426.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p427.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p427.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p455.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p455.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p514.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p514.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p523.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p523.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p586.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p586.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p653.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p653.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p654.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p654.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p680.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p680.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p710.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p710.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p721.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p721.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p762.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p762.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p800.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p800.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p810.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p810.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p827.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p827.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/competition_leakages/Leak_p879.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/competition_leakages/Leak_p879.xlsx -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanet2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/32bit/epanet2.dll -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanet2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/32bit/epanet2.exe -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanet2.h: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | Project: OWA EPANET 4 | Version: 2.2 5 | Module: epanet2.h 6 | Description: declarations of the legacy style EPANET 2 API functions 7 | Authors: see AUTHORS 8 | Copyright: see AUTHORS 9 | License: see LICENSE 10 | Last Updated: 10/29/2019 11 | ****************************************************************************** 12 | */ 13 | 14 | /* 15 | This module contains declarations of the legacy style EPANET API functions, with 16 | version 2.2 updates, that apply only to single threaded applications. A second 17 | set of thread safe API functions that allows one to run concurrent analyses on 18 | multiple EPANET projects can be found in the epanet2_2.h header file. The two 19 | APIs share the same function names and arguments with the difference being that 20 | the thread safe functions use the prefix "EN_" and include an extra argument that 21 | represents the EPANET project being analyzed. To avoid unneccesary repetition, 22 | only the thread safe API functions have been documented. To see a description of 23 | a legacy style API function declared here please refer to its complementary named 24 | function in epanet2_2.h. 25 | */ 26 | 27 | #ifndef EPANET2_H 28 | #define EPANET2_H 29 | 30 | // The legacy style EPANET API can be compiled with support for either single 31 | // precision or double precision floating point arguments, with the default 32 | // being single precision. To compile for double precision one must #define 33 | // EN_API_FLOAT_TYPE as double both here and in any client code that uses the 34 | // API. 35 | #ifndef EN_API_FLOAT_TYPE 36 | #define EN_API_FLOAT_TYPE float 37 | #endif 38 | 39 | #ifndef DLLEXPORT 40 | #ifdef _WIN32 41 | #ifdef epanet2_EXPORTS 42 | #define DLLEXPORT __declspec(dllexport) __stdcall 43 | #else 44 | #define DLLEXPORT __declspec(dllimport) __stdcall 45 | #endif 46 | #elif defined(__CYGWIN__) 47 | #define DLLEXPORT __stdcall 48 | #else 49 | #define DLLEXPORT 50 | #endif 51 | #endif 52 | 53 | #include "epanet2_enums.h" 54 | 55 | // --- Declare the EPANET toolkit functions 56 | #if defined(__cplusplus) 57 | extern "C" { 58 | #endif 59 | 60 | 61 | /******************************************************************** 62 | 63 | Project Functions 64 | 65 | ********************************************************************/ 66 | 67 | int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile, 68 | const char *outFile, void (*pviewprog) (char *)); 69 | 70 | int DLLEXPORT ENinit(const char *rptFile, const char *outFile, 71 | int unitsType, int headlossType); 72 | 73 | int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, 74 | const char *outFile); 75 | 76 | int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3); 77 | 78 | int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3); 79 | 80 | int DLLEXPORT ENgetcomment(int object, int index, char *comment); 81 | 82 | int DLLEXPORT ENsetcomment(int object, int index, char *comment); 83 | 84 | int DLLEXPORT ENgetcount(int object, int *count); 85 | 86 | int DLLEXPORT ENsaveinpfile(const char *filename); 87 | 88 | int DLLEXPORT ENclose(); 89 | 90 | /******************************************************************** 91 | 92 | Hydraulic Analysis Functions 93 | 94 | ********************************************************************/ 95 | 96 | int DLLEXPORT ENsolveH(); 97 | 98 | int DLLEXPORT ENsaveH(); 99 | 100 | int DLLEXPORT ENopenH(); 101 | 102 | int DLLEXPORT ENinitH(int initFlag); 103 | 104 | int DLLEXPORT ENrunH(long *currentTime); 105 | 106 | int DLLEXPORT ENnextH(long *tStep); 107 | 108 | int DLLEXPORT ENcloseH(); 109 | 110 | int DLLEXPORT ENsavehydfile(char *filename); 111 | 112 | int DLLEXPORT ENusehydfile(char *filename); 113 | 114 | /******************************************************************** 115 | 116 | Water Quality Analysis Functions 117 | 118 | ********************************************************************/ 119 | 120 | int DLLEXPORT ENsolveQ(); 121 | 122 | int DLLEXPORT ENopenQ(); 123 | 124 | int DLLEXPORT ENinitQ(int saveFlag); 125 | 126 | int DLLEXPORT ENrunQ(long *currentTime); 127 | 128 | int DLLEXPORT ENnextQ(long *tStep); 129 | 130 | int DLLEXPORT ENstepQ(long *timeLeft); 131 | 132 | int DLLEXPORT ENcloseQ(); 133 | 134 | /******************************************************************** 135 | 136 | Reporting Functions 137 | 138 | ********************************************************************/ 139 | 140 | int DLLEXPORT ENwriteline(char *line); 141 | 142 | int DLLEXPORT ENreport(); 143 | 144 | int DLLEXPORT ENcopyreport(char *filename); 145 | 146 | int DLLEXPORT ENclearreport(); 147 | 148 | int DLLEXPORT ENresetreport(); 149 | 150 | int DLLEXPORT ENsetreport(char *format); 151 | 152 | int DLLEXPORT ENsetstatusreport(int level); 153 | 154 | int DLLEXPORT ENgetversion(int *version); 155 | 156 | int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen); 157 | 158 | int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value); 159 | 160 | int DLLEXPORT ENgetresultindex(int type, int index, int *value); 161 | 162 | /******************************************************************** 163 | 164 | Analysis Options Functions 165 | 166 | ********************************************************************/ 167 | 168 | int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value); 169 | 170 | int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value); 171 | 172 | int DLLEXPORT ENgetflowunits(int *units); 173 | 174 | int DLLEXPORT ENsetflowunits(int units); 175 | 176 | int DLLEXPORT ENgettimeparam(int param, long *value); 177 | 178 | int DLLEXPORT ENsettimeparam(int param, long value); 179 | 180 | int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits, 181 | int *traceNode); 182 | 183 | int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode); 184 | 185 | int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits, 186 | char *traceNode); 187 | 188 | /******************************************************************** 189 | 190 | Node Functions 191 | 192 | ********************************************************************/ 193 | 194 | int DLLEXPORT ENaddnode(char *id, int nodeType, int *index); 195 | 196 | int DLLEXPORT ENdeletenode(int index, int actionCode); 197 | 198 | int DLLEXPORT ENgetnodeindex(char *id, int *index); 199 | 200 | int DLLEXPORT ENgetnodeid(int index, char *id); 201 | 202 | int DLLEXPORT ENsetnodeid(int index, char *newid); 203 | 204 | int DLLEXPORT ENgetnodetype(int index, int *nodeType); 205 | 206 | int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value); 207 | 208 | int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value); 209 | 210 | int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, 211 | EN_API_FLOAT_TYPE dmnd, char *dmndpat); 212 | 213 | int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, 214 | EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl, 215 | EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam, 216 | EN_API_FLOAT_TYPE minvol, char *volcurve); 217 | 218 | int DLLEXPORT ENgetcoord(int index, double *x, double *y); 219 | 220 | int DLLEXPORT ENsetcoord(int index, double x, double y); 221 | 222 | /******************************************************************** 223 | 224 | Nodal Demand Functions 225 | 226 | ********************************************************************/ 227 | 228 | int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin, 229 | EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp); 230 | 231 | int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin, 232 | EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp); 233 | 234 | int DLLEXPORT ENadddemand(int nodeIndex, EN_API_FLOAT_TYPE baseDemand, 235 | char *demandPattern, char *demandName); 236 | 237 | int DLLEXPORT ENdeletedemand(int nodeIndex, int demandIndex); 238 | 239 | int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands); 240 | 241 | int DLLEXPORT ENgetdemandindex(int nodeIndex, char *demandName, int *demandIndex); 242 | 243 | int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex, 244 | EN_API_FLOAT_TYPE *baseDemand); 245 | 246 | int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex, 247 | EN_API_FLOAT_TYPE baseDemand); 248 | 249 | int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *patIndex); 250 | 251 | int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex); 252 | 253 | int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName); 254 | 255 | int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName); 256 | 257 | /******************************************************************** 258 | 259 | Link Functions 260 | 261 | ********************************************************************/ 262 | 263 | int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index); 264 | 265 | int DLLEXPORT ENdeletelink(int index, int actionCode); 266 | 267 | int DLLEXPORT ENgetlinkindex(char *id, int *index); 268 | 269 | int DLLEXPORT ENgetlinkid(int index, char *id); 270 | 271 | int DLLEXPORT ENsetlinkid(int index, char *newid); 272 | 273 | int DLLEXPORT ENgetlinktype(int index, int *linkType); 274 | 275 | int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode); 276 | 277 | int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2); 278 | 279 | int DLLEXPORT ENsetlinknodes(int index, int node1, int node2); 280 | 281 | int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value); 282 | 283 | int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value); 284 | 285 | int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, 286 | EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, 287 | EN_API_FLOAT_TYPE mloss); 288 | 289 | int DLLEXPORT ENgetvertexcount(int index, int *count); 290 | 291 | int DLLEXPORT ENgetvertex(int index, int vertex, double *x, double *y); 292 | 293 | int DLLEXPORT ENsetvertices(int index, double *x, double *y, int count); 294 | 295 | /******************************************************************** 296 | 297 | Pump Functions 298 | 299 | ********************************************************************/ 300 | 301 | int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType); 302 | 303 | int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex); 304 | 305 | int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex); 306 | 307 | /******************************************************************** 308 | 309 | Time Pattern Functions 310 | 311 | ********************************************************************/ 312 | 313 | int DLLEXPORT ENaddpattern(char *id); 314 | 315 | int DLLEXPORT ENdeletepattern(int index); 316 | 317 | int DLLEXPORT ENgetpatternindex(char *id, int *index); 318 | 319 | int DLLEXPORT ENgetpatternid(int index, char *id); 320 | 321 | int DLLEXPORT ENsetpatternid(int index, char *id); 322 | 323 | int DLLEXPORT ENgetpatternlen(int index, int *len); 324 | 325 | int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value); 326 | 327 | int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value); 328 | 329 | int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); 330 | 331 | int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len); 332 | 333 | /******************************************************************** 334 | 335 | Data Curve Functions 336 | 337 | ********************************************************************/ 338 | 339 | int DLLEXPORT ENaddcurve(char *id); 340 | 341 | int DLLEXPORT ENdeletecurve(int index); 342 | 343 | int DLLEXPORT ENgetcurveindex(char *id, int *index); 344 | 345 | int DLLEXPORT ENgetcurveid(int index, char *id); 346 | 347 | int DLLEXPORT ENsetcurveid(int index, char *id); 348 | 349 | int DLLEXPORT ENgetcurvelen(int index, int *len); 350 | 351 | int DLLEXPORT ENgetcurvetype(int index, int *type); 352 | 353 | int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, 354 | EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y); 355 | 356 | int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex, 357 | EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); 358 | 359 | int DLLEXPORT ENgetcurve(int index, char* id, int *nPoints, 360 | EN_API_FLOAT_TYPE *xValues, EN_API_FLOAT_TYPE *yValues); 361 | 362 | int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues, 363 | EN_API_FLOAT_TYPE *yValues, int nPoints); 364 | 365 | /******************************************************************** 366 | 367 | Simple Controls Functions 368 | 369 | ********************************************************************/ 370 | 371 | int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting, 372 | int nodeIndex, EN_API_FLOAT_TYPE level, int *index); 373 | 374 | int DLLEXPORT ENdeletecontrol(int index); 375 | 376 | int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex, 377 | EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level); 378 | 379 | int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex, 380 | EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level); 381 | 382 | 383 | /******************************************************************** 384 | 385 | Rule-Based Controls Functions 386 | 387 | ********************************************************************/ 388 | 389 | int DLLEXPORT ENaddrule(char *rule); 390 | 391 | int DLLEXPORT ENdeleterule(int index); 392 | 393 | int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions, 394 | int *nElseActions, EN_API_FLOAT_TYPE *priority); 395 | 396 | int DLLEXPORT ENgetruleID(int index, char* id); 397 | 398 | int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop, 399 | int *object, int *objIndex, int *variable, 400 | int *relop, int *status, EN_API_FLOAT_TYPE *value); 401 | 402 | int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop, 403 | int object, int objIndex, int variable, int relop, 404 | int status, EN_API_FLOAT_TYPE value); 405 | 406 | int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex); 407 | 408 | int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status); 409 | 410 | int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex, 411 | EN_API_FLOAT_TYPE value); 412 | 413 | int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex, 414 | int *status, EN_API_FLOAT_TYPE *setting); 415 | 416 | int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex, 417 | int status, EN_API_FLOAT_TYPE setting); 418 | 419 | int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex, 420 | int *status, EN_API_FLOAT_TYPE *setting); 421 | 422 | int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex, 423 | int status, EN_API_FLOAT_TYPE setting); 424 | 425 | int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority); 426 | 427 | #if defined(__cplusplus) 428 | } 429 | #endif 430 | 431 | #endif //EPANET2_H 432 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanet2_enums.h: -------------------------------------------------------------------------------- 1 | /** @file epanet2_enums.h 2 | */ 3 | /* 4 | ****************************************************************************** 5 | Project: OWA EPANET 6 | Version: 2.2 7 | Module: epanet2_enums.h 8 | Description: enumerations of symbolic constants used by the API functions 9 | Authors: see AUTHORS 10 | Copyright: see AUTHORS 11 | License: see LICENSE 12 | Last Updated: 11/06/2019 13 | ****************************************************************************** 14 | */ 15 | 16 | 17 | #ifndef EPANET2_ENUMS_H 18 | #define EPANET2_ENUMS_H 19 | 20 | 21 | // --- Define the EPANET toolkit constants 22 | 23 | /// Size Limts 24 | /** 25 | Limits on the size of character arrays used to store ID names 26 | and text messages. 27 | */ 28 | typedef enum { 29 | EN_MAXID = 31, //!< Max. # characters in ID name 30 | EN_MAXMSG = 255 //!< Max. # characters in message text 31 | } EN_SizeLimits; 32 | 33 | /// Node properties 34 | /** 35 | These node properties are used with @ref EN_getnodevalue and @ref EN_setnodevalue. 36 | Those marked as read only are computed values that can only be retrieved. 37 | */ 38 | typedef enum { 39 | EN_ELEVATION = 0, //!< Elevation 40 | EN_BASEDEMAND = 1, //!< Primary demand baseline value 41 | EN_PATTERN = 2, //!< Primary demand time pattern index 42 | EN_EMITTER = 3, //!< Emitter flow coefficient 43 | EN_INITQUAL = 4, //!< Initial quality 44 | EN_SOURCEQUAL = 5, //!< Quality source strength 45 | EN_SOURCEPAT = 6, //!< Quality source pattern index 46 | EN_SOURCETYPE = 7, //!< Quality source type (see @ref EN_SourceType) 47 | EN_TANKLEVEL = 8, //!< Current computed tank water level (read only) 48 | EN_DEMAND = 9, //!< Current computed demand (read only) 49 | EN_HEAD = 10, //!< Current computed hydraulic head (read only) 50 | EN_PRESSURE = 11, //!< Current computed pressure (read only) 51 | EN_QUALITY = 12, //!< Current computed quality (read only) 52 | EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow (read only) 53 | EN_INITVOLUME = 14, //!< Tank initial volume (read only) 54 | EN_MIXMODEL = 15, //!< Tank mixing model (see @ref EN_MixingModel) 55 | EN_MIXZONEVOL = 16, //!< Tank mixing zone volume (read only) 56 | EN_TANKDIAM = 17, //!< Tank diameter 57 | EN_MINVOLUME = 18, //!< Tank minimum volume 58 | EN_VOLCURVE = 19, //!< Tank volume curve index 59 | EN_MINLEVEL = 20, //!< Tank minimum level 60 | EN_MAXLEVEL = 21, //!< Tank maximum level 61 | EN_MIXFRACTION = 22, //!< Tank mixing fraction 62 | EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient 63 | EN_TANKVOLUME = 24, //!< Current computed tank volume (read only) 64 | EN_MAXVOLUME = 25, //!< Tank maximum volume (read only) 65 | EN_CANOVERFLOW = 26, //!< Tank can overflow (= 1) or not (= 0) 66 | EN_DEMANDDEFICIT = 27 //!< Amount that full demand is reduced under PDA (read only) 67 | } EN_NodeProperty; 68 | 69 | /// Link properties 70 | /** 71 | These link properties are used with @ref EN_getlinkvalue and @ref EN_setlinkvalue. 72 | Those marked as read only are computed values that can only be retrieved. 73 | */ 74 | typedef enum { 75 | EN_DIAMETER = 0, //!< Pipe/valve diameter 76 | EN_LENGTH = 1, //!< Pipe length 77 | EN_ROUGHNESS = 2, //!< Pipe roughness coefficient 78 | EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient 79 | EN_INITSTATUS = 4, //!< Initial status (see @ref EN_LinkStatusType) 80 | EN_INITSETTING = 5, //!< Initial pump speed or valve setting 81 | EN_KBULK = 6, //!< Bulk chemical reaction coefficient 82 | EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient 83 | EN_FLOW = 8, //!< Current computed flow rate (read only) 84 | EN_VELOCITY = 9, //!< Current computed flow velocity (read only) 85 | EN_HEADLOSS = 10, //!< Current computed head loss (read only) 86 | EN_STATUS = 11, //!< Current link status (see @ref EN_LinkStatusType) 87 | EN_SETTING = 12, //!< Current link setting 88 | EN_ENERGY = 13, //!< Current computed pump energy usage (read only) 89 | EN_LINKQUAL = 14, //!< Current computed link quality (read only) 90 | EN_LINKPATTERN = 15, //!< Pump speed time pattern index 91 | EN_PUMP_STATE = 16, //!< Current computed pump state (read only) (see @ref EN_PumpStateType) 92 | EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency (read only) 93 | EN_PUMP_POWER = 18, //!< Pump constant power rating 94 | EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve index 95 | EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve index 96 | EN_PUMP_ECOST = 21, //!< Pump average energy price 97 | EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index 98 | } EN_LinkProperty; 99 | 100 | /// Time parameters 101 | /** 102 | These time-related options are used with @ref EN_gettimeparam and@ref EN_settimeparam. 103 | All times are expressed in seconds The parameters marked as read only are 104 | computed values that can only be retrieved. 105 | */ 106 | typedef enum { 107 | EN_DURATION = 0, //!< Total simulation duration 108 | EN_HYDSTEP = 1, //!< Hydraulic time step 109 | EN_QUALSTEP = 2, //!< Water quality time step 110 | EN_PATTERNSTEP = 3, //!< Time pattern period 111 | EN_PATTERNSTART = 4, //!< Time when time patterns begin 112 | EN_REPORTSTEP = 5, //!< Reporting time step 113 | EN_REPORTSTART = 6, //!< Time when reporting starts 114 | EN_RULESTEP = 7, //!< Rule-based control evaluation time step 115 | EN_STATISTIC = 8, //!< Reporting statistic code (see @ref EN_StatisticType) 116 | EN_PERIODS = 9, //!< Number of reporting time periods (read only) 117 | EN_STARTTIME = 10, //!< Simulation starting time of day 118 | EN_HTIME = 11, //!< Elapsed time of current hydraulic solution (read only) 119 | EN_QTIME = 12, //!< Elapsed time of current quality solution (read only) 120 | EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted (read only) 121 | EN_NEXTEVENT = 14, //!< Shortest time until a tank becomes empty or full (read only) 122 | EN_NEXTEVENTTANK = 15 //!< Index of tank with shortest time to become empty or full (read only) 123 | } EN_TimeParameter; 124 | 125 | /// Analysis convergence statistics 126 | /** 127 | These statistics report the convergence criteria for the most current hydraulic analysis 128 | and the cumulative water quality mass balance error at the current simulation time. They 129 | can be retrieved with @ref EN_getstatistic. 130 | */ 131 | typedef enum { 132 | EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken 133 | EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows 134 | EN_MAXHEADERROR = 2, //!< Largest head loss error for links 135 | EN_MAXFLOWCHANGE = 3, //!< Largest flow change in links 136 | EN_MASSBALANCE = 4, //!< Cumulative water quality mass balance ratio 137 | EN_DEFICIENTNODES = 5, //!< Number of pressure deficient nodes 138 | EN_DEMANDREDUCTION = 6 //!< % demand reduction at pressure deficient nodes 139 | } EN_AnalysisStatistic; 140 | 141 | /// Types of network objects 142 | /** 143 | The types of objects that comprise a network model. 144 | */ 145 | typedef enum { 146 | EN_NODE = 0, //!< Nodes 147 | EN_LINK = 1, //!< Links 148 | EN_TIMEPAT = 2, //!< Time patterns 149 | EN_CURVE = 3, //!< Data curves 150 | EN_CONTROL = 4, //!< Simple controls 151 | EN_RULE = 5 //!< Control rules 152 | } EN_ObjectType; 153 | 154 | /// Types of objects to count 155 | /** 156 | These options tell @ref EN_getcount which type of object to count. 157 | */ 158 | typedef enum { 159 | EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs) 160 | EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs 161 | EN_LINKCOUNT = 2, //!< Number of links (pipes + pumps + valves) 162 | EN_PATCOUNT = 3, //!< Number of time patterns 163 | EN_CURVECOUNT = 4, //!< Number of data curves 164 | EN_CONTROLCOUNT = 5, //!< Number of simple controls 165 | EN_RULECOUNT = 6 //!< Number of rule-based controls 166 | } EN_CountType; 167 | 168 | /// Node Types 169 | /** 170 | These are the different types of nodes that can be returned by calling @ref EN_getnodetype. 171 | */ 172 | typedef enum { 173 | EN_JUNCTION = 0, //!< Junction node 174 | EN_RESERVOIR = 1, //!< Reservoir node 175 | EN_TANK = 2 //!< Storage tank node 176 | } EN_NodeType; 177 | 178 | /// Link types 179 | /** 180 | These are the different types of links that can be returned by calling @ref EN_getlinktype. 181 | */ 182 | typedef enum { 183 | EN_CVPIPE = 0, //!< Pipe with check valve 184 | EN_PIPE = 1, //!< Pipe 185 | EN_PUMP = 2, //!< Pump 186 | EN_PRV = 3, //!< Pressure reducing valve 187 | EN_PSV = 4, //!< Pressure sustaining valve 188 | EN_PBV = 5, //!< Pressure breaker valve 189 | EN_FCV = 6, //!< Flow control valve 190 | EN_TCV = 7, //!< Throttle control valve 191 | EN_GPV = 8 //!< General purpose valve 192 | } EN_LinkType; 193 | 194 | /// Link status 195 | /** 196 | One of these values is returned when @ref EN_getlinkvalue is used to retrieve a link's 197 | initial status ( \b EN_INITSTATUS ) or its current status ( \b EN_STATUS ). These options are 198 | also used with @ref EN_setlinkvalue to set values for these same properties. 199 | */ 200 | typedef enum { 201 | EN_CLOSED = 0, 202 | EN_OPEN = 1 203 | } EN_LinkStatusType; 204 | 205 | /// Pump states 206 | /** 207 | One of these codes is returned when @ref EN_getlinkvalue is used to retrieve a pump's 208 | current operating state ( \b EN_PUMP_STATE ). \b EN_PUMP_XHEAD indicates that the pump has been 209 | shut down because it is being asked to deliver more than its shutoff head. \b EN_PUMP_XFLOW 210 | indicates that the pump is being asked to deliver more than its maximum flow. 211 | */ 212 | typedef enum { 213 | EN_PUMP_XHEAD = 0, //!< Pump closed - cannot supply head 214 | EN_PUMP_CLOSED = 2, //!< Pump closed 215 | EN_PUMP_OPEN = 3, //!< Pump open 216 | EN_PUMP_XFLOW = 5 //!< Pump open - cannot supply flow 217 | } EN_PumpStateType; 218 | 219 | /// Types of water quality analyses 220 | /** 221 | These are the different types of water quality analyses that EPANET can run. They 222 | are used with @ref EN_getqualinfo, @ref EN_getqualtype, and @ref EN_setqualtype. 223 | */ 224 | typedef enum { 225 | EN_NONE = 0, //!< No quality analysis 226 | EN_CHEM = 1, //!< Chemical fate and transport 227 | EN_AGE = 2, //!< Water age analysis 228 | EN_TRACE = 3 //!< Source tracing analysis 229 | } EN_QualityType; 230 | 231 | /// Water quality source types 232 | /** 233 | These are the different types of external water quality sources that can be assigned 234 | to a node's \b EN_SOURCETYPE property as used by @ref EN_getnodevalue and @ref EN_setnodevalue. 235 | */ 236 | typedef enum { 237 | EN_CONCEN = 0, //!< Sets the concentration of external inflow entering a node 238 | EN_MASS = 1, //!< Injects a given mass/minute into a node 239 | EN_SETPOINT = 2, //!< Sets the concentration leaving a node to a given value 240 | EN_FLOWPACED = 3 //!< Adds a given value to the concentration leaving a node 241 | } EN_SourceType; 242 | 243 | /// Head loss formulas 244 | /** 245 | The available choices for the \b EN_HEADLOSSFORM option in @ref EN_getoption and 246 | @ref EN_setoption. They are also used for the head loss type argument in @ref EN_init. 247 | Each head loss formula uses a different type of roughness coefficient ( \b EN_ROUGHNESS ) 248 | that can be set with @ref EN_setlinkvalue. 249 | */ 250 | typedef enum { 251 | EN_HW = 0, //!< Hazen-Williams 252 | EN_DW = 1, //!< Darcy-Weisbach 253 | EN_CM = 2 //!< Chezy-Manning 254 | } EN_HeadLossType; 255 | 256 | /// Flow units 257 | /** 258 | These choices for flow units are used with @ref EN_getflowunits and @ref EN_setflowunits. 259 | They are also used for the flow units type argument in @ref EN_init. If flow units are 260 | expressed in US Customary units ( \b EN_CFS through \b EN_AFD ) then all other quantities are 261 | in US Customary units. Otherwise they are in metric units. 262 | */ 263 | typedef enum { 264 | EN_CFS = 0, //!< Cubic feet per second 265 | EN_GPM = 1, //!< Gallons per minute 266 | EN_MGD = 2, //!< Million gallons per day 267 | EN_IMGD = 3, //!< Imperial million gallons per day 268 | EN_AFD = 4, //!< Acre-feet per day 269 | EN_LPS = 5, //!< Liters per second 270 | EN_LPM = 6, //!< Liters per minute 271 | EN_MLD = 7, //!< Million liters per day 272 | EN_CMH = 8, //!< Cubic meters per hour 273 | EN_CMD = 9 //!< Cubic meters per day 274 | } EN_FlowUnits; 275 | 276 | /// Demand models 277 | /** 278 | These choices for modeling consumer demands are used with @ref EN_getdemandmodel 279 | and @ref EN_setdemandmodel. 280 | 281 | A demand driven analysis requires that a junction's full demand be supplied 282 | in each time period independent of how much pressure is available. A pressure 283 | driven analysis makes demand be a power function of pressure, up to the point 284 | where the full demand is met. 285 | */ 286 | typedef enum { 287 | EN_DDA = 0, //!< Demand driven analysis 288 | EN_PDA = 1 //!< Pressure driven analysis 289 | } EN_DemandModel; 290 | 291 | /// Simulation options 292 | /** 293 | These constants identify the hydraulic and water quality simulation options 294 | that are applied on a network-wide basis. They are accessed using the 295 | @ref EN_getoption and @ref EN_setoption functions. 296 | */ 297 | typedef enum { 298 | EN_TRIALS = 0, //!< Maximum trials allowed for hydraulic convergence 299 | EN_ACCURACY = 1, //!< Total normalized flow change for hydraulic convergence 300 | EN_TOLERANCE = 2, //!< Water quality tolerance 301 | EN_EMITEXPON = 3, //!< Exponent in emitter discharge formula 302 | EN_DEMANDMULT = 4, //!< Global demand multiplier 303 | EN_HEADERROR = 5, //!< Maximum head loss error for hydraulic convergence 304 | EN_FLOWCHANGE = 6, //!< Maximum flow change for hydraulic convergence 305 | EN_HEADLOSSFORM = 7, //!< Head loss formula (see @ref EN_HeadLossType) 306 | EN_GLOBALEFFIC = 8, //!< Global pump efficiency (percent) 307 | EN_GLOBALPRICE = 9, //!< Global energy price per KWH 308 | EN_GLOBALPATTERN = 10, //!< Index of a global energy price pattern 309 | EN_DEMANDCHARGE = 11, //!< Energy charge per max. KW usage 310 | EN_SP_GRAVITY = 12, //!< Specific gravity 311 | EN_SP_VISCOS = 13, //!< Specific viscosity (relative to water at 20 deg C) 312 | EN_UNBALANCED = 14, //!< Extra trials allowed if hydraulics don't converge 313 | EN_CHECKFREQ = 15, //!< Frequency of hydraulic status checks 314 | EN_MAXCHECK = 16, //!< Maximum trials for status checking 315 | EN_DAMPLIMIT = 17, //!< Accuracy level where solution damping begins 316 | EN_SP_DIFFUS = 18, //!< Specific diffusivity (relative to chlorine at 20 deg C) 317 | EN_BULKORDER = 19, //!< Bulk water reaction order for pipes 318 | EN_WALLORDER = 20, //!< Wall reaction order for pipes (either 0 or 1) 319 | EN_TANKORDER = 21, //!< Bulk water reaction order for tanks 320 | EN_CONCENLIMIT = 22 //!< Limiting concentration for growth reactions 321 | } EN_Option; 322 | 323 | /// Simple control types 324 | /** 325 | These are the different types of simple (single statement) controls that can be applied 326 | to network links. They are used as an argument to @ref EN_addcontrol,@ref EN_getcontrol, 327 | and @ref EN_setcontrol. 328 | */ 329 | typedef enum { 330 | EN_LOWLEVEL = 0, //!< Act when pressure or tank level drops below a setpoint 331 | EN_HILEVEL = 1, //!< Act when pressure or tank level rises above a setpoint 332 | EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time 333 | EN_TIMEOFDAY = 3 //!< Act at a particular time of day 334 | } EN_ControlType; 335 | 336 | /// Reporting statistic choices 337 | /** 338 | These options determine what kind of statistical post-processing should be done on 339 | the time series of simulation results generated before they are reported using 340 | @ref EN_report. An option can be chosen by using \b STATISTIC _option_ as the argument 341 | to @ref EN_setreport. 342 | */ 343 | typedef enum { 344 | EN_SERIES = 0, //!< Report all time series points 345 | EN_AVERAGE = 1, //!< Report average value over simulation period 346 | EN_MINIMUM = 2, //!< Report minimum value over simulation period 347 | EN_MAXIMUM = 3, //!< Report maximum value over simulation period 348 | EN_RANGE = 4 //!< Report maximum - minimum over simulation period 349 | } EN_StatisticType; 350 | 351 | /// Tank mixing models 352 | /** 353 | These are the different types of models that describe water quality mixing in storage tanks. 354 | The choice of model is accessed with the \b EN_MIXMODEL property of a Tank node using 355 | @ref EN_getnodevalue and @ref EN_setnodevalue. 356 | */ 357 | typedef enum { 358 | EN_MIX1 = 0, //!< Complete mix model 359 | EN_MIX2 = 1, //!< 2-compartment model 360 | EN_FIFO = 2, //!< First in, first out model 361 | EN_LIFO = 3 //!< Last in, first out model 362 | } EN_MixingModel; 363 | 364 | /// Hydraulic initialization options 365 | /** 366 | These options are used to initialize a new hydraulic analysis when @ref EN_initH is called. 367 | */ 368 | typedef enum { 369 | EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows 370 | EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows 371 | EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows 372 | EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows 373 | } EN_InitHydOption; 374 | 375 | /// Types of pump curves 376 | /** 377 | @ref EN_getpumptype returns one of these values when it is called. 378 | */ 379 | typedef enum { 380 | EN_CONST_HP = 0, //!< Constant horsepower 381 | EN_POWER_FUNC = 1, //!< Power function 382 | EN_CUSTOM = 2, //!< User-defined custom curve 383 | EN_NOCURVE = 3 //!< No curve 384 | } EN_PumpType; 385 | 386 | /// Types of data curves 387 | /** 388 | These are the different types of physical relationships that a data curve can 389 | represent as returned by calling @ref EN_getcurvetype. 390 | */ 391 | typedef enum { 392 | EN_VOLUME_CURVE = 0, //!< Tank volume v. depth curve 393 | EN_PUMP_CURVE = 1, //!< Pump head v. flow curve 394 | EN_EFFIC_CURVE = 2, //!< Pump efficiency v. flow curve 395 | EN_HLOSS_CURVE = 3, //!< Valve head loss v. flow curve 396 | EN_GENERIC_CURVE = 4 //!< Generic curve 397 | } EN_CurveType; 398 | 399 | /// Deletion action codes 400 | /** 401 | These codes are used in @ref EN_deletenode and @ref EN_deletelink to indicate what action 402 | should be taken if the node or link being deleted appears in any simple or rule-based 403 | controls or if a deleted node has any links connected to it. 404 | */ 405 | typedef enum { 406 | EN_UNCONDITIONAL = 0, //!< Delete all controls and connecing links 407 | EN_CONDITIONAL = 1 //!< Cancel object deletion if it appears in controls or has connecting links 408 | } EN_ActionCodeType; 409 | 410 | /// Status reporting levels 411 | /** 412 | These choices specify the level of status reporting written to a project's report 413 | file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport function. 414 | */ 415 | typedef enum { 416 | EN_NO_REPORT = 0, //!< No status reporting 417 | EN_NORMAL_REPORT = 1, //!< Normal level of status reporting 418 | EN_FULL_REPORT = 2 //!< Full level of status reporting 419 | } EN_StatusReport; 420 | 421 | /// Network objects used in rule-based controls 422 | typedef enum { 423 | EN_R_NODE = 6, //!< Clause refers to a node 424 | EN_R_LINK = 7, //!< Clause refers to a link 425 | EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time) 426 | } EN_RuleObject; 427 | 428 | /// Object variables used in rule-based controls 429 | typedef enum { 430 | EN_R_DEMAND = 0, //!< Nodal demand 431 | EN_R_HEAD = 1, //!< Nodal hydraulic head 432 | EN_R_GRADE = 2, //!< Nodal hydraulic grade 433 | EN_R_LEVEL = 3, //!< Tank water level 434 | EN_R_PRESSURE = 4, //!< Nodal pressure 435 | EN_R_FLOW = 5, //!< Link flow rate 436 | EN_R_STATUS = 6, //!< Link status 437 | EN_R_SETTING = 7, //!< Link setting 438 | EN_R_POWER = 8, //!< Pump power output 439 | EN_R_TIME = 9, //!< Elapsed simulation time 440 | EN_R_CLOCKTIME = 10, //!< Time of day 441 | EN_R_FILLTIME = 11, //!< Time to fill a tank 442 | EN_R_DRAINTIME = 12 //!< Time to drain a tank 443 | } EN_RuleVariable; 444 | 445 | /// Comparison operators used in rule-based controls 446 | typedef enum { 447 | EN_R_EQ = 0, //!< Equal to 448 | EN_R_NE = 1, //!< Not equal 449 | EN_R_LE = 2, //!< Less than or equal to 450 | EN_R_GE = 3, //!< Greater than or equal to 451 | EN_R_LT = 4, //!< Less than 452 | EN_R_GT = 5, //!< Greater than 453 | EN_R_IS = 6, //!< Is equal to 454 | EN_R_NOT = 7, //!< Is not equal to 455 | EN_R_BELOW = 8, //!< Is below 456 | EN_R_ABOVE = 9 //!< Is above 457 | } EN_RuleOperator; 458 | 459 | /// Link status codes used in rule-based controls 460 | typedef enum { 461 | EN_R_IS_OPEN = 1, //!< Link is open 462 | EN_R_IS_CLOSED = 2, //!< Link is closed 463 | EN_R_IS_ACTIVE = 3 //!< Control valve is active 464 | } EN_RuleStatus; 465 | 466 | #define EN_MISSING -1.E10 //!< Missing value indicator 467 | 468 | #endif //EPANET2_ENUMS_H 469 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanetmsx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/32bit/epanetmsx.dll -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanetmsx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/32bit/epanetmsx.exe -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/32bit/epanetmsx.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** MODULE: EPANETMSX.H 3 | ** PROJECT: EPANET-MSX 4 | ** DESCRIPTION: C/C++ header file for EPANET Multi-Species Extension Toolkit 5 | ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber. 6 | ** All Rights Reserved. See license information in LICENSE.TXT. 7 | ** AUTHORS: L. Rossman, US EPA - NRMRL 8 | ** F. Shang, University of Cincinnati 9 | ** J. Uber, University of Cincinnati 10 | ** VERSION: 1.1 11 | ** LAST UPDATE: 11/01/10 12 | *******************************************************************************/ 13 | 14 | #ifndef EPANETMSX_H 15 | #define EPANETMSX_H 16 | 17 | // --- define WINDOWS 18 | 19 | #undef WINDOWS 20 | #ifdef _WIN32 21 | #define WINDOWS 22 | #endif 23 | #ifdef __WIN32__ 24 | #define WINDOWS 25 | #endif 26 | 27 | // --- define DLLEXPORT 28 | 29 | #ifndef DLLEXPORT // ttaxon - 9/7/10 30 | #ifdef WINDOWS 31 | #ifdef __cplusplus 32 | #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall 33 | #else 34 | #define DLLEXPORT __declspec(dllexport) __stdcall 35 | #endif 36 | #else 37 | #ifdef __cplusplus 38 | #define DLLEXPORT extern "C" 39 | #else 40 | #define DLLEXPORT 41 | #endif 42 | #endif 43 | #endif 44 | 45 | // --- define MSX constants 46 | 47 | #define MSX_NODE 0 48 | #define MSX_LINK 1 49 | #define MSX_TANK 2 50 | #define MSX_SPECIES 3 51 | #define MSX_TERM 4 52 | #define MSX_PARAMETER 5 53 | #define MSX_CONSTANT 6 54 | #define MSX_PATTERN 7 55 | 56 | #define MSX_BULK 0 57 | #define MSX_WALL 1 58 | 59 | #define MSX_NOSOURCE -1 60 | #define MSX_CONCEN 0 61 | #define MSX_MASS 1 62 | #define MSX_SETPOINT 2 63 | #define MSX_FLOWPACED 3 64 | 65 | // --- declare MSX functions 66 | 67 | int DLLEXPORT MSXopen(char *fname); 68 | int DLLEXPORT MSXsolveH(void); 69 | int DLLEXPORT MSXusehydfile(char *fname); 70 | int DLLEXPORT MSXsolveQ(void); 71 | int DLLEXPORT MSXinit(int saveFlag); 72 | int DLLEXPORT MSXstep(long *t, long *tleft); 73 | int DLLEXPORT MSXsaveoutfile(char *fname); 74 | int DLLEXPORT MSXsavemsxfile(char *fname); 75 | int DLLEXPORT MSXreport(void); 76 | int DLLEXPORT MSXclose(void); 77 | 78 | int DLLEXPORT MSXgetindex(int type, char *id, int *index); 79 | int DLLEXPORT MSXgetIDlen(int type, int index, int *len); 80 | int DLLEXPORT MSXgetID(int type, int index, char *id, int len); 81 | int DLLEXPORT MSXgetcount(int type, int *count); 82 | int DLLEXPORT MSXgetspecies(int index, int *type, char *units, double *aTol, 83 | double *rTol); 84 | int DLLEXPORT MSXgetconstant(int index, double *value); 85 | int DLLEXPORT MSXgetparameter(int type, int index, int param, double *value); 86 | int DLLEXPORT MSXgetsource(int node, int species, int *type, double *level, 87 | int *pat); 88 | int DLLEXPORT MSXgetpatternlen(int pat, int *len); 89 | int DLLEXPORT MSXgetpatternvalue(int pat, int period, double *value); 90 | int DLLEXPORT MSXgetinitqual(int type, int index, int species, double *value); 91 | int DLLEXPORT MSXgetqual(int type, int index, int species, double *value); 92 | int DLLEXPORT MSXgeterror(int code, char *msg, int len); 93 | 94 | int DLLEXPORT MSXsetconstant(int index, double value); 95 | int DLLEXPORT MSXsetparameter(int type, int index, int param, double value); 96 | int DLLEXPORT MSXsetinitqual(int type, int index, int species, double value); 97 | int DLLEXPORT MSXsetsource(int node, int species, int type, double level, 98 | int pat); 99 | int DLLEXPORT MSXsetpatternvalue(int pat, int period, double value); 100 | int DLLEXPORT MSXsetpattern(int pat, double mult[], int len); 101 | int DLLEXPORT MSXaddpattern(char *id); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanet2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/64bit/epanet2.dll -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanet2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/64bit/epanet2.exe -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanet2.h: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | Project: OWA EPANET 4 | Version: 2.2 5 | Module: epanet2.h 6 | Description: declarations of the legacy style EPANET 2 API functions 7 | Authors: see AUTHORS 8 | Copyright: see AUTHORS 9 | License: see LICENSE 10 | Last Updated: 10/29/2019 11 | ****************************************************************************** 12 | */ 13 | 14 | /* 15 | This module contains declarations of the legacy style EPANET API functions, with 16 | version 2.2 updates, that apply only to single threaded applications. A second 17 | set of thread safe API functions that allows one to run concurrent analyses on 18 | multiple EPANET projects can be found in the epanet2_2.h header file. The two 19 | APIs share the same function names and arguments with the difference being that 20 | the thread safe functions use the prefix "EN_" and include an extra argument that 21 | represents the EPANET project being analyzed. To avoid unneccesary repetition, 22 | only the thread safe API functions have been documented. To see a description of 23 | a legacy style API function declared here please refer to its complementary named 24 | function in epanet2_2.h. 25 | */ 26 | 27 | #ifndef EPANET2_H 28 | #define EPANET2_H 29 | 30 | // The legacy style EPANET API can be compiled with support for either single 31 | // precision or double precision floating point arguments, with the default 32 | // being single precision. To compile for double precision one must #define 33 | // EN_API_FLOAT_TYPE as double both here and in any client code that uses the 34 | // API. 35 | #ifndef EN_API_FLOAT_TYPE 36 | #define EN_API_FLOAT_TYPE float 37 | #endif 38 | 39 | #ifndef DLLEXPORT 40 | #ifdef _WIN32 41 | #ifdef epanet2_EXPORTS 42 | #define DLLEXPORT __declspec(dllexport) __stdcall 43 | #else 44 | #define DLLEXPORT __declspec(dllimport) __stdcall 45 | #endif 46 | #elif defined(__CYGWIN__) 47 | #define DLLEXPORT __stdcall 48 | #else 49 | #define DLLEXPORT 50 | #endif 51 | #endif 52 | 53 | #include "epanet2_enums.h" 54 | 55 | // --- Declare the EPANET toolkit functions 56 | #if defined(__cplusplus) 57 | extern "C" { 58 | #endif 59 | 60 | 61 | /******************************************************************** 62 | 63 | Project Functions 64 | 65 | ********************************************************************/ 66 | 67 | int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile, 68 | const char *outFile, void (*pviewprog) (char *)); 69 | 70 | int DLLEXPORT ENinit(const char *rptFile, const char *outFile, 71 | int unitsType, int headlossType); 72 | 73 | int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, 74 | const char *outFile); 75 | 76 | int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3); 77 | 78 | int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3); 79 | 80 | int DLLEXPORT ENgetcomment(int object, int index, char *comment); 81 | 82 | int DLLEXPORT ENsetcomment(int object, int index, char *comment); 83 | 84 | int DLLEXPORT ENgetcount(int object, int *count); 85 | 86 | int DLLEXPORT ENsaveinpfile(const char *filename); 87 | 88 | int DLLEXPORT ENclose(); 89 | 90 | /******************************************************************** 91 | 92 | Hydraulic Analysis Functions 93 | 94 | ********************************************************************/ 95 | 96 | int DLLEXPORT ENsolveH(); 97 | 98 | int DLLEXPORT ENsaveH(); 99 | 100 | int DLLEXPORT ENopenH(); 101 | 102 | int DLLEXPORT ENinitH(int initFlag); 103 | 104 | int DLLEXPORT ENrunH(long *currentTime); 105 | 106 | int DLLEXPORT ENnextH(long *tStep); 107 | 108 | int DLLEXPORT ENcloseH(); 109 | 110 | int DLLEXPORT ENsavehydfile(char *filename); 111 | 112 | int DLLEXPORT ENusehydfile(char *filename); 113 | 114 | /******************************************************************** 115 | 116 | Water Quality Analysis Functions 117 | 118 | ********************************************************************/ 119 | 120 | int DLLEXPORT ENsolveQ(); 121 | 122 | int DLLEXPORT ENopenQ(); 123 | 124 | int DLLEXPORT ENinitQ(int saveFlag); 125 | 126 | int DLLEXPORT ENrunQ(long *currentTime); 127 | 128 | int DLLEXPORT ENnextQ(long *tStep); 129 | 130 | int DLLEXPORT ENstepQ(long *timeLeft); 131 | 132 | int DLLEXPORT ENcloseQ(); 133 | 134 | /******************************************************************** 135 | 136 | Reporting Functions 137 | 138 | ********************************************************************/ 139 | 140 | int DLLEXPORT ENwriteline(char *line); 141 | 142 | int DLLEXPORT ENreport(); 143 | 144 | int DLLEXPORT ENcopyreport(char *filename); 145 | 146 | int DLLEXPORT ENclearreport(); 147 | 148 | int DLLEXPORT ENresetreport(); 149 | 150 | int DLLEXPORT ENsetreport(char *format); 151 | 152 | int DLLEXPORT ENsetstatusreport(int level); 153 | 154 | int DLLEXPORT ENgetversion(int *version); 155 | 156 | int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen); 157 | 158 | int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value); 159 | 160 | int DLLEXPORT ENgetresultindex(int type, int index, int *value); 161 | 162 | /******************************************************************** 163 | 164 | Analysis Options Functions 165 | 166 | ********************************************************************/ 167 | 168 | int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value); 169 | 170 | int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value); 171 | 172 | int DLLEXPORT ENgetflowunits(int *units); 173 | 174 | int DLLEXPORT ENsetflowunits(int units); 175 | 176 | int DLLEXPORT ENgettimeparam(int param, long *value); 177 | 178 | int DLLEXPORT ENsettimeparam(int param, long value); 179 | 180 | int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits, 181 | int *traceNode); 182 | 183 | int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode); 184 | 185 | int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits, 186 | char *traceNode); 187 | 188 | /******************************************************************** 189 | 190 | Node Functions 191 | 192 | ********************************************************************/ 193 | 194 | int DLLEXPORT ENaddnode(char *id, int nodeType, int *index); 195 | 196 | int DLLEXPORT ENdeletenode(int index, int actionCode); 197 | 198 | int DLLEXPORT ENgetnodeindex(char *id, int *index); 199 | 200 | int DLLEXPORT ENgetnodeid(int index, char *id); 201 | 202 | int DLLEXPORT ENsetnodeid(int index, char *newid); 203 | 204 | int DLLEXPORT ENgetnodetype(int index, int *nodeType); 205 | 206 | int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value); 207 | 208 | int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value); 209 | 210 | int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, 211 | EN_API_FLOAT_TYPE dmnd, char *dmndpat); 212 | 213 | int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, 214 | EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl, 215 | EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam, 216 | EN_API_FLOAT_TYPE minvol, char *volcurve); 217 | 218 | int DLLEXPORT ENgetcoord(int index, double *x, double *y); 219 | 220 | int DLLEXPORT ENsetcoord(int index, double x, double y); 221 | 222 | /******************************************************************** 223 | 224 | Nodal Demand Functions 225 | 226 | ********************************************************************/ 227 | 228 | int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin, 229 | EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp); 230 | 231 | int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin, 232 | EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp); 233 | 234 | int DLLEXPORT ENadddemand(int nodeIndex, EN_API_FLOAT_TYPE baseDemand, 235 | char *demandPattern, char *demandName); 236 | 237 | int DLLEXPORT ENdeletedemand(int nodeIndex, int demandIndex); 238 | 239 | int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands); 240 | 241 | int DLLEXPORT ENgetdemandindex(int nodeIndex, char *demandName, int *demandIndex); 242 | 243 | int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex, 244 | EN_API_FLOAT_TYPE *baseDemand); 245 | 246 | int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex, 247 | EN_API_FLOAT_TYPE baseDemand); 248 | 249 | int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *patIndex); 250 | 251 | int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex); 252 | 253 | int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName); 254 | 255 | int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName); 256 | 257 | /******************************************************************** 258 | 259 | Link Functions 260 | 261 | ********************************************************************/ 262 | 263 | int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index); 264 | 265 | int DLLEXPORT ENdeletelink(int index, int actionCode); 266 | 267 | int DLLEXPORT ENgetlinkindex(char *id, int *index); 268 | 269 | int DLLEXPORT ENgetlinkid(int index, char *id); 270 | 271 | int DLLEXPORT ENsetlinkid(int index, char *newid); 272 | 273 | int DLLEXPORT ENgetlinktype(int index, int *linkType); 274 | 275 | int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode); 276 | 277 | int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2); 278 | 279 | int DLLEXPORT ENsetlinknodes(int index, int node1, int node2); 280 | 281 | int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value); 282 | 283 | int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value); 284 | 285 | int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, 286 | EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, 287 | EN_API_FLOAT_TYPE mloss); 288 | 289 | int DLLEXPORT ENgetvertexcount(int index, int *count); 290 | 291 | int DLLEXPORT ENgetvertex(int index, int vertex, double *x, double *y); 292 | 293 | int DLLEXPORT ENsetvertices(int index, double *x, double *y, int count); 294 | 295 | /******************************************************************** 296 | 297 | Pump Functions 298 | 299 | ********************************************************************/ 300 | 301 | int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType); 302 | 303 | int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex); 304 | 305 | int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex); 306 | 307 | /******************************************************************** 308 | 309 | Time Pattern Functions 310 | 311 | ********************************************************************/ 312 | 313 | int DLLEXPORT ENaddpattern(char *id); 314 | 315 | int DLLEXPORT ENdeletepattern(int index); 316 | 317 | int DLLEXPORT ENgetpatternindex(char *id, int *index); 318 | 319 | int DLLEXPORT ENgetpatternid(int index, char *id); 320 | 321 | int DLLEXPORT ENsetpatternid(int index, char *id); 322 | 323 | int DLLEXPORT ENgetpatternlen(int index, int *len); 324 | 325 | int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value); 326 | 327 | int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value); 328 | 329 | int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); 330 | 331 | int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len); 332 | 333 | /******************************************************************** 334 | 335 | Data Curve Functions 336 | 337 | ********************************************************************/ 338 | 339 | int DLLEXPORT ENaddcurve(char *id); 340 | 341 | int DLLEXPORT ENdeletecurve(int index); 342 | 343 | int DLLEXPORT ENgetcurveindex(char *id, int *index); 344 | 345 | int DLLEXPORT ENgetcurveid(int index, char *id); 346 | 347 | int DLLEXPORT ENsetcurveid(int index, char *id); 348 | 349 | int DLLEXPORT ENgetcurvelen(int index, int *len); 350 | 351 | int DLLEXPORT ENgetcurvetype(int index, int *type); 352 | 353 | int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, 354 | EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y); 355 | 356 | int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex, 357 | EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); 358 | 359 | int DLLEXPORT ENgetcurve(int index, char* id, int *nPoints, 360 | EN_API_FLOAT_TYPE *xValues, EN_API_FLOAT_TYPE *yValues); 361 | 362 | int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues, 363 | EN_API_FLOAT_TYPE *yValues, int nPoints); 364 | 365 | /******************************************************************** 366 | 367 | Simple Controls Functions 368 | 369 | ********************************************************************/ 370 | 371 | int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting, 372 | int nodeIndex, EN_API_FLOAT_TYPE level, int *index); 373 | 374 | int DLLEXPORT ENdeletecontrol(int index); 375 | 376 | int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex, 377 | EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level); 378 | 379 | int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex, 380 | EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level); 381 | 382 | 383 | /******************************************************************** 384 | 385 | Rule-Based Controls Functions 386 | 387 | ********************************************************************/ 388 | 389 | int DLLEXPORT ENaddrule(char *rule); 390 | 391 | int DLLEXPORT ENdeleterule(int index); 392 | 393 | int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions, 394 | int *nElseActions, EN_API_FLOAT_TYPE *priority); 395 | 396 | int DLLEXPORT ENgetruleID(int index, char* id); 397 | 398 | int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop, 399 | int *object, int *objIndex, int *variable, 400 | int *relop, int *status, EN_API_FLOAT_TYPE *value); 401 | 402 | int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop, 403 | int object, int objIndex, int variable, int relop, 404 | int status, EN_API_FLOAT_TYPE value); 405 | 406 | int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex); 407 | 408 | int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status); 409 | 410 | int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex, 411 | EN_API_FLOAT_TYPE value); 412 | 413 | int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex, 414 | int *status, EN_API_FLOAT_TYPE *setting); 415 | 416 | int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex, 417 | int status, EN_API_FLOAT_TYPE setting); 418 | 419 | int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex, 420 | int *status, EN_API_FLOAT_TYPE *setting); 421 | 422 | int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex, 423 | int status, EN_API_FLOAT_TYPE setting); 424 | 425 | int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority); 426 | 427 | #if defined(__cplusplus) 428 | } 429 | #endif 430 | 431 | #endif //EPANET2_H 432 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanet2_enums.h: -------------------------------------------------------------------------------- 1 | /** @file epanet2_enums.h 2 | */ 3 | /* 4 | ****************************************************************************** 5 | Project: OWA EPANET 6 | Version: 2.2 7 | Module: epanet2_enums.h 8 | Description: enumerations of symbolic constants used by the API functions 9 | Authors: see AUTHORS 10 | Copyright: see AUTHORS 11 | License: see LICENSE 12 | Last Updated: 11/06/2019 13 | ****************************************************************************** 14 | */ 15 | 16 | 17 | #ifndef EPANET2_ENUMS_H 18 | #define EPANET2_ENUMS_H 19 | 20 | 21 | // --- Define the EPANET toolkit constants 22 | 23 | /// Size Limts 24 | /** 25 | Limits on the size of character arrays used to store ID names 26 | and text messages. 27 | */ 28 | typedef enum { 29 | EN_MAXID = 31, //!< Max. # characters in ID name 30 | EN_MAXMSG = 255 //!< Max. # characters in message text 31 | } EN_SizeLimits; 32 | 33 | /// Node properties 34 | /** 35 | These node properties are used with @ref EN_getnodevalue and @ref EN_setnodevalue. 36 | Those marked as read only are computed values that can only be retrieved. 37 | */ 38 | typedef enum { 39 | EN_ELEVATION = 0, //!< Elevation 40 | EN_BASEDEMAND = 1, //!< Primary demand baseline value 41 | EN_PATTERN = 2, //!< Primary demand time pattern index 42 | EN_EMITTER = 3, //!< Emitter flow coefficient 43 | EN_INITQUAL = 4, //!< Initial quality 44 | EN_SOURCEQUAL = 5, //!< Quality source strength 45 | EN_SOURCEPAT = 6, //!< Quality source pattern index 46 | EN_SOURCETYPE = 7, //!< Quality source type (see @ref EN_SourceType) 47 | EN_TANKLEVEL = 8, //!< Current computed tank water level (read only) 48 | EN_DEMAND = 9, //!< Current computed demand (read only) 49 | EN_HEAD = 10, //!< Current computed hydraulic head (read only) 50 | EN_PRESSURE = 11, //!< Current computed pressure (read only) 51 | EN_QUALITY = 12, //!< Current computed quality (read only) 52 | EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow (read only) 53 | EN_INITVOLUME = 14, //!< Tank initial volume (read only) 54 | EN_MIXMODEL = 15, //!< Tank mixing model (see @ref EN_MixingModel) 55 | EN_MIXZONEVOL = 16, //!< Tank mixing zone volume (read only) 56 | EN_TANKDIAM = 17, //!< Tank diameter 57 | EN_MINVOLUME = 18, //!< Tank minimum volume 58 | EN_VOLCURVE = 19, //!< Tank volume curve index 59 | EN_MINLEVEL = 20, //!< Tank minimum level 60 | EN_MAXLEVEL = 21, //!< Tank maximum level 61 | EN_MIXFRACTION = 22, //!< Tank mixing fraction 62 | EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient 63 | EN_TANKVOLUME = 24, //!< Current computed tank volume (read only) 64 | EN_MAXVOLUME = 25, //!< Tank maximum volume (read only) 65 | EN_CANOVERFLOW = 26, //!< Tank can overflow (= 1) or not (= 0) 66 | EN_DEMANDDEFICIT = 27 //!< Amount that full demand is reduced under PDA (read only) 67 | } EN_NodeProperty; 68 | 69 | /// Link properties 70 | /** 71 | These link properties are used with @ref EN_getlinkvalue and @ref EN_setlinkvalue. 72 | Those marked as read only are computed values that can only be retrieved. 73 | */ 74 | typedef enum { 75 | EN_DIAMETER = 0, //!< Pipe/valve diameter 76 | EN_LENGTH = 1, //!< Pipe length 77 | EN_ROUGHNESS = 2, //!< Pipe roughness coefficient 78 | EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient 79 | EN_INITSTATUS = 4, //!< Initial status (see @ref EN_LinkStatusType) 80 | EN_INITSETTING = 5, //!< Initial pump speed or valve setting 81 | EN_KBULK = 6, //!< Bulk chemical reaction coefficient 82 | EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient 83 | EN_FLOW = 8, //!< Current computed flow rate (read only) 84 | EN_VELOCITY = 9, //!< Current computed flow velocity (read only) 85 | EN_HEADLOSS = 10, //!< Current computed head loss (read only) 86 | EN_STATUS = 11, //!< Current link status (see @ref EN_LinkStatusType) 87 | EN_SETTING = 12, //!< Current link setting 88 | EN_ENERGY = 13, //!< Current computed pump energy usage (read only) 89 | EN_LINKQUAL = 14, //!< Current computed link quality (read only) 90 | EN_LINKPATTERN = 15, //!< Pump speed time pattern index 91 | EN_PUMP_STATE = 16, //!< Current computed pump state (read only) (see @ref EN_PumpStateType) 92 | EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency (read only) 93 | EN_PUMP_POWER = 18, //!< Pump constant power rating 94 | EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve index 95 | EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve index 96 | EN_PUMP_ECOST = 21, //!< Pump average energy price 97 | EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index 98 | } EN_LinkProperty; 99 | 100 | /// Time parameters 101 | /** 102 | These time-related options are used with @ref EN_gettimeparam and@ref EN_settimeparam. 103 | All times are expressed in seconds The parameters marked as read only are 104 | computed values that can only be retrieved. 105 | */ 106 | typedef enum { 107 | EN_DURATION = 0, //!< Total simulation duration 108 | EN_HYDSTEP = 1, //!< Hydraulic time step 109 | EN_QUALSTEP = 2, //!< Water quality time step 110 | EN_PATTERNSTEP = 3, //!< Time pattern period 111 | EN_PATTERNSTART = 4, //!< Time when time patterns begin 112 | EN_REPORTSTEP = 5, //!< Reporting time step 113 | EN_REPORTSTART = 6, //!< Time when reporting starts 114 | EN_RULESTEP = 7, //!< Rule-based control evaluation time step 115 | EN_STATISTIC = 8, //!< Reporting statistic code (see @ref EN_StatisticType) 116 | EN_PERIODS = 9, //!< Number of reporting time periods (read only) 117 | EN_STARTTIME = 10, //!< Simulation starting time of day 118 | EN_HTIME = 11, //!< Elapsed time of current hydraulic solution (read only) 119 | EN_QTIME = 12, //!< Elapsed time of current quality solution (read only) 120 | EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted (read only) 121 | EN_NEXTEVENT = 14, //!< Shortest time until a tank becomes empty or full (read only) 122 | EN_NEXTEVENTTANK = 15 //!< Index of tank with shortest time to become empty or full (read only) 123 | } EN_TimeParameter; 124 | 125 | /// Analysis convergence statistics 126 | /** 127 | These statistics report the convergence criteria for the most current hydraulic analysis 128 | and the cumulative water quality mass balance error at the current simulation time. They 129 | can be retrieved with @ref EN_getstatistic. 130 | */ 131 | typedef enum { 132 | EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken 133 | EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows 134 | EN_MAXHEADERROR = 2, //!< Largest head loss error for links 135 | EN_MAXFLOWCHANGE = 3, //!< Largest flow change in links 136 | EN_MASSBALANCE = 4, //!< Cumulative water quality mass balance ratio 137 | EN_DEFICIENTNODES = 5, //!< Number of pressure deficient nodes 138 | EN_DEMANDREDUCTION = 6 //!< % demand reduction at pressure deficient nodes 139 | } EN_AnalysisStatistic; 140 | 141 | /// Types of network objects 142 | /** 143 | The types of objects that comprise a network model. 144 | */ 145 | typedef enum { 146 | EN_NODE = 0, //!< Nodes 147 | EN_LINK = 1, //!< Links 148 | EN_TIMEPAT = 2, //!< Time patterns 149 | EN_CURVE = 3, //!< Data curves 150 | EN_CONTROL = 4, //!< Simple controls 151 | EN_RULE = 5 //!< Control rules 152 | } EN_ObjectType; 153 | 154 | /// Types of objects to count 155 | /** 156 | These options tell @ref EN_getcount which type of object to count. 157 | */ 158 | typedef enum { 159 | EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs) 160 | EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs 161 | EN_LINKCOUNT = 2, //!< Number of links (pipes + pumps + valves) 162 | EN_PATCOUNT = 3, //!< Number of time patterns 163 | EN_CURVECOUNT = 4, //!< Number of data curves 164 | EN_CONTROLCOUNT = 5, //!< Number of simple controls 165 | EN_RULECOUNT = 6 //!< Number of rule-based controls 166 | } EN_CountType; 167 | 168 | /// Node Types 169 | /** 170 | These are the different types of nodes that can be returned by calling @ref EN_getnodetype. 171 | */ 172 | typedef enum { 173 | EN_JUNCTION = 0, //!< Junction node 174 | EN_RESERVOIR = 1, //!< Reservoir node 175 | EN_TANK = 2 //!< Storage tank node 176 | } EN_NodeType; 177 | 178 | /// Link types 179 | /** 180 | These are the different types of links that can be returned by calling @ref EN_getlinktype. 181 | */ 182 | typedef enum { 183 | EN_CVPIPE = 0, //!< Pipe with check valve 184 | EN_PIPE = 1, //!< Pipe 185 | EN_PUMP = 2, //!< Pump 186 | EN_PRV = 3, //!< Pressure reducing valve 187 | EN_PSV = 4, //!< Pressure sustaining valve 188 | EN_PBV = 5, //!< Pressure breaker valve 189 | EN_FCV = 6, //!< Flow control valve 190 | EN_TCV = 7, //!< Throttle control valve 191 | EN_GPV = 8 //!< General purpose valve 192 | } EN_LinkType; 193 | 194 | /// Link status 195 | /** 196 | One of these values is returned when @ref EN_getlinkvalue is used to retrieve a link's 197 | initial status ( \b EN_INITSTATUS ) or its current status ( \b EN_STATUS ). These options are 198 | also used with @ref EN_setlinkvalue to set values for these same properties. 199 | */ 200 | typedef enum { 201 | EN_CLOSED = 0, 202 | EN_OPEN = 1 203 | } EN_LinkStatusType; 204 | 205 | /// Pump states 206 | /** 207 | One of these codes is returned when @ref EN_getlinkvalue is used to retrieve a pump's 208 | current operating state ( \b EN_PUMP_STATE ). \b EN_PUMP_XHEAD indicates that the pump has been 209 | shut down because it is being asked to deliver more than its shutoff head. \b EN_PUMP_XFLOW 210 | indicates that the pump is being asked to deliver more than its maximum flow. 211 | */ 212 | typedef enum { 213 | EN_PUMP_XHEAD = 0, //!< Pump closed - cannot supply head 214 | EN_PUMP_CLOSED = 2, //!< Pump closed 215 | EN_PUMP_OPEN = 3, //!< Pump open 216 | EN_PUMP_XFLOW = 5 //!< Pump open - cannot supply flow 217 | } EN_PumpStateType; 218 | 219 | /// Types of water quality analyses 220 | /** 221 | These are the different types of water quality analyses that EPANET can run. They 222 | are used with @ref EN_getqualinfo, @ref EN_getqualtype, and @ref EN_setqualtype. 223 | */ 224 | typedef enum { 225 | EN_NONE = 0, //!< No quality analysis 226 | EN_CHEM = 1, //!< Chemical fate and transport 227 | EN_AGE = 2, //!< Water age analysis 228 | EN_TRACE = 3 //!< Source tracing analysis 229 | } EN_QualityType; 230 | 231 | /// Water quality source types 232 | /** 233 | These are the different types of external water quality sources that can be assigned 234 | to a node's \b EN_SOURCETYPE property as used by @ref EN_getnodevalue and @ref EN_setnodevalue. 235 | */ 236 | typedef enum { 237 | EN_CONCEN = 0, //!< Sets the concentration of external inflow entering a node 238 | EN_MASS = 1, //!< Injects a given mass/minute into a node 239 | EN_SETPOINT = 2, //!< Sets the concentration leaving a node to a given value 240 | EN_FLOWPACED = 3 //!< Adds a given value to the concentration leaving a node 241 | } EN_SourceType; 242 | 243 | /// Head loss formulas 244 | /** 245 | The available choices for the \b EN_HEADLOSSFORM option in @ref EN_getoption and 246 | @ref EN_setoption. They are also used for the head loss type argument in @ref EN_init. 247 | Each head loss formula uses a different type of roughness coefficient ( \b EN_ROUGHNESS ) 248 | that can be set with @ref EN_setlinkvalue. 249 | */ 250 | typedef enum { 251 | EN_HW = 0, //!< Hazen-Williams 252 | EN_DW = 1, //!< Darcy-Weisbach 253 | EN_CM = 2 //!< Chezy-Manning 254 | } EN_HeadLossType; 255 | 256 | /// Flow units 257 | /** 258 | These choices for flow units are used with @ref EN_getflowunits and @ref EN_setflowunits. 259 | They are also used for the flow units type argument in @ref EN_init. If flow units are 260 | expressed in US Customary units ( \b EN_CFS through \b EN_AFD ) then all other quantities are 261 | in US Customary units. Otherwise they are in metric units. 262 | */ 263 | typedef enum { 264 | EN_CFS = 0, //!< Cubic feet per second 265 | EN_GPM = 1, //!< Gallons per minute 266 | EN_MGD = 2, //!< Million gallons per day 267 | EN_IMGD = 3, //!< Imperial million gallons per day 268 | EN_AFD = 4, //!< Acre-feet per day 269 | EN_LPS = 5, //!< Liters per second 270 | EN_LPM = 6, //!< Liters per minute 271 | EN_MLD = 7, //!< Million liters per day 272 | EN_CMH = 8, //!< Cubic meters per hour 273 | EN_CMD = 9 //!< Cubic meters per day 274 | } EN_FlowUnits; 275 | 276 | /// Demand models 277 | /** 278 | These choices for modeling consumer demands are used with @ref EN_getdemandmodel 279 | and @ref EN_setdemandmodel. 280 | 281 | A demand driven analysis requires that a junction's full demand be supplied 282 | in each time period independent of how much pressure is available. A pressure 283 | driven analysis makes demand be a power function of pressure, up to the point 284 | where the full demand is met. 285 | */ 286 | typedef enum { 287 | EN_DDA = 0, //!< Demand driven analysis 288 | EN_PDA = 1 //!< Pressure driven analysis 289 | } EN_DemandModel; 290 | 291 | /// Simulation options 292 | /** 293 | These constants identify the hydraulic and water quality simulation options 294 | that are applied on a network-wide basis. They are accessed using the 295 | @ref EN_getoption and @ref EN_setoption functions. 296 | */ 297 | typedef enum { 298 | EN_TRIALS = 0, //!< Maximum trials allowed for hydraulic convergence 299 | EN_ACCURACY = 1, //!< Total normalized flow change for hydraulic convergence 300 | EN_TOLERANCE = 2, //!< Water quality tolerance 301 | EN_EMITEXPON = 3, //!< Exponent in emitter discharge formula 302 | EN_DEMANDMULT = 4, //!< Global demand multiplier 303 | EN_HEADERROR = 5, //!< Maximum head loss error for hydraulic convergence 304 | EN_FLOWCHANGE = 6, //!< Maximum flow change for hydraulic convergence 305 | EN_HEADLOSSFORM = 7, //!< Head loss formula (see @ref EN_HeadLossType) 306 | EN_GLOBALEFFIC = 8, //!< Global pump efficiency (percent) 307 | EN_GLOBALPRICE = 9, //!< Global energy price per KWH 308 | EN_GLOBALPATTERN = 10, //!< Index of a global energy price pattern 309 | EN_DEMANDCHARGE = 11, //!< Energy charge per max. KW usage 310 | EN_SP_GRAVITY = 12, //!< Specific gravity 311 | EN_SP_VISCOS = 13, //!< Specific viscosity (relative to water at 20 deg C) 312 | EN_UNBALANCED = 14, //!< Extra trials allowed if hydraulics don't converge 313 | EN_CHECKFREQ = 15, //!< Frequency of hydraulic status checks 314 | EN_MAXCHECK = 16, //!< Maximum trials for status checking 315 | EN_DAMPLIMIT = 17, //!< Accuracy level where solution damping begins 316 | EN_SP_DIFFUS = 18, //!< Specific diffusivity (relative to chlorine at 20 deg C) 317 | EN_BULKORDER = 19, //!< Bulk water reaction order for pipes 318 | EN_WALLORDER = 20, //!< Wall reaction order for pipes (either 0 or 1) 319 | EN_TANKORDER = 21, //!< Bulk water reaction order for tanks 320 | EN_CONCENLIMIT = 22 //!< Limiting concentration for growth reactions 321 | } EN_Option; 322 | 323 | /// Simple control types 324 | /** 325 | These are the different types of simple (single statement) controls that can be applied 326 | to network links. They are used as an argument to @ref EN_addcontrol,@ref EN_getcontrol, 327 | and @ref EN_setcontrol. 328 | */ 329 | typedef enum { 330 | EN_LOWLEVEL = 0, //!< Act when pressure or tank level drops below a setpoint 331 | EN_HILEVEL = 1, //!< Act when pressure or tank level rises above a setpoint 332 | EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time 333 | EN_TIMEOFDAY = 3 //!< Act at a particular time of day 334 | } EN_ControlType; 335 | 336 | /// Reporting statistic choices 337 | /** 338 | These options determine what kind of statistical post-processing should be done on 339 | the time series of simulation results generated before they are reported using 340 | @ref EN_report. An option can be chosen by using \b STATISTIC _option_ as the argument 341 | to @ref EN_setreport. 342 | */ 343 | typedef enum { 344 | EN_SERIES = 0, //!< Report all time series points 345 | EN_AVERAGE = 1, //!< Report average value over simulation period 346 | EN_MINIMUM = 2, //!< Report minimum value over simulation period 347 | EN_MAXIMUM = 3, //!< Report maximum value over simulation period 348 | EN_RANGE = 4 //!< Report maximum - minimum over simulation period 349 | } EN_StatisticType; 350 | 351 | /// Tank mixing models 352 | /** 353 | These are the different types of models that describe water quality mixing in storage tanks. 354 | The choice of model is accessed with the \b EN_MIXMODEL property of a Tank node using 355 | @ref EN_getnodevalue and @ref EN_setnodevalue. 356 | */ 357 | typedef enum { 358 | EN_MIX1 = 0, //!< Complete mix model 359 | EN_MIX2 = 1, //!< 2-compartment model 360 | EN_FIFO = 2, //!< First in, first out model 361 | EN_LIFO = 3 //!< Last in, first out model 362 | } EN_MixingModel; 363 | 364 | /// Hydraulic initialization options 365 | /** 366 | These options are used to initialize a new hydraulic analysis when @ref EN_initH is called. 367 | */ 368 | typedef enum { 369 | EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows 370 | EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows 371 | EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows 372 | EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows 373 | } EN_InitHydOption; 374 | 375 | /// Types of pump curves 376 | /** 377 | @ref EN_getpumptype returns one of these values when it is called. 378 | */ 379 | typedef enum { 380 | EN_CONST_HP = 0, //!< Constant horsepower 381 | EN_POWER_FUNC = 1, //!< Power function 382 | EN_CUSTOM = 2, //!< User-defined custom curve 383 | EN_NOCURVE = 3 //!< No curve 384 | } EN_PumpType; 385 | 386 | /// Types of data curves 387 | /** 388 | These are the different types of physical relationships that a data curve can 389 | represent as returned by calling @ref EN_getcurvetype. 390 | */ 391 | typedef enum { 392 | EN_VOLUME_CURVE = 0, //!< Tank volume v. depth curve 393 | EN_PUMP_CURVE = 1, //!< Pump head v. flow curve 394 | EN_EFFIC_CURVE = 2, //!< Pump efficiency v. flow curve 395 | EN_HLOSS_CURVE = 3, //!< Valve head loss v. flow curve 396 | EN_GENERIC_CURVE = 4 //!< Generic curve 397 | } EN_CurveType; 398 | 399 | /// Deletion action codes 400 | /** 401 | These codes are used in @ref EN_deletenode and @ref EN_deletelink to indicate what action 402 | should be taken if the node or link being deleted appears in any simple or rule-based 403 | controls or if a deleted node has any links connected to it. 404 | */ 405 | typedef enum { 406 | EN_UNCONDITIONAL = 0, //!< Delete all controls and connecing links 407 | EN_CONDITIONAL = 1 //!< Cancel object deletion if it appears in controls or has connecting links 408 | } EN_ActionCodeType; 409 | 410 | /// Status reporting levels 411 | /** 412 | These choices specify the level of status reporting written to a project's report 413 | file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport function. 414 | */ 415 | typedef enum { 416 | EN_NO_REPORT = 0, //!< No status reporting 417 | EN_NORMAL_REPORT = 1, //!< Normal level of status reporting 418 | EN_FULL_REPORT = 2 //!< Full level of status reporting 419 | } EN_StatusReport; 420 | 421 | /// Network objects used in rule-based controls 422 | typedef enum { 423 | EN_R_NODE = 6, //!< Clause refers to a node 424 | EN_R_LINK = 7, //!< Clause refers to a link 425 | EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time) 426 | } EN_RuleObject; 427 | 428 | /// Object variables used in rule-based controls 429 | typedef enum { 430 | EN_R_DEMAND = 0, //!< Nodal demand 431 | EN_R_HEAD = 1, //!< Nodal hydraulic head 432 | EN_R_GRADE = 2, //!< Nodal hydraulic grade 433 | EN_R_LEVEL = 3, //!< Tank water level 434 | EN_R_PRESSURE = 4, //!< Nodal pressure 435 | EN_R_FLOW = 5, //!< Link flow rate 436 | EN_R_STATUS = 6, //!< Link status 437 | EN_R_SETTING = 7, //!< Link setting 438 | EN_R_POWER = 8, //!< Pump power output 439 | EN_R_TIME = 9, //!< Elapsed simulation time 440 | EN_R_CLOCKTIME = 10, //!< Time of day 441 | EN_R_FILLTIME = 11, //!< Time to fill a tank 442 | EN_R_DRAINTIME = 12 //!< Time to drain a tank 443 | } EN_RuleVariable; 444 | 445 | /// Comparison operators used in rule-based controls 446 | typedef enum { 447 | EN_R_EQ = 0, //!< Equal to 448 | EN_R_NE = 1, //!< Not equal 449 | EN_R_LE = 2, //!< Less than or equal to 450 | EN_R_GE = 3, //!< Greater than or equal to 451 | EN_R_LT = 4, //!< Less than 452 | EN_R_GT = 5, //!< Greater than 453 | EN_R_IS = 6, //!< Is equal to 454 | EN_R_NOT = 7, //!< Is not equal to 455 | EN_R_BELOW = 8, //!< Is below 456 | EN_R_ABOVE = 9 //!< Is above 457 | } EN_RuleOperator; 458 | 459 | /// Link status codes used in rule-based controls 460 | typedef enum { 461 | EN_R_IS_OPEN = 1, //!< Link is open 462 | EN_R_IS_CLOSED = 2, //!< Link is closed 463 | EN_R_IS_ACTIVE = 3 //!< Control valve is active 464 | } EN_RuleStatus; 465 | 466 | #define EN_MISSING -1.E10 //!< Missing value indicator 467 | 468 | #endif //EPANET2_ENUMS_H 469 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanetmsx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/64bit/epanetmsx.dll -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanetmsx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/64bit/epanetmsx.exe -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/64bit/epanetmsx.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** MODULE: EPANETMSX.H 3 | ** PROJECT: EPANET-MSX 4 | ** DESCRIPTION: C/C++ header file for EPANET Multi-Species Extension Toolkit 5 | ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber. 6 | ** All Rights Reserved. See license information in LICENSE.TXT. 7 | ** AUTHORS: L. Rossman, US EPA - NRMRL 8 | ** F. Shang, University of Cincinnati 9 | ** J. Uber, University of Cincinnati 10 | ** VERSION: 1.1 11 | ** LAST UPDATE: 11/01/10 12 | *******************************************************************************/ 13 | 14 | #ifndef EPANETMSX_H 15 | #define EPANETMSX_H 16 | 17 | // --- define WINDOWS 18 | 19 | #undef WINDOWS 20 | #ifdef _WIN32 21 | #define WINDOWS 22 | #endif 23 | #ifdef __WIN32__ 24 | #define WINDOWS 25 | #endif 26 | 27 | // --- define DLLEXPORT 28 | 29 | #ifndef DLLEXPORT // ttaxon - 9/7/10 30 | #ifdef WINDOWS 31 | #ifdef __cplusplus 32 | #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall 33 | #else 34 | #define DLLEXPORT __declspec(dllexport) __stdcall 35 | #endif 36 | #else 37 | #ifdef __cplusplus 38 | #define DLLEXPORT extern "C" 39 | #else 40 | #define DLLEXPORT 41 | #endif 42 | #endif 43 | #endif 44 | 45 | // --- define MSX constants 46 | 47 | #define MSX_NODE 0 48 | #define MSX_LINK 1 49 | #define MSX_TANK 2 50 | #define MSX_SPECIES 3 51 | #define MSX_TERM 4 52 | #define MSX_PARAMETER 5 53 | #define MSX_CONSTANT 6 54 | #define MSX_PATTERN 7 55 | 56 | #define MSX_BULK 0 57 | #define MSX_WALL 1 58 | 59 | #define MSX_NOSOURCE -1 60 | #define MSX_CONCEN 0 61 | #define MSX_MASS 1 62 | #define MSX_SETPOINT 2 63 | #define MSX_FLOWPACED 3 64 | 65 | // --- declare MSX functions 66 | 67 | int DLLEXPORT MSXopen(char *fname); 68 | int DLLEXPORT MSXsolveH(void); 69 | int DLLEXPORT MSXusehydfile(char *fname); 70 | int DLLEXPORT MSXsolveQ(void); 71 | int DLLEXPORT MSXinit(int saveFlag); 72 | int DLLEXPORT MSXstep(long *t, long *tleft); 73 | int DLLEXPORT MSXsaveoutfile(char *fname); 74 | int DLLEXPORT MSXsavemsxfile(char *fname); 75 | int DLLEXPORT MSXreport(void); 76 | int DLLEXPORT MSXclose(void); 77 | 78 | int DLLEXPORT MSXgetindex(int type, char *id, int *index); 79 | int DLLEXPORT MSXgetIDlen(int type, int index, int *len); 80 | int DLLEXPORT MSXgetID(int type, int index, char *id, int len); 81 | int DLLEXPORT MSXgetcount(int type, int *count); 82 | int DLLEXPORT MSXgetspecies(int index, int *type, char *units, double *aTol, 83 | double *rTol); 84 | int DLLEXPORT MSXgetconstant(int index, double *value); 85 | int DLLEXPORT MSXgetparameter(int type, int index, int param, double *value); 86 | int DLLEXPORT MSXgetsource(int node, int species, int *type, double *level, 87 | int *pat); 88 | int DLLEXPORT MSXgetpatternlen(int pat, int *len); 89 | int DLLEXPORT MSXgetpatternvalue(int pat, int period, double *value); 90 | int DLLEXPORT MSXgetinitqual(int type, int index, int species, double *value); 91 | int DLLEXPORT MSXgetqual(int type, int index, int species, double *value); 92 | int DLLEXPORT MSXgeterror(int code, char *msg, int len); 93 | 94 | int DLLEXPORT MSXsetconstant(int index, double value); 95 | int DLLEXPORT MSXsetparameter(int type, int index, int param, double value); 96 | int DLLEXPORT MSXsetinitqual(int type, int index, int species, double value); 97 | int DLLEXPORT MSXsetsource(int node, int species, int type, double level, 98 | int pat); 99 | int DLLEXPORT MSXsetpatternvalue(int pat, int period, double value); 100 | int DLLEXPORT MSXsetpattern(int pat, double mult[], int len); 101 | int DLLEXPORT MSXaddpattern(char *id); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/glnx/epanet2_enums.h: -------------------------------------------------------------------------------- 1 | /** @file epanet2_enums.h 2 | */ 3 | /* 4 | ****************************************************************************** 5 | Project: OWA EPANET 6 | Version: 2.2 7 | Module: epanet2_enums.h 8 | Description: enumerations of symbolic constants used by the API functions 9 | Authors: see AUTHORS 10 | Copyright: see AUTHORS 11 | License: see LICENSE 12 | Last Updated: 11/06/2019 13 | ****************************************************************************** 14 | */ 15 | 16 | 17 | #ifndef EPANET2_ENUMS_H 18 | #define EPANET2_ENUMS_H 19 | 20 | 21 | // --- Define the EPANET toolkit constants 22 | 23 | /// Size Limts 24 | /** 25 | Limits on the size of character arrays used to store ID names 26 | and text messages. 27 | */ 28 | typedef enum { 29 | EN_MAXID = 31, //!< Max. # characters in ID name 30 | EN_MAXMSG = 255 //!< Max. # characters in message text 31 | } EN_SizeLimits; 32 | 33 | /// Node properties 34 | /** 35 | These node properties are used with @ref EN_getnodevalue and @ref EN_setnodevalue. 36 | Those marked as read only are computed values that can only be retrieved. 37 | */ 38 | typedef enum { 39 | EN_ELEVATION = 0, //!< Elevation 40 | EN_BASEDEMAND = 1, //!< Primary demand baseline value 41 | EN_PATTERN = 2, //!< Primary demand time pattern index 42 | EN_EMITTER = 3, //!< Emitter flow coefficient 43 | EN_INITQUAL = 4, //!< Initial quality 44 | EN_SOURCEQUAL = 5, //!< Quality source strength 45 | EN_SOURCEPAT = 6, //!< Quality source pattern index 46 | EN_SOURCETYPE = 7, //!< Quality source type (see @ref EN_SourceType) 47 | EN_TANKLEVEL = 8, //!< Current computed tank water level (read only) 48 | EN_DEMAND = 9, //!< Current computed demand (read only) 49 | EN_HEAD = 10, //!< Current computed hydraulic head (read only) 50 | EN_PRESSURE = 11, //!< Current computed pressure (read only) 51 | EN_QUALITY = 12, //!< Current computed quality (read only) 52 | EN_SOURCEMASS = 13, //!< Current computed quality source mass inflow (read only) 53 | EN_INITVOLUME = 14, //!< Tank initial volume (read only) 54 | EN_MIXMODEL = 15, //!< Tank mixing model (see @ref EN_MixingModel) 55 | EN_MIXZONEVOL = 16, //!< Tank mixing zone volume (read only) 56 | EN_TANKDIAM = 17, //!< Tank diameter 57 | EN_MINVOLUME = 18, //!< Tank minimum volume 58 | EN_VOLCURVE = 19, //!< Tank volume curve index 59 | EN_MINLEVEL = 20, //!< Tank minimum level 60 | EN_MAXLEVEL = 21, //!< Tank maximum level 61 | EN_MIXFRACTION = 22, //!< Tank mixing fraction 62 | EN_TANK_KBULK = 23, //!< Tank bulk decay coefficient 63 | EN_TANKVOLUME = 24, //!< Current computed tank volume (read only) 64 | EN_MAXVOLUME = 25, //!< Tank maximum volume (read only) 65 | EN_CANOVERFLOW = 26, //!< Tank can overflow (= 1) or not (= 0) 66 | EN_DEMANDDEFICIT = 27 //!< Amount that full demand is reduced under PDA (read only) 67 | } EN_NodeProperty; 68 | 69 | /// Link properties 70 | /** 71 | These link properties are used with @ref EN_getlinkvalue and @ref EN_setlinkvalue. 72 | Those marked as read only are computed values that can only be retrieved. 73 | */ 74 | typedef enum { 75 | EN_DIAMETER = 0, //!< Pipe/valve diameter 76 | EN_LENGTH = 1, //!< Pipe length 77 | EN_ROUGHNESS = 2, //!< Pipe roughness coefficient 78 | EN_MINORLOSS = 3, //!< Pipe/valve minor loss coefficient 79 | EN_INITSTATUS = 4, //!< Initial status (see @ref EN_LinkStatusType) 80 | EN_INITSETTING = 5, //!< Initial pump speed or valve setting 81 | EN_KBULK = 6, //!< Bulk chemical reaction coefficient 82 | EN_KWALL = 7, //!< Pipe wall chemical reaction coefficient 83 | EN_FLOW = 8, //!< Current computed flow rate (read only) 84 | EN_VELOCITY = 9, //!< Current computed flow velocity (read only) 85 | EN_HEADLOSS = 10, //!< Current computed head loss (read only) 86 | EN_STATUS = 11, //!< Current link status (see @ref EN_LinkStatusType) 87 | EN_SETTING = 12, //!< Current link setting 88 | EN_ENERGY = 13, //!< Current computed pump energy usage (read only) 89 | EN_LINKQUAL = 14, //!< Current computed link quality (read only) 90 | EN_LINKPATTERN = 15, //!< Pump speed time pattern index 91 | EN_PUMP_STATE = 16, //!< Current computed pump state (read only) (see @ref EN_PumpStateType) 92 | EN_PUMP_EFFIC = 17, //!< Current computed pump efficiency (read only) 93 | EN_PUMP_POWER = 18, //!< Pump constant power rating 94 | EN_PUMP_HCURVE = 19, //!< Pump head v. flow curve index 95 | EN_PUMP_ECURVE = 20, //!< Pump efficiency v. flow curve index 96 | EN_PUMP_ECOST = 21, //!< Pump average energy price 97 | EN_PUMP_EPAT = 22 //!< Pump energy price time pattern index 98 | } EN_LinkProperty; 99 | 100 | /// Time parameters 101 | /** 102 | These time-related options are used with @ref EN_gettimeparam and@ref EN_settimeparam. 103 | All times are expressed in seconds The parameters marked as read only are 104 | computed values that can only be retrieved. 105 | */ 106 | typedef enum { 107 | EN_DURATION = 0, //!< Total simulation duration 108 | EN_HYDSTEP = 1, //!< Hydraulic time step 109 | EN_QUALSTEP = 2, //!< Water quality time step 110 | EN_PATTERNSTEP = 3, //!< Time pattern period 111 | EN_PATTERNSTART = 4, //!< Time when time patterns begin 112 | EN_REPORTSTEP = 5, //!< Reporting time step 113 | EN_REPORTSTART = 6, //!< Time when reporting starts 114 | EN_RULESTEP = 7, //!< Rule-based control evaluation time step 115 | EN_STATISTIC = 8, //!< Reporting statistic code (see @ref EN_StatisticType) 116 | EN_PERIODS = 9, //!< Number of reporting time periods (read only) 117 | EN_STARTTIME = 10, //!< Simulation starting time of day 118 | EN_HTIME = 11, //!< Elapsed time of current hydraulic solution (read only) 119 | EN_QTIME = 12, //!< Elapsed time of current quality solution (read only) 120 | EN_HALTFLAG = 13, //!< Flag indicating if the simulation was halted (read only) 121 | EN_NEXTEVENT = 14, //!< Shortest time until a tank becomes empty or full (read only) 122 | EN_NEXTEVENTTANK = 15 //!< Index of tank with shortest time to become empty or full (read only) 123 | } EN_TimeParameter; 124 | 125 | /// Analysis convergence statistics 126 | /** 127 | These statistics report the convergence criteria for the most current hydraulic analysis 128 | and the cumulative water quality mass balance error at the current simulation time. They 129 | can be retrieved with @ref EN_getstatistic. 130 | */ 131 | typedef enum { 132 | EN_ITERATIONS = 0, //!< Number of hydraulic iterations taken 133 | EN_RELATIVEERROR = 1, //!< Sum of link flow changes / sum of link flows 134 | EN_MAXHEADERROR = 2, //!< Largest head loss error for links 135 | EN_MAXFLOWCHANGE = 3, //!< Largest flow change in links 136 | EN_MASSBALANCE = 4, //!< Cumulative water quality mass balance ratio 137 | EN_DEFICIENTNODES = 5, //!< Number of pressure deficient nodes 138 | EN_DEMANDREDUCTION = 6 //!< % demand reduction at pressure deficient nodes 139 | } EN_AnalysisStatistic; 140 | 141 | /// Types of network objects 142 | /** 143 | The types of objects that comprise a network model. 144 | */ 145 | typedef enum { 146 | EN_NODE = 0, //!< Nodes 147 | EN_LINK = 1, //!< Links 148 | EN_TIMEPAT = 2, //!< Time patterns 149 | EN_CURVE = 3, //!< Data curves 150 | EN_CONTROL = 4, //!< Simple controls 151 | EN_RULE = 5 //!< Control rules 152 | } EN_ObjectType; 153 | 154 | /// Types of objects to count 155 | /** 156 | These options tell @ref EN_getcount which type of object to count. 157 | */ 158 | typedef enum { 159 | EN_NODECOUNT = 0, //!< Number of nodes (junctions + tanks + reservoirs) 160 | EN_TANKCOUNT = 1, //!< Number of tanks and reservoirs 161 | EN_LINKCOUNT = 2, //!< Number of links (pipes + pumps + valves) 162 | EN_PATCOUNT = 3, //!< Number of time patterns 163 | EN_CURVECOUNT = 4, //!< Number of data curves 164 | EN_CONTROLCOUNT = 5, //!< Number of simple controls 165 | EN_RULECOUNT = 6 //!< Number of rule-based controls 166 | } EN_CountType; 167 | 168 | /// Node Types 169 | /** 170 | These are the different types of nodes that can be returned by calling @ref EN_getnodetype. 171 | */ 172 | typedef enum { 173 | EN_JUNCTION = 0, //!< Junction node 174 | EN_RESERVOIR = 1, //!< Reservoir node 175 | EN_TANK = 2 //!< Storage tank node 176 | } EN_NodeType; 177 | 178 | /// Link types 179 | /** 180 | These are the different types of links that can be returned by calling @ref EN_getlinktype. 181 | */ 182 | typedef enum { 183 | EN_CVPIPE = 0, //!< Pipe with check valve 184 | EN_PIPE = 1, //!< Pipe 185 | EN_PUMP = 2, //!< Pump 186 | EN_PRV = 3, //!< Pressure reducing valve 187 | EN_PSV = 4, //!< Pressure sustaining valve 188 | EN_PBV = 5, //!< Pressure breaker valve 189 | EN_FCV = 6, //!< Flow control valve 190 | EN_TCV = 7, //!< Throttle control valve 191 | EN_GPV = 8 //!< General purpose valve 192 | } EN_LinkType; 193 | 194 | /// Link status 195 | /** 196 | One of these values is returned when @ref EN_getlinkvalue is used to retrieve a link's 197 | initial status ( \b EN_INITSTATUS ) or its current status ( \b EN_STATUS ). These options are 198 | also used with @ref EN_setlinkvalue to set values for these same properties. 199 | */ 200 | typedef enum { 201 | EN_CLOSED = 0, 202 | EN_OPEN = 1 203 | } EN_LinkStatusType; 204 | 205 | /// Pump states 206 | /** 207 | One of these codes is returned when @ref EN_getlinkvalue is used to retrieve a pump's 208 | current operating state ( \b EN_PUMP_STATE ). \b EN_PUMP_XHEAD indicates that the pump has been 209 | shut down because it is being asked to deliver more than its shutoff head. \b EN_PUMP_XFLOW 210 | indicates that the pump is being asked to deliver more than its maximum flow. 211 | */ 212 | typedef enum { 213 | EN_PUMP_XHEAD = 0, //!< Pump closed - cannot supply head 214 | EN_PUMP_CLOSED = 2, //!< Pump closed 215 | EN_PUMP_OPEN = 3, //!< Pump open 216 | EN_PUMP_XFLOW = 5 //!< Pump open - cannot supply flow 217 | } EN_PumpStateType; 218 | 219 | /// Types of water quality analyses 220 | /** 221 | These are the different types of water quality analyses that EPANET can run. They 222 | are used with @ref EN_getqualinfo, @ref EN_getqualtype, and @ref EN_setqualtype. 223 | */ 224 | typedef enum { 225 | EN_NONE = 0, //!< No quality analysis 226 | EN_CHEM = 1, //!< Chemical fate and transport 227 | EN_AGE = 2, //!< Water age analysis 228 | EN_TRACE = 3 //!< Source tracing analysis 229 | } EN_QualityType; 230 | 231 | /// Water quality source types 232 | /** 233 | These are the different types of external water quality sources that can be assigned 234 | to a node's \b EN_SOURCETYPE property as used by @ref EN_getnodevalue and @ref EN_setnodevalue. 235 | */ 236 | typedef enum { 237 | EN_CONCEN = 0, //!< Sets the concentration of external inflow entering a node 238 | EN_MASS = 1, //!< Injects a given mass/minute into a node 239 | EN_SETPOINT = 2, //!< Sets the concentration leaving a node to a given value 240 | EN_FLOWPACED = 3 //!< Adds a given value to the concentration leaving a node 241 | } EN_SourceType; 242 | 243 | /// Head loss formulas 244 | /** 245 | The available choices for the \b EN_HEADLOSSFORM option in @ref EN_getoption and 246 | @ref EN_setoption. They are also used for the head loss type argument in @ref EN_init. 247 | Each head loss formula uses a different type of roughness coefficient ( \b EN_ROUGHNESS ) 248 | that can be set with @ref EN_setlinkvalue. 249 | */ 250 | typedef enum { 251 | EN_HW = 0, //!< Hazen-Williams 252 | EN_DW = 1, //!< Darcy-Weisbach 253 | EN_CM = 2 //!< Chezy-Manning 254 | } EN_HeadLossType; 255 | 256 | /// Flow units 257 | /** 258 | These choices for flow units are used with @ref EN_getflowunits and @ref EN_setflowunits. 259 | They are also used for the flow units type argument in @ref EN_init. If flow units are 260 | expressed in US Customary units ( \b EN_CFS through \b EN_AFD ) then all other quantities are 261 | in US Customary units. Otherwise they are in metric units. 262 | */ 263 | typedef enum { 264 | EN_CFS = 0, //!< Cubic feet per second 265 | EN_GPM = 1, //!< Gallons per minute 266 | EN_MGD = 2, //!< Million gallons per day 267 | EN_IMGD = 3, //!< Imperial million gallons per day 268 | EN_AFD = 4, //!< Acre-feet per day 269 | EN_LPS = 5, //!< Liters per second 270 | EN_LPM = 6, //!< Liters per minute 271 | EN_MLD = 7, //!< Million liters per day 272 | EN_CMH = 8, //!< Cubic meters per hour 273 | EN_CMD = 9 //!< Cubic meters per day 274 | } EN_FlowUnits; 275 | 276 | /// Demand models 277 | /** 278 | These choices for modeling consumer demands are used with @ref EN_getdemandmodel 279 | and @ref EN_setdemandmodel. 280 | 281 | A demand driven analysis requires that a junction's full demand be supplied 282 | in each time period independent of how much pressure is available. A pressure 283 | driven analysis makes demand be a power function of pressure, up to the point 284 | where the full demand is met. 285 | */ 286 | typedef enum { 287 | EN_DDA = 0, //!< Demand driven analysis 288 | EN_PDA = 1 //!< Pressure driven analysis 289 | } EN_DemandModel; 290 | 291 | /// Simulation options 292 | /** 293 | These constants identify the hydraulic and water quality simulation options 294 | that are applied on a network-wide basis. They are accessed using the 295 | @ref EN_getoption and @ref EN_setoption functions. 296 | */ 297 | typedef enum { 298 | EN_TRIALS = 0, //!< Maximum trials allowed for hydraulic convergence 299 | EN_ACCURACY = 1, //!< Total normalized flow change for hydraulic convergence 300 | EN_TOLERANCE = 2, //!< Water quality tolerance 301 | EN_EMITEXPON = 3, //!< Exponent in emitter discharge formula 302 | EN_DEMANDMULT = 4, //!< Global demand multiplier 303 | EN_HEADERROR = 5, //!< Maximum head loss error for hydraulic convergence 304 | EN_FLOWCHANGE = 6, //!< Maximum flow change for hydraulic convergence 305 | EN_HEADLOSSFORM = 7, //!< Head loss formula (see @ref EN_HeadLossType) 306 | EN_GLOBALEFFIC = 8, //!< Global pump efficiency (percent) 307 | EN_GLOBALPRICE = 9, //!< Global energy price per KWH 308 | EN_GLOBALPATTERN = 10, //!< Index of a global energy price pattern 309 | EN_DEMANDCHARGE = 11, //!< Energy charge per max. KW usage 310 | EN_SP_GRAVITY = 12, //!< Specific gravity 311 | EN_SP_VISCOS = 13, //!< Specific viscosity (relative to water at 20 deg C) 312 | EN_UNBALANCED = 14, //!< Extra trials allowed if hydraulics don't converge 313 | EN_CHECKFREQ = 15, //!< Frequency of hydraulic status checks 314 | EN_MAXCHECK = 16, //!< Maximum trials for status checking 315 | EN_DAMPLIMIT = 17, //!< Accuracy level where solution damping begins 316 | EN_SP_DIFFUS = 18, //!< Specific diffusivity (relative to chlorine at 20 deg C) 317 | EN_BULKORDER = 19, //!< Bulk water reaction order for pipes 318 | EN_WALLORDER = 20, //!< Wall reaction order for pipes (either 0 or 1) 319 | EN_TANKORDER = 21, //!< Bulk water reaction order for tanks 320 | EN_CONCENLIMIT = 22 //!< Limiting concentration for growth reactions 321 | } EN_Option; 322 | 323 | /// Simple control types 324 | /** 325 | These are the different types of simple (single statement) controls that can be applied 326 | to network links. They are used as an argument to @ref EN_addcontrol,@ref EN_getcontrol, 327 | and @ref EN_setcontrol. 328 | */ 329 | typedef enum { 330 | EN_LOWLEVEL = 0, //!< Act when pressure or tank level drops below a setpoint 331 | EN_HILEVEL = 1, //!< Act when pressure or tank level rises above a setpoint 332 | EN_TIMER = 2, //!< Act at a prescribed elapsed amount of time 333 | EN_TIMEOFDAY = 3 //!< Act at a particular time of day 334 | } EN_ControlType; 335 | 336 | /// Reporting statistic choices 337 | /** 338 | These options determine what kind of statistical post-processing should be done on 339 | the time series of simulation results generated before they are reported using 340 | @ref EN_report. An option can be chosen by using \b STATISTIC _option_ as the argument 341 | to @ref EN_setreport. 342 | */ 343 | typedef enum { 344 | EN_SERIES = 0, //!< Report all time series points 345 | EN_AVERAGE = 1, //!< Report average value over simulation period 346 | EN_MINIMUM = 2, //!< Report minimum value over simulation period 347 | EN_MAXIMUM = 3, //!< Report maximum value over simulation period 348 | EN_RANGE = 4 //!< Report maximum - minimum over simulation period 349 | } EN_StatisticType; 350 | 351 | /// Tank mixing models 352 | /** 353 | These are the different types of models that describe water quality mixing in storage tanks. 354 | The choice of model is accessed with the \b EN_MIXMODEL property of a Tank node using 355 | @ref EN_getnodevalue and @ref EN_setnodevalue. 356 | */ 357 | typedef enum { 358 | EN_MIX1 = 0, //!< Complete mix model 359 | EN_MIX2 = 1, //!< 2-compartment model 360 | EN_FIFO = 2, //!< First in, first out model 361 | EN_LIFO = 3 //!< Last in, first out model 362 | } EN_MixingModel; 363 | 364 | /// Hydraulic initialization options 365 | /** 366 | These options are used to initialize a new hydraulic analysis when @ref EN_initH is called. 367 | */ 368 | typedef enum { 369 | EN_NOSAVE = 0, //!< Don't save hydraulics; don't re-initialize flows 370 | EN_SAVE = 1, //!< Save hydraulics to file, don't re-initialize flows 371 | EN_INITFLOW = 10, //!< Don't save hydraulics; re-initialize flows 372 | EN_SAVE_AND_INIT = 11 //!< Save hydraulics; re-initialize flows 373 | } EN_InitHydOption; 374 | 375 | /// Types of pump curves 376 | /** 377 | @ref EN_getpumptype returns one of these values when it is called. 378 | */ 379 | typedef enum { 380 | EN_CONST_HP = 0, //!< Constant horsepower 381 | EN_POWER_FUNC = 1, //!< Power function 382 | EN_CUSTOM = 2, //!< User-defined custom curve 383 | EN_NOCURVE = 3 //!< No curve 384 | } EN_PumpType; 385 | 386 | /// Types of data curves 387 | /** 388 | These are the different types of physical relationships that a data curve can 389 | represent as returned by calling @ref EN_getcurvetype. 390 | */ 391 | typedef enum { 392 | EN_VOLUME_CURVE = 0, //!< Tank volume v. depth curve 393 | EN_PUMP_CURVE = 1, //!< Pump head v. flow curve 394 | EN_EFFIC_CURVE = 2, //!< Pump efficiency v. flow curve 395 | EN_HLOSS_CURVE = 3, //!< Valve head loss v. flow curve 396 | EN_GENERIC_CURVE = 4 //!< Generic curve 397 | } EN_CurveType; 398 | 399 | /// Deletion action codes 400 | /** 401 | These codes are used in @ref EN_deletenode and @ref EN_deletelink to indicate what action 402 | should be taken if the node or link being deleted appears in any simple or rule-based 403 | controls or if a deleted node has any links connected to it. 404 | */ 405 | typedef enum { 406 | EN_UNCONDITIONAL = 0, //!< Delete all controls and connecing links 407 | EN_CONDITIONAL = 1 //!< Cancel object deletion if it appears in controls or has connecting links 408 | } EN_ActionCodeType; 409 | 410 | /// Status reporting levels 411 | /** 412 | These choices specify the level of status reporting written to a project's report 413 | file during a hydraulic analysis. The level is set using the @ref EN_setstatusreport function. 414 | */ 415 | typedef enum { 416 | EN_NO_REPORT = 0, //!< No status reporting 417 | EN_NORMAL_REPORT = 1, //!< Normal level of status reporting 418 | EN_FULL_REPORT = 2 //!< Full level of status reporting 419 | } EN_StatusReport; 420 | 421 | /// Network objects used in rule-based controls 422 | typedef enum { 423 | EN_R_NODE = 6, //!< Clause refers to a node 424 | EN_R_LINK = 7, //!< Clause refers to a link 425 | EN_R_SYSTEM = 8 //!< Clause refers to a system parameter (e.g., time) 426 | } EN_RuleObject; 427 | 428 | /// Object variables used in rule-based controls 429 | typedef enum { 430 | EN_R_DEMAND = 0, //!< Nodal demand 431 | EN_R_HEAD = 1, //!< Nodal hydraulic head 432 | EN_R_GRADE = 2, //!< Nodal hydraulic grade 433 | EN_R_LEVEL = 3, //!< Tank water level 434 | EN_R_PRESSURE = 4, //!< Nodal pressure 435 | EN_R_FLOW = 5, //!< Link flow rate 436 | EN_R_STATUS = 6, //!< Link status 437 | EN_R_SETTING = 7, //!< Link setting 438 | EN_R_POWER = 8, //!< Pump power output 439 | EN_R_TIME = 9, //!< Elapsed simulation time 440 | EN_R_CLOCKTIME = 10, //!< Time of day 441 | EN_R_FILLTIME = 11, //!< Time to fill a tank 442 | EN_R_DRAINTIME = 12 //!< Time to drain a tank 443 | } EN_RuleVariable; 444 | 445 | /// Comparison operators used in rule-based controls 446 | typedef enum { 447 | EN_R_EQ = 0, //!< Equal to 448 | EN_R_NE = 1, //!< Not equal 449 | EN_R_LE = 2, //!< Less than or equal to 450 | EN_R_GE = 3, //!< Greater than or equal to 451 | EN_R_LT = 4, //!< Less than 452 | EN_R_GT = 5, //!< Greater than 453 | EN_R_IS = 6, //!< Is equal to 454 | EN_R_NOT = 7, //!< Is not equal to 455 | EN_R_BELOW = 8, //!< Is below 456 | EN_R_ABOVE = 9 //!< Is above 457 | } EN_RuleOperator; 458 | 459 | /// Link status codes used in rule-based controls 460 | typedef enum { 461 | EN_R_IS_OPEN = 1, //!< Link is open 462 | EN_R_IS_CLOSED = 2, //!< Link is closed 463 | EN_R_IS_ACTIVE = 3 //!< Control valve is active 464 | } EN_RuleStatus; 465 | 466 | #define EN_MISSING -1.E10 //!< Missing value indicator 467 | 468 | #endif //EPANET2_ENUMS_H 469 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/glnx/libepanet.h: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | Project: OWA EPANET 4 | Version: 2.2 5 | Module: epanet2.h 6 | Description: declarations of the legacy style EPANET 2 API functions 7 | Authors: see AUTHORS 8 | Copyright: see AUTHORS 9 | License: see LICENSE 10 | Last Updated: 10/29/2019 11 | ****************************************************************************** 12 | */ 13 | 14 | /* 15 | This module contains declarations of the legacy style EPANET API functions, with 16 | version 2.2 updates, that apply only to single threaded applications. A second 17 | set of thread safe API functions that allows one to run concurrent analyses on 18 | multiple EPANET projects can be found in the epanet2_2.h header file. The two 19 | APIs share the same function names and arguments with the difference being that 20 | the thread safe functions use the prefix "EN_" and include an extra argument that 21 | represents the EPANET project being analyzed. To avoid unneccesary repetition, 22 | only the thread safe API functions have been documented. To see a description of 23 | a legacy style API function declared here please refer to its complementary named 24 | function in epanet2_2.h. 25 | */ 26 | 27 | #ifndef EPANET2_H 28 | #define EPANET2_H 29 | 30 | // The legacy style EPANET API can be compiled with support for either single 31 | // precision or double precision floating point arguments, with the default 32 | // being single precision. To compile for double precision one must #define 33 | // EN_API_FLOAT_TYPE as double both here and in any client code that uses the 34 | // API. 35 | #ifndef EN_API_FLOAT_TYPE 36 | #define EN_API_FLOAT_TYPE float 37 | #endif 38 | 39 | #ifndef DLLEXPORT 40 | #ifdef _WIN32 41 | #ifdef epanet2_EXPORTS 42 | #define DLLEXPORT __declspec(dllexport) __stdcall 43 | #else 44 | #define DLLEXPORT __declspec(dllimport) __stdcall 45 | #endif 46 | #elif defined(__CYGWIN__) 47 | #define DLLEXPORT __stdcall 48 | #else 49 | #define DLLEXPORT 50 | #endif 51 | #endif 52 | 53 | #include "epanet2_enums.h" 54 | 55 | // --- Declare the EPANET toolkit functions 56 | #if defined(__cplusplus) 57 | extern "C" { 58 | #endif 59 | 60 | 61 | /******************************************************************** 62 | 63 | Project Functions 64 | 65 | ********************************************************************/ 66 | 67 | int DLLEXPORT ENepanet(const char *inpFile, const char *rptFile, 68 | const char *outFile, void (*pviewprog) (char *)); 69 | 70 | int DLLEXPORT ENinit(const char *rptFile, const char *outFile, 71 | int unitsType, int headlossType); 72 | 73 | int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, 74 | const char *outFile); 75 | 76 | int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3); 77 | 78 | int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3); 79 | 80 | int DLLEXPORT ENgetcomment(int object, int index, char *comment); 81 | 82 | int DLLEXPORT ENsetcomment(int object, int index, char *comment); 83 | 84 | int DLLEXPORT ENgetcount(int object, int *count); 85 | 86 | int DLLEXPORT ENsaveinpfile(const char *filename); 87 | 88 | int DLLEXPORT ENclose(); 89 | 90 | /******************************************************************** 91 | 92 | Hydraulic Analysis Functions 93 | 94 | ********************************************************************/ 95 | 96 | int DLLEXPORT ENsolveH(); 97 | 98 | int DLLEXPORT ENsaveH(); 99 | 100 | int DLLEXPORT ENopenH(); 101 | 102 | int DLLEXPORT ENinitH(int initFlag); 103 | 104 | int DLLEXPORT ENrunH(long *currentTime); 105 | 106 | int DLLEXPORT ENnextH(long *tStep); 107 | 108 | int DLLEXPORT ENcloseH(); 109 | 110 | int DLLEXPORT ENsavehydfile(char *filename); 111 | 112 | int DLLEXPORT ENusehydfile(char *filename); 113 | 114 | /******************************************************************** 115 | 116 | Water Quality Analysis Functions 117 | 118 | ********************************************************************/ 119 | 120 | int DLLEXPORT ENsolveQ(); 121 | 122 | int DLLEXPORT ENopenQ(); 123 | 124 | int DLLEXPORT ENinitQ(int saveFlag); 125 | 126 | int DLLEXPORT ENrunQ(long *currentTime); 127 | 128 | int DLLEXPORT ENnextQ(long *tStep); 129 | 130 | int DLLEXPORT ENstepQ(long *timeLeft); 131 | 132 | int DLLEXPORT ENcloseQ(); 133 | 134 | /******************************************************************** 135 | 136 | Reporting Functions 137 | 138 | ********************************************************************/ 139 | 140 | int DLLEXPORT ENwriteline(char *line); 141 | 142 | int DLLEXPORT ENreport(); 143 | 144 | int DLLEXPORT ENcopyreport(char *filename); 145 | 146 | int DLLEXPORT ENclearreport(); 147 | 148 | int DLLEXPORT ENresetreport(); 149 | 150 | int DLLEXPORT ENsetreport(char *format); 151 | 152 | int DLLEXPORT ENsetstatusreport(int level); 153 | 154 | int DLLEXPORT ENgetversion(int *version); 155 | 156 | int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen); 157 | 158 | int DLLEXPORT ENgetstatistic(int type, EN_API_FLOAT_TYPE* value); 159 | 160 | int DLLEXPORT ENgetresultindex(int type, int index, int *value); 161 | 162 | /******************************************************************** 163 | 164 | Analysis Options Functions 165 | 166 | ********************************************************************/ 167 | 168 | int DLLEXPORT ENgetoption(int option, EN_API_FLOAT_TYPE *value); 169 | 170 | int DLLEXPORT ENsetoption(int option, EN_API_FLOAT_TYPE value); 171 | 172 | int DLLEXPORT ENgetflowunits(int *units); 173 | 174 | int DLLEXPORT ENsetflowunits(int units); 175 | 176 | int DLLEXPORT ENgettimeparam(int param, long *value); 177 | 178 | int DLLEXPORT ENsettimeparam(int param, long value); 179 | 180 | int DLLEXPORT ENgetqualinfo(int *qualType, char *chemName, char *chemUnits, 181 | int *traceNode); 182 | 183 | int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode); 184 | 185 | int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits, 186 | char *traceNode); 187 | 188 | /******************************************************************** 189 | 190 | Node Functions 191 | 192 | ********************************************************************/ 193 | 194 | int DLLEXPORT ENaddnode(char *id, int nodeType, int *index); 195 | 196 | int DLLEXPORT ENdeletenode(int index, int actionCode); 197 | 198 | int DLLEXPORT ENgetnodeindex(char *id, int *index); 199 | 200 | int DLLEXPORT ENgetnodeid(int index, char *id); 201 | 202 | int DLLEXPORT ENsetnodeid(int index, char *newid); 203 | 204 | int DLLEXPORT ENgetnodetype(int index, int *nodeType); 205 | 206 | int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value); 207 | 208 | int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value); 209 | 210 | int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, 211 | EN_API_FLOAT_TYPE dmnd, char *dmndpat); 212 | 213 | int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, 214 | EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl, 215 | EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam, 216 | EN_API_FLOAT_TYPE minvol, char *volcurve); 217 | 218 | int DLLEXPORT ENgetcoord(int index, double *x, double *y); 219 | 220 | int DLLEXPORT ENsetcoord(int index, double x, double y); 221 | 222 | /******************************************************************** 223 | 224 | Nodal Demand Functions 225 | 226 | ********************************************************************/ 227 | 228 | int DLLEXPORT ENgetdemandmodel(int *model, EN_API_FLOAT_TYPE *pmin, 229 | EN_API_FLOAT_TYPE *preq, EN_API_FLOAT_TYPE *pexp); 230 | 231 | int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin, 232 | EN_API_FLOAT_TYPE preq, EN_API_FLOAT_TYPE pexp); 233 | 234 | int DLLEXPORT ENadddemand(int nodeIndex, EN_API_FLOAT_TYPE baseDemand, 235 | char *demandPattern, char *demandName); 236 | 237 | int DLLEXPORT ENdeletedemand(int nodeIndex, int demandIndex); 238 | 239 | int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands); 240 | 241 | int DLLEXPORT ENgetdemandindex(int nodeIndex, char *demandName, int *demandIndex); 242 | 243 | int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIndex, 244 | EN_API_FLOAT_TYPE *baseDemand); 245 | 246 | int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIndex, 247 | EN_API_FLOAT_TYPE baseDemand); 248 | 249 | int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIndex, int *patIndex); 250 | 251 | int DLLEXPORT ENsetdemandpattern(int nodeIndex, int demandIndex, int patIndex); 252 | 253 | int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName); 254 | 255 | int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName); 256 | 257 | /******************************************************************** 258 | 259 | Link Functions 260 | 261 | ********************************************************************/ 262 | 263 | int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index); 264 | 265 | int DLLEXPORT ENdeletelink(int index, int actionCode); 266 | 267 | int DLLEXPORT ENgetlinkindex(char *id, int *index); 268 | 269 | int DLLEXPORT ENgetlinkid(int index, char *id); 270 | 271 | int DLLEXPORT ENsetlinkid(int index, char *newid); 272 | 273 | int DLLEXPORT ENgetlinktype(int index, int *linkType); 274 | 275 | int DLLEXPORT ENsetlinktype(int *index, int linkType, int actionCode); 276 | 277 | int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2); 278 | 279 | int DLLEXPORT ENsetlinknodes(int index, int node1, int node2); 280 | 281 | int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value); 282 | 283 | int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value); 284 | 285 | int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, 286 | EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, 287 | EN_API_FLOAT_TYPE mloss); 288 | 289 | int DLLEXPORT ENgetvertexcount(int index, int *count); 290 | 291 | int DLLEXPORT ENgetvertex(int index, int vertex, double *x, double *y); 292 | 293 | int DLLEXPORT ENsetvertices(int index, double *x, double *y, int count); 294 | 295 | /******************************************************************** 296 | 297 | Pump Functions 298 | 299 | ********************************************************************/ 300 | 301 | int DLLEXPORT ENgetpumptype(int linkIndex, int *pumpType); 302 | 303 | int DLLEXPORT ENgetheadcurveindex(int linkIndex, int *curveIndex); 304 | 305 | int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex); 306 | 307 | /******************************************************************** 308 | 309 | Time Pattern Functions 310 | 311 | ********************************************************************/ 312 | 313 | int DLLEXPORT ENaddpattern(char *id); 314 | 315 | int DLLEXPORT ENdeletepattern(int index); 316 | 317 | int DLLEXPORT ENgetpatternindex(char *id, int *index); 318 | 319 | int DLLEXPORT ENgetpatternid(int index, char *id); 320 | 321 | int DLLEXPORT ENsetpatternid(int index, char *id); 322 | 323 | int DLLEXPORT ENgetpatternlen(int index, int *len); 324 | 325 | int DLLEXPORT ENgetpatternvalue(int index, int period, EN_API_FLOAT_TYPE *value); 326 | 327 | int DLLEXPORT ENsetpatternvalue(int index, int period, EN_API_FLOAT_TYPE value); 328 | 329 | int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); 330 | 331 | int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len); 332 | 333 | /******************************************************************** 334 | 335 | Data Curve Functions 336 | 337 | ********************************************************************/ 338 | 339 | int DLLEXPORT ENaddcurve(char *id); 340 | 341 | int DLLEXPORT ENdeletecurve(int index); 342 | 343 | int DLLEXPORT ENgetcurveindex(char *id, int *index); 344 | 345 | int DLLEXPORT ENgetcurveid(int index, char *id); 346 | 347 | int DLLEXPORT ENsetcurveid(int index, char *id); 348 | 349 | int DLLEXPORT ENgetcurvelen(int index, int *len); 350 | 351 | int DLLEXPORT ENgetcurvetype(int index, int *type); 352 | 353 | int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, 354 | EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y); 355 | 356 | int DLLEXPORT ENsetcurvevalue(int curveIndex, int pointIndex, 357 | EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y); 358 | 359 | int DLLEXPORT ENgetcurve(int index, char* id, int *nPoints, 360 | EN_API_FLOAT_TYPE *xValues, EN_API_FLOAT_TYPE *yValues); 361 | 362 | int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues, 363 | EN_API_FLOAT_TYPE *yValues, int nPoints); 364 | 365 | /******************************************************************** 366 | 367 | Simple Controls Functions 368 | 369 | ********************************************************************/ 370 | 371 | int DLLEXPORT ENaddcontrol(int type, int linkIndex, EN_API_FLOAT_TYPE setting, 372 | int nodeIndex, EN_API_FLOAT_TYPE level, int *index); 373 | 374 | int DLLEXPORT ENdeletecontrol(int index); 375 | 376 | int DLLEXPORT ENgetcontrol(int index, int *type, int *linkIndex, 377 | EN_API_FLOAT_TYPE *setting, int *nodeIndex, EN_API_FLOAT_TYPE *level); 378 | 379 | int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex, 380 | EN_API_FLOAT_TYPE setting, int nodeIndex, EN_API_FLOAT_TYPE level); 381 | 382 | 383 | /******************************************************************** 384 | 385 | Rule-Based Controls Functions 386 | 387 | ********************************************************************/ 388 | 389 | int DLLEXPORT ENaddrule(char *rule); 390 | 391 | int DLLEXPORT ENdeleterule(int index); 392 | 393 | int DLLEXPORT ENgetrule(int index, int *nPremises, int *nThenActions, 394 | int *nElseActions, EN_API_FLOAT_TYPE *priority); 395 | 396 | int DLLEXPORT ENgetruleID(int index, char* id); 397 | 398 | int DLLEXPORT ENgetpremise(int ruleIndex, int premiseIndex, int *logop, 399 | int *object, int *objIndex, int *variable, 400 | int *relop, int *status, EN_API_FLOAT_TYPE *value); 401 | 402 | int DLLEXPORT ENsetpremise(int ruleIndex, int premiseIndex, int logop, 403 | int object, int objIndex, int variable, int relop, 404 | int status, EN_API_FLOAT_TYPE value); 405 | 406 | int DLLEXPORT ENsetpremiseindex(int ruleIndex, int premiseIndex, int objIndex); 407 | 408 | int DLLEXPORT ENsetpremisestatus(int ruleIndex, int premiseIndex, int status); 409 | 410 | int DLLEXPORT ENsetpremisevalue(int ruleIndex, int premiseIndex, 411 | EN_API_FLOAT_TYPE value); 412 | 413 | int DLLEXPORT ENgetthenaction(int ruleIndex, int actionIndex, int *linkIndex, 414 | int *status, EN_API_FLOAT_TYPE *setting); 415 | 416 | int DLLEXPORT ENsetthenaction(int ruleIndex, int actionIndex, int linkIndex, 417 | int status, EN_API_FLOAT_TYPE setting); 418 | 419 | int DLLEXPORT ENgetelseaction(int ruleIndex, int actionIndex, int *linkIndex, 420 | int *status, EN_API_FLOAT_TYPE *setting); 421 | 422 | int DLLEXPORT ENsetelseaction(int ruleIndex, int actionIndex, int linkIndex, 423 | int status, EN_API_FLOAT_TYPE setting); 424 | 425 | int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority); 426 | 427 | #if defined(__cplusplus) 428 | } 429 | #endif 430 | 431 | #endif //EPANET2_H 432 | -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/glnx/libepanet.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/glnx/libepanet.so -------------------------------------------------------------------------------- /Scoring Algorithm/epanet_matlab/glnx/runepanet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/epanet_matlab/glnx/runepanet -------------------------------------------------------------------------------- /Scoring Algorithm/functions/EPAsimulation.m: -------------------------------------------------------------------------------- 1 | function [Q, H, CL] = EPAsimulation(inpname) 2 | %load network 3 | d=epanet(inpname); 4 | allParameters=d.getComputedTimeSeries; 5 | H = allParameters.Head; 6 | d.unload 7 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/barvalues.m: -------------------------------------------------------------------------------- 1 | function varargout = barvalues(h,precision) 2 | % BARVALUES Display bar values ontop of bars in bar or histogram plot. 3 | % SYNTAX: 4 | % barvalues; - operates on currnet axes. 5 | % barvalues(h); - operates on h. 6 | % barvalues(_,precision); - additionaly, specifies the precision of 7 | % displayed values. or format. 8 | % t = barvalues(_,_); - returns the handles to the value text objects. 9 | % 10 | % h - handle to axes or bar (operates on specified object only) 11 | % or figure (operates on all child axes). 12 | % 13 | % precision - Decimal precision to display (0-10), 14 | % or 'formatSpec' as in num2str. (default:'% .0f') 15 | % 16 | % t - handles to the text objects. 17 | % 18 | % For more information about 'formatSpec': 19 | % See also NUM2STR. 20 | 21 | %Author: Elimelech Schreiber, 11/2017 22 | % ver 2.1 - updated 04/2018 23 | 24 | t=[]; 25 | 26 | if nargin>1 && ~isempty(precision) % Parse precision 27 | if isnumeric(precision) && precision >=0 && precision <=10 28 | precision =['% .',int2str(precision),'f']; 29 | elseif ~ischar(precision) && ~isstring(precision) 30 | error('Precision format unsupported.'); 31 | end 32 | else 33 | precision ='% .0f'; 34 | end 35 | 36 | if nargin<1 || isempty(h) % parse h (handle) 37 | h =gca; 38 | elseif isaType(h,'figure') 39 | B = findobj(h,'type','bar','-or','type','Histogram'); % apply to multiple axes in figure. 40 | for b =B' 41 | t = [t; {barvalues(b,precision)}]; % Return array of text objects 42 | % for each bar plot. 43 | end 44 | if nargout>0 45 | varargout{1}=t; 46 | end 47 | return; 48 | end 49 | if isaType(h,'axes') 50 | h = findobj(h,'type','bar','-or','type','Histogram','-or','type','patch'); 51 | if isempty(h) 52 | return; % silently. to support multiple axes in figure. 53 | end 54 | end 55 | h = h(isaType(h,'bar') | isaType(h,'patch') | isaType(h,'histogram')); 56 | if isempty(h) 57 | error('Cannot find bar plot.'); 58 | end 59 | if size(h,1)>size(h,2) 60 | h=h'; 61 | end 62 | for hn = h 63 | axes(ancestor(hn,'axes')); % make intended axes curent. 64 | if isaType(hn,'histogram') 65 | t =[t; histvalues(hn,precision)]; 66 | continue; 67 | end 68 | if isfield(hn,'XOffset')&&~isempty(hn.XOffset) 69 | XOffset = hn.XOffset; 70 | else 71 | XOffset = 0; 72 | end 73 | if isfield(hn,'YOffset')&&~isempty(hn.YOffset) 74 | YOffset = hn.YOffset; 75 | else 76 | YOffset = 0; 77 | end 78 | xData = hn.XData +XOffset; 79 | yData = hn.YData +YOffset; 80 | if size(xData,1)==4 81 | xData=mean(xData); 82 | yData=yData(2,:); 83 | end 84 | t = [t; text(xData,yData,... %position 85 | arrayfun(@(x)num2str(x,precision),yData,'UniformOutput' ,false),... %text to display 86 | 'HorizontalAlignment','center','VerticalAlignment','bottom')]; 87 | end 88 | if nargout>0 89 | varargout{1}=t; 90 | end 91 | 92 | function flag =isaType(h,type) 93 | try 94 | flag =strcmpi(get(h, 'type'), type); 95 | catch 96 | flag =false; 97 | end 98 | 99 | 100 | function flag = isfield(h,fld) 101 | flag =true; 102 | try 103 | get(h,fld); 104 | catch 105 | flag =false; 106 | end 107 | 108 | 109 | function t =histvalues(h,precision) 110 | hn=h; 111 | axes(ancestor(hn,'axes')); % make intended axes curent. 112 | % if isfield(hn,'XOffset')&&~isempty(hn.XOffset), XOffset = hn.XOffset; else XOffset = 0; end 113 | % if isfield(hn,'YOffset')&&~isempty(hn.YOffset), YOffset = hn.YOffset; else YOffset = 0; end 114 | xData = (hn.BinEdges(1:end-1) + hn.BinEdges(2:end))/2; yData = hn.Values; 115 | 116 | t = text(xData,yData,... %position 117 | arrayfun(@(x)num2str(x,precision),yData,'UniformOutput' ,false),... %text to display 118 | 'HorizontalAlignment','center','VerticalAlignment','bottom'); -------------------------------------------------------------------------------- /Scoring Algorithm/functions/chooseDataFile.m: -------------------------------------------------------------------------------- 1 | function [filename] = chooseDataFile(num) 2 | %% choose a network to load from networks folder 3 | clc 4 | dirName = [pwd,'\results_mat\*.mat']; 5 | Allinpnames = dir(dirName); 6 | 7 | if isempty(num) 8 | disp(sprintf('\nChoose data file:')) 9 | for i=1:length(Allinpnames) 10 | disp([num2str(i),'. ', Allinpnames(i).name]) 11 | end 12 | x = input(sprintf('\nEnter File Number: ')); 13 | else 14 | x = num; 15 | end 16 | filename=['results_mat\',Allinpnames(x).name]; 17 | end 18 | 19 | -------------------------------------------------------------------------------- /Scoring Algorithm/functions/chooseNetwork.m: -------------------------------------------------------------------------------- 1 | function [inpname,dispname] = chooseNetwork(net_num) 2 | %% choose a network to load from networks folder 3 | clc 4 | dirName = [pwd,'\networks\*.inp']; 5 | Allinpnames = dir(dirName); 6 | 7 | if isempty(net_num) 8 | disp(sprintf('\nChoose Water Network:')) 9 | for i=1:length(Allinpnames) 10 | disp([num2str(i),'. ', Allinpnames(i).name]) 11 | end 12 | x = input(sprintf('\nEnter Network Number: ')); 13 | else 14 | x = net_num; 15 | end 16 | inpname=['\networks\',Allinpnames(x).name]; 17 | dispname=Allinpnames(x).name(1:find(Allinpnames(x).name=='.')-1); 18 | end 19 | 20 | -------------------------------------------------------------------------------- /Scoring Algorithm/functions/nodeTopologicalDistance.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/functions/nodeTopologicalDistance.m -------------------------------------------------------------------------------- /Scoring Algorithm/functions/readLeakageFile.m: -------------------------------------------------------------------------------- 1 | function [leak] = readLeakageFile(fname) 2 | 3 | %% Leakages 4 | % # linkID, startTime, endTime, leakDiameter (m), leakType, peakTime 5 | % p257, 2018-01-08 13:30, 2019-12-31 23:55, 0.011843, incipient, 2018-01-25 08:30 6 | % p427, 2018-02-13 08:25, 2019-12-31 23:55, 0.0090731, incipient, 2018-05-14 19:25 7 | % p810, 2018-07-28 03:05, 2019-12-31 23:55, 0.010028, incipient, 2018-11-02 22:25 8 | % p654, 2018-07-05 03:40, 2019-12-31 23:55, 0.0087735, incipient, 2018-09-16 21:05 9 | % p523, 2019-01-15 23:00, 2019-02-01 09:50, 0.020246, abrupt, 2019-01-15 23:00 10 | % p827, 2019-01-24 18:30, 2019-02-07 09:05, 0.02025, abrupt, 2019-01-24 18:30 11 | % p280, 2019-02-10 13:05, 2019-12-31 23:55, 0.0095008, abrupt, 2019-02-10 13:05 12 | % p653, 2019-03-03 13:10, 2019-05-05 12:10, 0.016035, incipient, 2019-04-21 19:00 13 | % p710, 2019-03-24 14:15, 2019-12-31 23:55, 0.0092936, abrupt, 2019-03-24 14:15 14 | % p514, 2019-04-02 20:40, 2019-05-23 14:55, 0.014979, abrupt, 2019-04-02 20:40 15 | % p331, 2019-04-20 10:10, 2019-12-31 23:55, 0.014053, abrupt, 2019-04-20 10:10 16 | % p193, 2019-05-19 10:40, 2019-12-31 23:55, 0.01239, incipient, 2019-07-25 03:20 17 | % p277, 2019-05-30 21:55, 2019-12-31 23:55, 0.012089, incipient, 2019-08-11 15:05 18 | % p142, 2019-06-12 19:55, 2019-07-17 09:25, 0.019857, abrupt, 2019-06-12 19:55 19 | % p680, 2019-07-10 08:45, 2019-12-31 23:55, 0.0097197, abrupt, 2019-07-10 08:45 20 | % p586, 2019-07-26 14:40, 2019-09-16 03:20, 0.017184, incipient, 2019-08-28 07:55 21 | % p721, 2019-08-02 03:00, 2019-12-31 23:55, 0.01408, incipient, 2019-09-23 05:40 22 | % p800, 2019-08-16 14:00, 2019-10-01 16:35, 0.018847, incipient, 2019-09-07 21:05 23 | % p123, 2019-09-13 20:05, 2019-12-31 23:55, 0.011906, incipient, 2019-11-29 22:10 24 | % p455, 2019-10-03 14:00, 2019-12-31 23:55, 0.012722, incipient, 2019-12-16 05:25 25 | % p762, 2019-10-09 10:15, 2019-12-31 23:55, 0.01519, incipient, 2019-12-03 01:15 26 | % p426, 2019-10-25 13:25, 2019-12-31 23:55, 0.015008, abrupt, 2019-10-25 13:25 27 | % p879, 2019-11-20 11:55, 2019-12-31 23:55, 0.013195, incipient, 2019-12-31 23:55 28 | 29 | %% Read file and sort info: 30 | fname = 'leakages_info.yalm'; 31 | fid=fopen(fname); 32 | tline = fgetl(fid); 33 | leak_lines = cell(0,1); 34 | i=1; 35 | while ischar(tline) 36 | if strcmp(tline(1),'#') 37 | tline = fgetl(fid); 38 | continue 39 | end 40 | leak_lines{end+1,1} = tline; 41 | com = strfind(leak_lines{end,1},','); 42 | leak(i).linkID = leak_lines{end}(1:com(1)-1); 43 | leak(i).startTime = time2steps(leak_lines{end}(com(1)+2:com(2)-1)); 44 | leak(i).endTime = time2steps(leak_lines{end}(com(2)+2:com(3)-1)); 45 | leak(i).diameter = str2num(leak_lines{end}(com(3)+2:com(4)-1)); 46 | leak(i).type = leak_lines{end}(com(4)+2:com(5)-1); 47 | leak(i).peakTime = time2steps(leak_lines{end}(com(5)+2:end)); 48 | leak(i).timeSeries = xlsread(['Leak_',leak(i).linkID,'.xlsx'],2,'B2:B105121'); 49 | leak(i).volume = sum(leak(i).timeSeries)/12; 50 | tline = fgetl(fid); 51 | i=i+1; 52 | end 53 | fclose(fid); 54 | 55 | %% 56 | % timeFormat = 'yyyy-mm-dd MM:HH'; 57 | % leak(i).startTime = datenum('2019-06-12 19:55',timeFormat); 58 | % leak(i).peakTime = datenum('2019-06-12 19:55',timeFormat); 59 | % leak(i).endTime = datenum('2019-07-17 09:25',timeFormat); 60 | % detection(i).startTime= datenum('2019-06-13 19:55',timeFormat); 61 | 62 | % i=1; 63 | % leak(i).linkID = 'p142'; 64 | % leak(i).startTime = time2steps('2019-06-12 19:55'); 65 | % leak(i).peakTime = time2steps('2019-06-12 19:55'); 66 | % leak(i).endTime = time2steps('2019-07-17 09:25'); 67 | % leak(i).diameter = 0.019857; 68 | % leak(i).type = 'abrupt'; 69 | 70 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/readResultsFile.m: -------------------------------------------------------------------------------- 1 | function [detection] = readResultsFile(fname) 2 | 3 | %% Read file and sort info: 4 | fid=fopen(fname); 5 | tline = fgetl(fid); 6 | det_lines = cell(0,1); 7 | i=1; 8 | while ischar(tline) 9 | if isempty(tline) || strcmp(tline(1),'#') 10 | tline = fgetl(fid); 11 | continue 12 | end 13 | det_lines{end+1,1} = tline; 14 | com = strfind(det_lines{end,1},','); 15 | detection(i).linkID = det_lines{end}(1:com(1)-1); 16 | detection(i).startTime = time2steps(det_lines{end}(com(1)+2:end)); 17 | tline = fgetl(fid); 18 | i=i+1; 19 | end 20 | fclose(fid); 21 | 22 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/scoring_function.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/functions/scoring_function.m -------------------------------------------------------------------------------- /Scoring Algorithm/functions/selectResultsFile.m: -------------------------------------------------------------------------------- 1 | function [filename, teamName] = selectResultsFile(num) 2 | %% choose a network to load from networks folder 3 | clc 4 | dirName = [pwd,'\SUBMITTED_files\*.txt']; 5 | Allinpnames = dir(dirName); 6 | 7 | if isempty(num) 8 | disp(sprintf('\nChoose Results file:')) 9 | for i=1:length(Allinpnames) 10 | disp([num2str(i),'. ', Allinpnames(i).name]) 11 | end 12 | x = input(sprintf('\nEnter File Number: ')); 13 | else 14 | x = num; 15 | end 16 | filename=[Allinpnames(x).name]; 17 | teamName = filename(1:strfind(filename,'.txt')-1); 18 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/steps2time.m: -------------------------------------------------------------------------------- 1 | function [timeG] = steps2time(ts) 2 | %%% Converts a given time of the year 2019 to number of 5-minute time steps 3 | %%% since 2019-01-01 00:00 4 | 5 | %% 6 | timeFormat = 'yyyy-mm-dd HH:MM'; 7 | initTime = datenum('2019-01-01 00:00',timeFormat); 8 | % fiveMinStep = datenum('2019-01-01 00:05',timeFormat)-initTime; 9 | % ts = round((timeG-initTime)/fiveMinStep); 10 | % timeG = (ts*fiveMinStep)+initTime; 11 | timeG = (ts*5/60/24)+initTime; 12 | timeG=datestr(timeG,timeFormat); 13 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/tightfig.m: -------------------------------------------------------------------------------- 1 | function hfig = tightfig(hfig) 2 | % tightfig: Alters a figure so that it has the minimum size necessary to 3 | % enclose all axes in the figure without excess space around them. 4 | % 5 | % Note that tightfig will expand the figure to completely encompass all 6 | % axes if necessary. If any 3D axes are present which have been zoomed, 7 | % tightfig will produce an error, as these cannot easily be dealt with. 8 | % 9 | % hfig - handle to figure, if not supplied, the current figure will be used 10 | % instead. 11 | 12 | if nargin == 0 13 | hfig = gcf; 14 | end 15 | 16 | % There can be an issue with tightfig when the user has been modifying 17 | % the contnts manually, the code below is an attempt to resolve this, 18 | % but it has not yet been satisfactorily fixed 19 | % origwindowstyle = get(hfig, 'WindowStyle'); 20 | set(hfig, 'WindowStyle', 'normal'); 21 | 22 | % 1 point is 0.3528 mm for future use 23 | 24 | % get all the axes handles note this will also fetch legends and 25 | % colorbars as well 26 | hax = findall(hfig, 'type', 'axes'); 27 | 28 | % get the original axes units, so we can change and reset these again 29 | % later 30 | origaxunits = get(hax, 'Units'); 31 | 32 | % change the axes units to cm 33 | set(hax, 'Units', 'centimeters'); 34 | 35 | % get various position parameters of the axes 36 | if numel(hax) > 1 37 | % fsize = cell2mat(get(hax, 'FontSize')); 38 | ti = cell2mat(get(hax,'TightInset')); 39 | pos = cell2mat(get(hax, 'Position')); 40 | else 41 | % fsize = get(hax, 'FontSize'); 42 | ti = get(hax,'TightInset'); 43 | pos = get(hax, 'Position'); 44 | end 45 | 46 | % ensure very tiny border so outer box always appears 47 | ti(ti < 0.1) = 0.15; 48 | 49 | % we will check if any 3d axes are zoomed, to do this we will check if 50 | % they are not being viewed in any of the 2d directions 51 | views2d = [0,90; 0,0; 90,0]; 52 | 53 | for i = 1:numel(hax) 54 | 55 | set(hax(i), 'LooseInset', ti(i,:)); 56 | % set(hax(i), 'LooseInset', [0,0,0,0]); 57 | 58 | % get the current viewing angle of the axes 59 | [az,el] = view(hax(i)); 60 | 61 | % determine if the axes are zoomed 62 | iszoomed = strcmp(get(hax(i), 'CameraViewAngleMode'), 'manual'); 63 | 64 | % test if we are viewing in 2d mode or a 3d view 65 | is2d = all(bsxfun(@eq, [az,el], views2d), 2); 66 | 67 | if iszoomed && ~any(is2d) 68 | error('TIGHTFIG:haszoomed3d', 'Cannot make figures containing zoomed 3D axes tight.') 69 | end 70 | 71 | end 72 | 73 | % we will move all the axes down and to the left by the amount 74 | % necessary to just show the bottom and leftmost axes and labels etc. 75 | moveleft = min(pos(:,1) - ti(:,1)); 76 | 77 | movedown = min(pos(:,2) - ti(:,2)); 78 | 79 | % we will also alter the height and width of the figure to just 80 | % encompass the topmost and rightmost axes and lables 81 | figwidth = max(pos(:,1) + pos(:,3) + ti(:,3) - moveleft); 82 | 83 | figheight = max(pos(:,2) + pos(:,4) + ti(:,4) - movedown); 84 | 85 | % move all the axes 86 | for i = 1:numel(hax) 87 | 88 | set(hax(i), 'Position', [pos(i,1:2) - [moveleft,movedown], pos(i,3:4)]); 89 | 90 | end 91 | 92 | origfigunits = get(hfig, 'Units'); 93 | 94 | set(hfig, 'Units', 'centimeters'); 95 | 96 | % change the size of the figure 97 | figpos = get(hfig, 'Position'); 98 | 99 | set(hfig, 'Position', [figpos(1), figpos(2), figwidth, figheight]); 100 | 101 | % change the size of the paper 102 | set(hfig, 'PaperUnits','centimeters'); 103 | set(hfig, 'PaperSize', [figwidth, figheight]); 104 | set(hfig, 'PaperPositionMode', 'manual'); 105 | set(hfig, 'PaperPosition',[0 0 figwidth figheight]); 106 | 107 | % reset to original units for axes and figure 108 | if ~iscell(origaxunits) 109 | origaxunits = {origaxunits}; 110 | end 111 | 112 | for i = 1:numel(hax) 113 | set(hax(i), 'Units', origaxunits{i}); 114 | end 115 | 116 | set(hfig, 'Units', origfigunits); 117 | 118 | % set(hfig, 'WindowStyle', origwindowstyle); 119 | 120 | end -------------------------------------------------------------------------------- /Scoring Algorithm/functions/time2steps.m: -------------------------------------------------------------------------------- 1 | function [ts] = time2steps(timeG) 2 | %%% Converts a given time of the year 2019 to number of 5-minute time steps 3 | %%% since 2019-01-01 00:00 4 | 5 | %% 6 | timeFormat = 'yyyy-mm-dd HH:MM'; 7 | timeG = datenum(timeG,timeFormat); 8 | initTime = datenum('2019-01-01 00:00',timeFormat); 9 | fiveMinStep = datenum('2019-01-01 00:05',timeFormat)-initTime; 10 | ts = round((timeG-initTime)/fiveMinStep); 11 | 12 | end -------------------------------------------------------------------------------- /Scoring Algorithm/results_mat/PERFECT_TEAM.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_mat/PERFECT_TEAM.mat -------------------------------------------------------------------------------- /Scoring Algorithm/results_mat/test_team.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_mat/test_team.mat -------------------------------------------------------------------------------- /Scoring Algorithm/results_mat/test_team_multiple.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_mat/test_team_multiple.mat -------------------------------------------------------------------------------- /Scoring Algorithm/results_reports/PERFECT_TEAM_report.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_reports/PERFECT_TEAM_report.txt -------------------------------------------------------------------------------- /Scoring Algorithm/results_reports/test_team_multiple_report.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_reports/test_team_multiple_report.txt -------------------------------------------------------------------------------- /Scoring Algorithm/results_reports/test_team_report.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/BattLeDIM/ea81f544debb21587e09c32801ce605f8305720a/Scoring Algorithm/results_reports/test_team_report.txt --------------------------------------------------------------------------------