mg-pso-gui 0.1.13__py3-none-any.whl → 0.2.75__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/METADATA +10 -11
- mg_pso_gui-0.2.75.dist-info/RECORD +76 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/WHEEL +1 -1
- mgpsogui/gui/General/ParameterView.py +110 -0
- mgpsogui/gui/General/__init__.py +0 -0
- mgpsogui/gui/HomePage.py +565 -513
- mgpsogui/gui/OptionManager.py +333 -145
- mgpsogui/gui/OptionManager_backup.py +443 -0
- mgpsogui/gui/PlatformTab/PlatformTab.py +15 -6
- mgpsogui/gui/RunTab/OptimalParameterView.py +47 -0
- mgpsogui/gui/RunTab/RunTab.py +89 -35
- mgpsogui/gui/SetupTab/BoundsEditorWindow.py +1 -1
- mgpsogui/gui/SetupTab/BoundsList.py +97 -34
- mgpsogui/gui/SetupTab/CustomFunctionEditorWindow.py +74 -0
- mgpsogui/gui/SetupTab/CustomFunctionMetrics.py +156 -0
- mgpsogui/gui/SetupTab/FunctionsList.py +60 -6
- mgpsogui/gui/SetupTab/{StaticParameterView.py → ListEditor.py} +27 -16
- mgpsogui/gui/SetupTab/ListParametersView.py +7 -6
- mgpsogui/gui/SetupTab/{CalibrationParametersView.py → OverrideParameterMetrics.py} +35 -9
- mgpsogui/gui/SetupTab/OverrideParameterWindow.py +40 -0
- mgpsogui/gui/SetupTab/SetupTab.py +31 -11
- mgpsogui/gui/SetupTab/StepView.py +93 -22
- mgpsogui/gui/VisualizeTab/MatrixEditor.py +68 -0
- mgpsogui/gui/VisualizeTab/SideBar.py +399 -0
- mgpsogui/gui/VisualizeTab/VisualizeTab.py +76 -11
- mgpsogui/gui/defaults/__init__.py +0 -0
- mgpsogui/gui/defaults/optimization.json +176 -0
- mgpsogui/gui/defaults/sampling.json +111 -0
- mgpsogui/gui/defaults/sensitivity.json +20 -0
- mgpsogui/gui/images/plus.png +0 -0
- mgpsogui/gui/images/test.png +0 -0
- mgpsogui/util/GraphGenerator.py +747 -42
- mgpsogui/util/PSORunner.py +608 -116
- mgpsogui/util/debug.py +559 -0
- mgpsogui/util/helpers.py +95 -0
- mgpsogui/util/recosu/__init__.py +2 -1
- mgpsogui/util/recosu/pso/csip_access.py +2 -35
- mgpsogui/util/recosu/pso/pso.py +55 -59
- mgpsogui/util/recosu/sampling/__init__.py +16 -0
- mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
- mgpsogui/util/recosu/sampling/halton/halton.py +45 -0
- mgpsogui/util/recosu/sampling/halton/prime.py +82 -0
- mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
- mgpsogui/util/recosu/sampling/random/random_sampler.py +34 -0
- mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
- mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
- mgpsogui/util/recosu/sampling/sampling.py +99 -0
- mgpsogui/util/sampler_test_driver.py +129 -0
- mg_pso_gui-0.1.13.dist-info/RECORD +0 -50
- mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/entry_points.txt +0 -0
- {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/top_level.txt +0 -0
mgpsogui/util/debug.py
ADDED
@@ -0,0 +1,559 @@
|
|
1
|
+
from recosu.pso import global_best
|
2
|
+
|
3
|
+
# 1) COSU steps, definition of parameters to calibrate
|
4
|
+
steps = [
|
5
|
+
{ # step 1
|
6
|
+
"param": [
|
7
|
+
{"name": "soilOutLPS", "bounds": (0.0, 2.0)},
|
8
|
+
{"name": "lagInterflow", "bounds": (10.0, 80.0)},
|
9
|
+
],
|
10
|
+
"objfunc": [
|
11
|
+
{
|
12
|
+
"name": "ns", # Name (Must be unique)
|
13
|
+
"of": "ns", # Objective Function
|
14
|
+
"data": (
|
15
|
+
"obs_data02_14.csv/obs/orun[1]",
|
16
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
17
|
+
)
|
18
|
+
# Optional Weight parameter. If not specified it is 1 or evenly distributed between all objective functions
|
19
|
+
}
|
20
|
+
],
|
21
|
+
},
|
22
|
+
{ # step 2
|
23
|
+
"param": [
|
24
|
+
{"name": "flowRouteTA", "bounds": (0.4, 5.0)},
|
25
|
+
{"name": "soilMaxDPS", "bounds": (0.0, 5.0)},
|
26
|
+
],
|
27
|
+
"objfunc": [
|
28
|
+
{
|
29
|
+
"name": "ns",
|
30
|
+
"of": "ns",
|
31
|
+
"data": (
|
32
|
+
"obs_data02_14.csv/obs/orun[1]",
|
33
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
34
|
+
),
|
35
|
+
}
|
36
|
+
],
|
37
|
+
},
|
38
|
+
]
|
39
|
+
|
40
|
+
steps = [
|
41
|
+
{
|
42
|
+
"param": [
|
43
|
+
{
|
44
|
+
"name": "soilOutLPS",
|
45
|
+
"bounds": (0.0, 2.0),
|
46
|
+
"default_value": 1.0,
|
47
|
+
"optimal_value": 0.0,
|
48
|
+
"type": "float",
|
49
|
+
"calibration_strategy": "none",
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"name": "lagInterflow",
|
53
|
+
"bounds": (10.0, 80.0),
|
54
|
+
"default_value": 1.0,
|
55
|
+
"optimal_value": 0.0,
|
56
|
+
"type": "float",
|
57
|
+
"calibration_strategy": "none",
|
58
|
+
},
|
59
|
+
],
|
60
|
+
"objfunc": [
|
61
|
+
{
|
62
|
+
"name": "ns",
|
63
|
+
"of": "ns",
|
64
|
+
"weight": 1.0,
|
65
|
+
"data": (
|
66
|
+
"obs_data02_14.csv/obs/orun[1]",
|
67
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
68
|
+
),
|
69
|
+
}
|
70
|
+
],
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"param": [
|
74
|
+
{
|
75
|
+
"name": "flowRouteTA",
|
76
|
+
"bounds": (0.4, 5.0),
|
77
|
+
"default_value": 1.0,
|
78
|
+
"optimal_value": 0.0,
|
79
|
+
"type": "float",
|
80
|
+
"calibration_strategy": "none",
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "soilMaxDPS",
|
84
|
+
"bounds": (0.0, 5.0),
|
85
|
+
"default_value": 1.0,
|
86
|
+
"optimal_value": 0.0,
|
87
|
+
"type": "float",
|
88
|
+
"calibration_strategy": "none",
|
89
|
+
},
|
90
|
+
],
|
91
|
+
"objfunc": [
|
92
|
+
{
|
93
|
+
"name": "ns",
|
94
|
+
"of": "ns",
|
95
|
+
"weight": 1.0,
|
96
|
+
"data": (
|
97
|
+
"obs_data02_14.csv/obs/orun[1]",
|
98
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
99
|
+
),
|
100
|
+
}
|
101
|
+
],
|
102
|
+
},
|
103
|
+
]
|
104
|
+
|
105
|
+
# 2) static ages parameters
|
106
|
+
args = {
|
107
|
+
"param": [
|
108
|
+
{"name": "startTime", "value": "2002-01-01"},
|
109
|
+
{"name": "endTime", "value": "2006-12-31"},
|
110
|
+
{"name": "dataStartTime", "value": "2002-01-01"},
|
111
|
+
{"name": "dataEndTime", "value": "2006-12-31"},
|
112
|
+
{"name": "cal_startTime", "value": "2003-01-01"},
|
113
|
+
{"name": "cal_endTime", "value": "2006-12-31"},
|
114
|
+
{"name": "parallelismThreads", "value": "2"},
|
115
|
+
{"name": "flagLoadState", "value": "True"},
|
116
|
+
{"name": "payload", "value": "false"},
|
117
|
+
{"name": "project", "value": "SFIR3"},
|
118
|
+
],
|
119
|
+
# the service url
|
120
|
+
"url": "http://csip.engr.colostate.edu:8087/csip-oms/m/ages/0.3.0",
|
121
|
+
# the files to attach for each run
|
122
|
+
"files": {},
|
123
|
+
}
|
124
|
+
|
125
|
+
args = {
|
126
|
+
"param": [
|
127
|
+
{"name": "startTime", "value": "2002-01-01"},
|
128
|
+
{"name": "endTime", "value": "2006-12-31"},
|
129
|
+
{"name": "dataStartTime", "value": "2002-01-01"},
|
130
|
+
{"name": "dataEndTime", "value": "2006-12-31"},
|
131
|
+
{"name": "cal_startTime", "value": "2003-01-01"},
|
132
|
+
{"name": "cal_endTime", "value": "2006-12-31"},
|
133
|
+
{"name": "parallelismThreads", "value": "2"},
|
134
|
+
{"name": "flagLoadState", "value": "True"},
|
135
|
+
{"name": "payload", "value": "false"},
|
136
|
+
{"name": "project", "value": "SFIR3"},
|
137
|
+
],
|
138
|
+
"url": "http://csip.engr.colostate.edu:8087/csip-oms/m/ages/0.3.0",
|
139
|
+
"mode": "Optimization: MG-PSO",
|
140
|
+
"files": {},
|
141
|
+
}
|
142
|
+
|
143
|
+
if "mode" in args:
|
144
|
+
del args["mode"]
|
145
|
+
|
146
|
+
# 3. perform optimization
|
147
|
+
optimizer, trace = global_best(
|
148
|
+
steps, # step definition
|
149
|
+
rounds=(1, 2), # min/max number of rounds
|
150
|
+
args=args, # static arguments
|
151
|
+
n_particles=10, # number of particle candidates for each param
|
152
|
+
iters=20, # max # of iterations
|
153
|
+
n_threads=10, # number of threads to use
|
154
|
+
# ftol=0.00000001, # min cost function delta for convergence
|
155
|
+
options={"c1": 2, "c2": 2, "w": 0.8}, # hyperparameter
|
156
|
+
oh_strategy={
|
157
|
+
"w": "adaptive",
|
158
|
+
"c1": "adaptive",
|
159
|
+
"c2": "adaptive",
|
160
|
+
}, # adaptive hyperparameter adjustments based on current and max # of iterations
|
161
|
+
conf={
|
162
|
+
"service_timeout": 400.0,
|
163
|
+
"http_retry": 5,
|
164
|
+
"http_allow_redirects": True,
|
165
|
+
"async_call": False,
|
166
|
+
"http_conn_timeout": 10,
|
167
|
+
"http_read_timeout": 400,
|
168
|
+
"particles_fail": 5,
|
169
|
+
"step_trace": "./step_trace.json",
|
170
|
+
},
|
171
|
+
)
|
172
|
+
|
173
|
+
step_trace = {
|
174
|
+
"dir": "/Users/robertcordingly/Library/Python/3.8/lib/python/site-packages/mgpsogui/gui",
|
175
|
+
"start": "2024-05-28 14:25:53.793407",
|
176
|
+
"min_rounds": 1,
|
177
|
+
"max_rounds": 2,
|
178
|
+
"iters": 20,
|
179
|
+
"ftol": "-inf",
|
180
|
+
"ftol_iter": 1,
|
181
|
+
"rtol": 0.001,
|
182
|
+
"rtol_iter": 1,
|
183
|
+
"n_threads": 10,
|
184
|
+
"n_particles": 10,
|
185
|
+
"n_steps": 2,
|
186
|
+
"steps": [
|
187
|
+
{
|
188
|
+
"param": [
|
189
|
+
{
|
190
|
+
"name": "soilOutLPS",
|
191
|
+
"bounds": (0.0, 2.0),
|
192
|
+
"default_value": 1.0,
|
193
|
+
"optimal_value": 0.0,
|
194
|
+
"type": "float",
|
195
|
+
"calibration_strategy": "none",
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"name": "lagInterflow",
|
199
|
+
"bounds": (10.0, 80.0),
|
200
|
+
"default_value": 1.0,
|
201
|
+
"optimal_value": 0.0,
|
202
|
+
"type": "float",
|
203
|
+
"calibration_strategy": "none",
|
204
|
+
},
|
205
|
+
],
|
206
|
+
"objfunc": [
|
207
|
+
{
|
208
|
+
"name": "ns",
|
209
|
+
"of": "ns",
|
210
|
+
"weight": 1.0,
|
211
|
+
"data": (
|
212
|
+
"obs_data02_14.csv/obs/orun[1]",
|
213
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
214
|
+
),
|
215
|
+
}
|
216
|
+
],
|
217
|
+
},
|
218
|
+
{
|
219
|
+
"param": [
|
220
|
+
{
|
221
|
+
"name": "flowRouteTA",
|
222
|
+
"bounds": (0.4, 5.0),
|
223
|
+
"default_value": 1.0,
|
224
|
+
"optimal_value": 0.0,
|
225
|
+
"type": "float",
|
226
|
+
"calibration_strategy": "none",
|
227
|
+
},
|
228
|
+
{
|
229
|
+
"name": "soilMaxDPS",
|
230
|
+
"bounds": (0.0, 5.0),
|
231
|
+
"default_value": 1.0,
|
232
|
+
"optimal_value": 0.0,
|
233
|
+
"type": "float",
|
234
|
+
"calibration_strategy": "none",
|
235
|
+
},
|
236
|
+
],
|
237
|
+
"objfunc": [
|
238
|
+
{
|
239
|
+
"name": "ns",
|
240
|
+
"of": "ns",
|
241
|
+
"weight": 1.0,
|
242
|
+
"data": (
|
243
|
+
"obs_data02_14.csv/obs/orun[1]",
|
244
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
245
|
+
),
|
246
|
+
}
|
247
|
+
],
|
248
|
+
},
|
249
|
+
],
|
250
|
+
"args": "{'param': [{'name': 'startTime', 'value': '2002-01-01'}, {'name': 'endTime', 'value': '2006-12-31'}, {'name': 'dataStartTime', 'value': '2002-01-01'}, {'name': 'dataEndTime', 'value': '2006-12-31'}, {'name': 'cal_startTime', 'value': '2003-01-01'}, {'name': 'cal_endTime', 'value': '2006-12-31'}, {'name': 'parallelismThreads', 'value': '2'}, {'name': 'flagLoadState', 'value': 'True'}, {'name': 'payload', 'value': 'false'}, {'name': 'project', 'value': 'SFIR3'}], 'url': 'http://csip.engr.colostate.edu:8087/csip-oms/m/ages/0.3.0', 'files': {}}",
|
251
|
+
"r1s1": {
|
252
|
+
"time": "2024-05-28 14:28:27.648143",
|
253
|
+
"best_costs": [0.4962544759194877, "inf"],
|
254
|
+
"steps": [
|
255
|
+
{
|
256
|
+
"param": [
|
257
|
+
{
|
258
|
+
"name": "soilOutLPS",
|
259
|
+
"bounds": (0.0, 2.0),
|
260
|
+
"default_value": 1.0,
|
261
|
+
"optimal_value": 0.0,
|
262
|
+
"type": "float",
|
263
|
+
"calibration_strategy": "none",
|
264
|
+
"value": 1.4277364777450963,
|
265
|
+
},
|
266
|
+
{
|
267
|
+
"name": "lagInterflow",
|
268
|
+
"bounds": (10.0, 80.0),
|
269
|
+
"default_value": 1.0,
|
270
|
+
"optimal_value": 0.0,
|
271
|
+
"type": "float",
|
272
|
+
"calibration_strategy": "none",
|
273
|
+
"value": 65.31198215742819,
|
274
|
+
},
|
275
|
+
],
|
276
|
+
"objfunc": [
|
277
|
+
{
|
278
|
+
"name": "ns",
|
279
|
+
"of": "ns",
|
280
|
+
"weight": 1.0,
|
281
|
+
"data": (
|
282
|
+
"obs_data02_14.csv/obs/orun[1]",
|
283
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
284
|
+
),
|
285
|
+
}
|
286
|
+
],
|
287
|
+
"cost": 0.4962544759194877,
|
288
|
+
},
|
289
|
+
{
|
290
|
+
"param": [
|
291
|
+
{
|
292
|
+
"name": "flowRouteTA",
|
293
|
+
"bounds": (0.4, 5.0),
|
294
|
+
"default_value": 1.0,
|
295
|
+
"optimal_value": 0.0,
|
296
|
+
"type": "float",
|
297
|
+
"calibration_strategy": "none",
|
298
|
+
},
|
299
|
+
{
|
300
|
+
"name": "soilMaxDPS",
|
301
|
+
"bounds": (0.0, 5.0),
|
302
|
+
"default_value": 1.0,
|
303
|
+
"optimal_value": 0.0,
|
304
|
+
"type": "float",
|
305
|
+
"calibration_strategy": "none",
|
306
|
+
},
|
307
|
+
],
|
308
|
+
"objfunc": [
|
309
|
+
{
|
310
|
+
"name": "ns",
|
311
|
+
"of": "ns",
|
312
|
+
"weight": 1.0,
|
313
|
+
"data": (
|
314
|
+
"obs_data02_14.csv/obs/orun[1]",
|
315
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
316
|
+
),
|
317
|
+
}
|
318
|
+
],
|
319
|
+
},
|
320
|
+
],
|
321
|
+
},
|
322
|
+
"r1s2": {
|
323
|
+
"time": "2024-05-28 14:30:53.464613",
|
324
|
+
"best_costs": [0.4962544759194877, 0.4159144385219078],
|
325
|
+
"steps": [
|
326
|
+
{
|
327
|
+
"param": [
|
328
|
+
{
|
329
|
+
"name": "soilOutLPS",
|
330
|
+
"bounds": (0.0, 2.0),
|
331
|
+
"default_value": 1.0,
|
332
|
+
"optimal_value": 0.0,
|
333
|
+
"type": "float",
|
334
|
+
"calibration_strategy": "none",
|
335
|
+
"value": 1.4277364777450963,
|
336
|
+
},
|
337
|
+
{
|
338
|
+
"name": "lagInterflow",
|
339
|
+
"bounds": (10.0, 80.0),
|
340
|
+
"default_value": 1.0,
|
341
|
+
"optimal_value": 0.0,
|
342
|
+
"type": "float",
|
343
|
+
"calibration_strategy": "none",
|
344
|
+
"value": 65.31198215742819,
|
345
|
+
},
|
346
|
+
],
|
347
|
+
"objfunc": [
|
348
|
+
{
|
349
|
+
"name": "ns",
|
350
|
+
"of": "ns",
|
351
|
+
"weight": 1.0,
|
352
|
+
"data": (
|
353
|
+
"obs_data02_14.csv/obs/orun[1]",
|
354
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
355
|
+
),
|
356
|
+
}
|
357
|
+
],
|
358
|
+
"cost": 0.4962544759194877,
|
359
|
+
},
|
360
|
+
{
|
361
|
+
"param": [
|
362
|
+
{
|
363
|
+
"name": "flowRouteTA",
|
364
|
+
"bounds": (0.4, 5.0),
|
365
|
+
"default_value": 1.0,
|
366
|
+
"optimal_value": 0.0,
|
367
|
+
"type": "float",
|
368
|
+
"calibration_strategy": "none",
|
369
|
+
"value": 1.9846472555222765,
|
370
|
+
},
|
371
|
+
{
|
372
|
+
"name": "soilMaxDPS",
|
373
|
+
"bounds": (0.0, 5.0),
|
374
|
+
"default_value": 1.0,
|
375
|
+
"optimal_value": 0.0,
|
376
|
+
"type": "float",
|
377
|
+
"calibration_strategy": "none",
|
378
|
+
"value": 4.619363774024649,
|
379
|
+
},
|
380
|
+
],
|
381
|
+
"objfunc": [
|
382
|
+
{
|
383
|
+
"name": "ns",
|
384
|
+
"of": "ns",
|
385
|
+
"weight": 1.0,
|
386
|
+
"data": (
|
387
|
+
"obs_data02_14.csv/obs/orun[1]",
|
388
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
389
|
+
),
|
390
|
+
}
|
391
|
+
],
|
392
|
+
"cost": 0.4159144385219078,
|
393
|
+
},
|
394
|
+
],
|
395
|
+
},
|
396
|
+
"r1": {
|
397
|
+
"time": "2024-05-28 14:30:53.465478",
|
398
|
+
"round_cost": 0.9121689144413955,
|
399
|
+
"best_costs": [0.4962544759194877, 0.4159144385219078],
|
400
|
+
"improvements": [False, False],
|
401
|
+
},
|
402
|
+
"r2s1": {
|
403
|
+
"time": "2024-05-28 14:33:23.457742",
|
404
|
+
"best_costs": [0.41218845540212334, 0.4159144385219078],
|
405
|
+
"steps": [
|
406
|
+
{
|
407
|
+
"param": [
|
408
|
+
{
|
409
|
+
"name": "soilOutLPS",
|
410
|
+
"bounds": (0.0, 2.0),
|
411
|
+
"default_value": 1.0,
|
412
|
+
"optimal_value": 0.0,
|
413
|
+
"type": "float",
|
414
|
+
"calibration_strategy": "none",
|
415
|
+
"value": 1.3832527609622032,
|
416
|
+
},
|
417
|
+
{
|
418
|
+
"name": "lagInterflow",
|
419
|
+
"bounds": (10.0, 80.0),
|
420
|
+
"default_value": 1.0,
|
421
|
+
"optimal_value": 0.0,
|
422
|
+
"type": "float",
|
423
|
+
"calibration_strategy": "none",
|
424
|
+
"value": 71.21736822883048,
|
425
|
+
},
|
426
|
+
],
|
427
|
+
"objfunc": [
|
428
|
+
{
|
429
|
+
"name": "ns",
|
430
|
+
"of": "ns",
|
431
|
+
"weight": 1.0,
|
432
|
+
"data": (
|
433
|
+
"obs_data02_14.csv/obs/orun[1]",
|
434
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
435
|
+
),
|
436
|
+
}
|
437
|
+
],
|
438
|
+
"cost": 0.41218845540212334,
|
439
|
+
},
|
440
|
+
{
|
441
|
+
"param": [
|
442
|
+
{
|
443
|
+
"name": "flowRouteTA",
|
444
|
+
"bounds": (0.4, 5.0),
|
445
|
+
"default_value": 1.0,
|
446
|
+
"optimal_value": 0.0,
|
447
|
+
"type": "float",
|
448
|
+
"calibration_strategy": "none",
|
449
|
+
"value": 1.9846472555222765,
|
450
|
+
},
|
451
|
+
{
|
452
|
+
"name": "soilMaxDPS",
|
453
|
+
"bounds": (0.0, 5.0),
|
454
|
+
"default_value": 1.0,
|
455
|
+
"optimal_value": 0.0,
|
456
|
+
"type": "float",
|
457
|
+
"calibration_strategy": "none",
|
458
|
+
"value": 4.619363774024649,
|
459
|
+
},
|
460
|
+
],
|
461
|
+
"objfunc": [
|
462
|
+
{
|
463
|
+
"name": "ns",
|
464
|
+
"of": "ns",
|
465
|
+
"weight": 1.0,
|
466
|
+
"data": (
|
467
|
+
"obs_data02_14.csv/obs/orun[1]",
|
468
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
469
|
+
),
|
470
|
+
}
|
471
|
+
],
|
472
|
+
"cost": 0.4159144385219078,
|
473
|
+
},
|
474
|
+
],
|
475
|
+
},
|
476
|
+
"r2s2": {
|
477
|
+
"time": "2024-05-28 14:35:50.514486",
|
478
|
+
"best_costs": [0.41218845540212334, 0.4121061580572347],
|
479
|
+
"steps": [
|
480
|
+
{
|
481
|
+
"param": [
|
482
|
+
{
|
483
|
+
"name": "soilOutLPS",
|
484
|
+
"bounds": (0.0, 2.0),
|
485
|
+
"default_value": 1.0,
|
486
|
+
"optimal_value": 0.0,
|
487
|
+
"type": "float",
|
488
|
+
"calibration_strategy": "none",
|
489
|
+
"value": 1.3832527609622032,
|
490
|
+
},
|
491
|
+
{
|
492
|
+
"name": "lagInterflow",
|
493
|
+
"bounds": (10.0, 80.0),
|
494
|
+
"default_value": 1.0,
|
495
|
+
"optimal_value": 0.0,
|
496
|
+
"type": "float",
|
497
|
+
"calibration_strategy": "none",
|
498
|
+
"value": 71.21736822883048,
|
499
|
+
},
|
500
|
+
],
|
501
|
+
"objfunc": [
|
502
|
+
{
|
503
|
+
"name": "ns",
|
504
|
+
"of": "ns",
|
505
|
+
"weight": 1.0,
|
506
|
+
"data": (
|
507
|
+
"obs_data02_14.csv/obs/orun[1]",
|
508
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
509
|
+
),
|
510
|
+
}
|
511
|
+
],
|
512
|
+
"cost": 0.41218845540212334,
|
513
|
+
},
|
514
|
+
{
|
515
|
+
"param": [
|
516
|
+
{
|
517
|
+
"name": "flowRouteTA",
|
518
|
+
"bounds": (0.4, 5.0),
|
519
|
+
"default_value": 1.0,
|
520
|
+
"optimal_value": 0.0,
|
521
|
+
"type": "float",
|
522
|
+
"calibration_strategy": "none",
|
523
|
+
"value": 1.9461260670740506,
|
524
|
+
},
|
525
|
+
{
|
526
|
+
"name": "soilMaxDPS",
|
527
|
+
"bounds": (0.0, 5.0),
|
528
|
+
"default_value": 1.0,
|
529
|
+
"optimal_value": 0.0,
|
530
|
+
"type": "float",
|
531
|
+
"calibration_strategy": "none",
|
532
|
+
"value": 3.7734465992198514,
|
533
|
+
},
|
534
|
+
],
|
535
|
+
"objfunc": [
|
536
|
+
{
|
537
|
+
"name": "ns",
|
538
|
+
"of": "ns",
|
539
|
+
"weight": 1.0,
|
540
|
+
"data": (
|
541
|
+
"obs_data02_14.csv/obs/orun[1]",
|
542
|
+
"output/csip_run/out/Outlet.csv/output/catchmentSimRunoff",
|
543
|
+
),
|
544
|
+
}
|
545
|
+
],
|
546
|
+
"cost": 0.4121061580572347,
|
547
|
+
},
|
548
|
+
],
|
549
|
+
},
|
550
|
+
"r2": {
|
551
|
+
"time": "2024-05-28 14:35:50.521162",
|
552
|
+
"round_cost": 0.8242946134593581,
|
553
|
+
"best_costs": [0.41218845540212334, 0.4121061580572347],
|
554
|
+
"improvements": [False, False],
|
555
|
+
},
|
556
|
+
"rounds": 2,
|
557
|
+
"end": "2024-05-28 14:35:51.017597",
|
558
|
+
"time": "0:09:56.726582",
|
559
|
+
}
|
mgpsogui/util/helpers.py
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
def extract_final_round_values(data):
|
2
|
+
max_rounds = data['max_rounds'] + 1
|
3
|
+
steps = data['n_steps'] + 1
|
4
|
+
|
5
|
+
final_value = {}
|
6
|
+
|
7
|
+
for round in range(max_rounds):
|
8
|
+
for step in range(steps):
|
9
|
+
key = f"r{round}s{step}"
|
10
|
+
if key in data:
|
11
|
+
obj = data[key]
|
12
|
+
round_steps = []
|
13
|
+
for o_step in obj['steps']:
|
14
|
+
step_obj = {}
|
15
|
+
for param in o_step['param']:
|
16
|
+
if 'name' in param and 'value' in param:
|
17
|
+
step_obj[param['name']] = param['value']
|
18
|
+
|
19
|
+
round_steps.append(step_obj)
|
20
|
+
final_value["data"] = round_steps
|
21
|
+
final_value["index"] = key
|
22
|
+
return final_value
|
23
|
+
|
24
|
+
def parse_sampling_output(file_path):
|
25
|
+
lines = ""
|
26
|
+
|
27
|
+
with open(file_path, 'r') as f:
|
28
|
+
lines = f.readlines()
|
29
|
+
|
30
|
+
# Remove any lines that don't contain "% Done "
|
31
|
+
lines = [line for line in lines if '% Done ' in line]
|
32
|
+
|
33
|
+
percents = []
|
34
|
+
percent = 0
|
35
|
+
for line in lines:
|
36
|
+
percent = float(line.split('% Done ')[0].strip())
|
37
|
+
percents.append(percent)
|
38
|
+
|
39
|
+
return {"percent": percent, "data": percents}
|
40
|
+
|
41
|
+
def parse_pso_error(file_path, num_steps):
|
42
|
+
lines = ""
|
43
|
+
|
44
|
+
with open(file_path, 'r') as f:
|
45
|
+
lines = f.readlines()
|
46
|
+
|
47
|
+
lines = [line for line in lines if 'best_cost' in line]
|
48
|
+
lines = [line.replace("pyswarms.single.global_best:", "") for line in lines]
|
49
|
+
|
50
|
+
# Add a fake line to make sure the last round is added
|
51
|
+
lines.append(" 0% /best_cost=0")
|
52
|
+
|
53
|
+
round = 1
|
54
|
+
step = 1
|
55
|
+
|
56
|
+
round_steps = {}
|
57
|
+
percents = []
|
58
|
+
best_costs = []
|
59
|
+
percent = 0
|
60
|
+
last_percent = 0
|
61
|
+
final_percent = 0
|
62
|
+
final_round = 0
|
63
|
+
final_step = 0
|
64
|
+
|
65
|
+
for line in lines:
|
66
|
+
best_cost = float(line.split('best_cost=')[1].strip())
|
67
|
+
percent = float(line.split('%')[0].strip())
|
68
|
+
|
69
|
+
# Percent is less than last percent or we are at the end of the file
|
70
|
+
if (percent < last_percent):
|
71
|
+
|
72
|
+
round_steps[f"Round: {round} - Step: {step}"] = {
|
73
|
+
"best_cost": best_costs.copy(),
|
74
|
+
"percent": percents.copy()
|
75
|
+
}
|
76
|
+
|
77
|
+
best_costs = []
|
78
|
+
percents = []
|
79
|
+
|
80
|
+
final_round = round
|
81
|
+
final_step = step
|
82
|
+
|
83
|
+
step += 1
|
84
|
+
if step > num_steps:
|
85
|
+
step = 1
|
86
|
+
round += 1
|
87
|
+
|
88
|
+
final_percent = last_percent
|
89
|
+
|
90
|
+
best_costs.append(best_cost)
|
91
|
+
percents.append(percent)
|
92
|
+
|
93
|
+
last_percent = percent
|
94
|
+
|
95
|
+
return {"round": final_round, "step": final_step, "percent": final_percent, "data": round_steps}
|