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.
Files changed (52) hide show
  1. {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/METADATA +10 -11
  2. mg_pso_gui-0.2.75.dist-info/RECORD +76 -0
  3. {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/WHEEL +1 -1
  4. mgpsogui/gui/General/ParameterView.py +110 -0
  5. mgpsogui/gui/General/__init__.py +0 -0
  6. mgpsogui/gui/HomePage.py +565 -513
  7. mgpsogui/gui/OptionManager.py +333 -145
  8. mgpsogui/gui/OptionManager_backup.py +443 -0
  9. mgpsogui/gui/PlatformTab/PlatformTab.py +15 -6
  10. mgpsogui/gui/RunTab/OptimalParameterView.py +47 -0
  11. mgpsogui/gui/RunTab/RunTab.py +89 -35
  12. mgpsogui/gui/SetupTab/BoundsEditorWindow.py +1 -1
  13. mgpsogui/gui/SetupTab/BoundsList.py +97 -34
  14. mgpsogui/gui/SetupTab/CustomFunctionEditorWindow.py +74 -0
  15. mgpsogui/gui/SetupTab/CustomFunctionMetrics.py +156 -0
  16. mgpsogui/gui/SetupTab/FunctionsList.py +60 -6
  17. mgpsogui/gui/SetupTab/{StaticParameterView.py → ListEditor.py} +27 -16
  18. mgpsogui/gui/SetupTab/ListParametersView.py +7 -6
  19. mgpsogui/gui/SetupTab/{CalibrationParametersView.py → OverrideParameterMetrics.py} +35 -9
  20. mgpsogui/gui/SetupTab/OverrideParameterWindow.py +40 -0
  21. mgpsogui/gui/SetupTab/SetupTab.py +31 -11
  22. mgpsogui/gui/SetupTab/StepView.py +93 -22
  23. mgpsogui/gui/VisualizeTab/MatrixEditor.py +68 -0
  24. mgpsogui/gui/VisualizeTab/SideBar.py +399 -0
  25. mgpsogui/gui/VisualizeTab/VisualizeTab.py +76 -11
  26. mgpsogui/gui/defaults/__init__.py +0 -0
  27. mgpsogui/gui/defaults/optimization.json +176 -0
  28. mgpsogui/gui/defaults/sampling.json +111 -0
  29. mgpsogui/gui/defaults/sensitivity.json +20 -0
  30. mgpsogui/gui/images/plus.png +0 -0
  31. mgpsogui/gui/images/test.png +0 -0
  32. mgpsogui/util/GraphGenerator.py +747 -42
  33. mgpsogui/util/PSORunner.py +608 -116
  34. mgpsogui/util/debug.py +559 -0
  35. mgpsogui/util/helpers.py +95 -0
  36. mgpsogui/util/recosu/__init__.py +2 -1
  37. mgpsogui/util/recosu/pso/csip_access.py +2 -35
  38. mgpsogui/util/recosu/pso/pso.py +55 -59
  39. mgpsogui/util/recosu/sampling/__init__.py +16 -0
  40. mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
  41. mgpsogui/util/recosu/sampling/halton/halton.py +45 -0
  42. mgpsogui/util/recosu/sampling/halton/prime.py +82 -0
  43. mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
  44. mgpsogui/util/recosu/sampling/random/random_sampler.py +34 -0
  45. mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
  46. mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
  47. mgpsogui/util/recosu/sampling/sampling.py +99 -0
  48. mgpsogui/util/sampler_test_driver.py +129 -0
  49. mg_pso_gui-0.1.13.dist-info/RECORD +0 -50
  50. mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
  51. {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/entry_points.txt +0 -0
  52. {mg_pso_gui-0.1.13.dist-info → mg_pso_gui-0.2.75.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,99 @@
1
+ from collections.abc import Iterable
2
+ import math
3
+ import asyncio
4
+ import concurrent
5
+ import datetime
6
+ from ..utils import utils
7
+ from ..sampling.halton.halton import HaltonSampleGenerator
8
+ from ..sampling.random.random_sampler import RandomSampleGenerator
9
+ from ..sampling.sampler_task import SamplerTask
10
+ from ..sampling.sample_trace_writer import SampleTraceWriter
11
+
12
+
13
+ def weighted_value(weight: float, lower: float, upper: float) -> float:
14
+ return lower + weight * (upper - lower)
15
+
16
+
17
+ def get_static_parameters(args: dict[str, any]) -> dict[str, any]:
18
+ static_parameters: dict[str, any] = {}
19
+ for param in args["param"]:
20
+ static_parameters[param["name"]] = param["value"]
21
+ return static_parameters
22
+
23
+
24
+ def get_objective_names(objfunc: dict[str, any]) -> list[str]:
25
+ objective_names: list[str] = []
26
+ for of in objfunc:
27
+ objective_names.append(of["name"])
28
+ return objective_names
29
+
30
+
31
+ def thread_function(task: SamplerTask) -> tuple[bool, SamplerTask]:
32
+ return task.run_task(), task
33
+
34
+
35
+ def create_generator(method: str, count: int, num_parameters: int, **kwargs) -> Iterable[tuple[int, list[float]]]:
36
+ if method == "halton":
37
+ offset: int = 0
38
+ if "offset" in kwargs:
39
+ offset = kwargs["offset"]
40
+ return HaltonSampleGenerator(count, offset, num_parameters)
41
+ elif method == "random":
42
+ return RandomSampleGenerator(count, num_parameters)
43
+
44
+ raise Exception("Sampling method is not recognized")
45
+
46
+
47
+ def run_sampler(steps: list[dict[str, any]], args: dict[str, any], count: int, num_threads: int, method: str = "halton",
48
+ metainfo: dict[str, any] = None, conf: dict[str, any] = None, trace_file: str = "trace.csv",
49
+ **kwargs) -> dict[int, tuple[dict[str, any], dict[str, any]]]:
50
+ param_names, bounds, objfunc = utils.get_step_info(steps, 0)
51
+ generator: Iterable[tuple[int, list[float]]] = create_generator(method, count, len(param_names), **kwargs)
52
+ objective_names: list[str] = get_objective_names(objfunc)
53
+ static_parameters: dict[str, any] = get_static_parameters(args)
54
+ url: str = args["url"]
55
+ files: list[str] = args["files"]
56
+
57
+ trace: dict[int, tuple[dict[str, float], dict[str, float]]] = {}
58
+ trace_writer: SampleTraceWriter = SampleTraceWriter(trace_file)
59
+ trace_writer.write_header(param_names, objective_names)
60
+
61
+ with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
62
+ futures = []
63
+ for sample_id, sample in generator:
64
+ params: dict[str, float] = {}
65
+ index: int = 0
66
+ while index < len(sample):
67
+ params[param_names[index]] = weighted_value(sample[index], bounds[0][index], bounds[1][index])
68
+ index += 1
69
+
70
+ task: SamplerTask = SamplerTask(sample_id, params, objfunc, static_parameters, url, files, metainfo, conf)
71
+ futures.append(executor.submit(thread_function, task))
72
+ # for future in concurrent.futures.as_completed(futures):
73
+ # pass
74
+ num_finished: int = 0
75
+ percentage: float
76
+ last_percentage: float = 0
77
+ for future in concurrent.futures.as_completed(futures):
78
+ try:
79
+ successful, task = future.result()
80
+
81
+ if successful:
82
+ trace[task.task_id] = (task.parameters, task.result)
83
+ trace_writer.append_sample(task.task_id, task.parameters, task.result)
84
+ else:
85
+ print("Failed to successfully execute task: {}", task.task_id, flush=True)
86
+ except asyncio.CancelledError as ce:
87
+ pass
88
+ except asyncio.InvalidStateError as ise:
89
+ pass
90
+ except Exception as ex:
91
+ print(ex, flush=True)
92
+
93
+ num_finished = num_finished + 1
94
+ percentage = math.trunc(num_finished / count * 1000) / 10
95
+ if percentage > last_percentage:
96
+ last_percentage = percentage
97
+ print("{}% Done {}".format(percentage, datetime.datetime.now()), flush=True)
98
+
99
+ return trace
@@ -0,0 +1,129 @@
1
+ from typing import List, Dict, Iterable
2
+ from recosu.sampling.sampler import run_sampler
3
+
4
+
5
+ def main():
6
+ steps: List[Dict[str, any]] = [
7
+ {
8
+ "param": [
9
+ {
10
+ "name": "Ksink",
11
+ "bounds": [
12
+ 0.0,
13
+ 5.0
14
+ ],
15
+ "default_value": 1.0,
16
+ "type": "float",
17
+ "calibration_strategy": "none"
18
+ },
19
+ {
20
+ "name": "a_rain",
21
+ "bounds": [
22
+ 5.0,
23
+ 10.0
24
+ ],
25
+ "default_value": 1.0,
26
+ "type": "float",
27
+ "calibration_strategy": "none"
28
+ },
29
+ {
30
+ "name": "flowRouteTA",
31
+ "bounds": [
32
+ 0.01,
33
+ 0.1
34
+ ],
35
+ "default_value": 1.0,
36
+ "type": "float",
37
+ "calibration_strategy": "none"
38
+ },
39
+ {
40
+ "name": "soilMaxDPS",
41
+ "bounds": [
42
+ 0.001,
43
+ 10.0
44
+ ],
45
+ "default_value": 1.0,
46
+ "type": "float",
47
+ "calibration_strategy": "none"
48
+ }
49
+ ],
50
+ "objfunc": [
51
+ {
52
+ "name": "ns",
53
+ "of": "ns",
54
+ "weight": 1.0,
55
+ "data": [
56
+ "orun5minall.csv/Runoff/orun[0]",
57
+ "output/csip_run/out/subDailyOutlet.csv/output/subDailyCatchmentSimRunoff"
58
+ ]
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+
64
+ args: Dict[str, any] = {
65
+ "param": [
66
+ {
67
+ "name": "startTime",
68
+ "value": "2011-06-08"
69
+ },
70
+ {
71
+ "name": "endTime",
72
+ "value": "2011-07-13"
73
+ },
74
+ {
75
+ "name": "dataStartTime",
76
+ "value": "2011-06-08"
77
+ },
78
+ {
79
+ "name": "dataEndTime",
80
+ "value": "2011-07-13"
81
+ },
82
+ {
83
+ "name": "cal_startTime",
84
+ "value": "2011-06-08"
85
+ },
86
+ {
87
+ "name": "cal_endTime",
88
+ "value": "2011-07-13"
89
+ },
90
+ {
91
+ "name": "parallelismThreads",
92
+ "value": "8"
93
+ },
94
+ {
95
+ "name": "flagLoadState",
96
+ "value": "True"
97
+ },
98
+ {
99
+ "name": "payload",
100
+ "value": "false"
101
+ },
102
+ {
103
+ "name": "project",
104
+ "value": "drake58hru-5min"
105
+ }
106
+ ],
107
+ "url": "http://csip.engr.colostate.edu:8087/csip-oms/m/ages/1.0.1_sub",
108
+ "files": []
109
+ }
110
+
111
+ conf: Dict[str, any] = {
112
+ "service_timeout": 400,
113
+ "http_retry": 5,
114
+ "allow_redirects": True,
115
+ "async_call": True,
116
+ "conn_timeout": 10,
117
+ "read_timeout": 400,
118
+ }
119
+
120
+ trace = run_sampler(steps, args, 10, 2, "halton", conf=conf, trace_file="halton_trace.csv", offset=5)
121
+ print(trace)
122
+
123
+
124
+ trace = run_sampler(steps, args, 10, 2, "random", conf=conf, trace_file="random_trace.csv")
125
+ print(trace)
126
+
127
+
128
+ if __name__ == "__main__":
129
+ main()
@@ -1,50 +0,0 @@
1
- mgpsogui/__init__.py,sha256=q7AfBjeJABnFtbsZnsObpUwaXKPDVYtz46G6MKXLF74,42
2
- mgpsogui/mgpsogui.py,sha256=NIZmyNcbwC8EgSwf1ubdMUSJscrIEgoD4jLYziqHQ-k,148
3
- mgpsogui/start.yaml,sha256=ZjCVLb-MLqAxrGRm9kA7_SDpa-45EuKIELNQ2QqCAiU,4713
4
- mgpsogui/gui/HomePage.py,sha256=ZV3I5eU8GFlVdAIRd_ygkrg49CWTKQAWOCKoBrcqV4g,25874
5
- mgpsogui/gui/OptionManager.py,sha256=bFN2jWJbx1Din3waOFLmbWGt0BXD_KthGJ8Mgue_FEE,11712
6
- mgpsogui/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- mgpsogui/gui/PlatformTab/PlatformTab.py,sha256=KyIoHlMKD9nfQqHeGJwRDA4RCoe4UykjB2l6xMTKK_M,10486
8
- mgpsogui/gui/PlatformTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- mgpsogui/gui/RunTab/RunTab.py,sha256=OjRteh5-ivHXRBam1M60JrxzkQEeqjstrUR93K25R8Y,2850
10
- mgpsogui/gui/RunTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- mgpsogui/gui/SetupTab/BoundsEditorWindow.py,sha256=_6_xEl46PY9MmNvpmoMNdNDbVav6ODwWSDROboy57Cs,2866
12
- mgpsogui/gui/SetupTab/BoundsList.py,sha256=L77UEaUJNiUE-ZsYIl44tWRb1zBfxaEQ-bAG1V5_IH0,12268
13
- mgpsogui/gui/SetupTab/CalibrationParametersView.py,sha256=ppVBHG3nphku9-P6Z8az-HTpgk8vHxnj-A5m80BZTgA,2784
14
- mgpsogui/gui/SetupTab/FunctionsList.py,sha256=tUqW43VWpxFpdo9UHaPvFQ0CtCo9mFI3mri52ikntrE,4092
15
- mgpsogui/gui/SetupTab/ListParametersView.py,sha256=wYcDcaooYkw-y7XW6dJUwhTWxLuUUOK5tGUFVHBf3ck,7352
16
- mgpsogui/gui/SetupTab/SetupTab.py,sha256=Doy_6xLq1BjhLTFHRQm7CAbpQzUnNJW4KkBcdfrxWoE,1881
17
- mgpsogui/gui/SetupTab/StaticParameterView.py,sha256=iEG-UpBBlAJabZo3MG768oLqOROjUPc23tKOSd47IUc,2739
18
- mgpsogui/gui/SetupTab/StepView.py,sha256=oG5Q-3xpTRP1f_PbNvohKctrbpD63zLAJzHD00bN44k,5531
19
- mgpsogui/gui/SetupTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- mgpsogui/gui/VisualizeTab/VisualizeTab.py,sha256=x40jLeGNfgeMaJaa8YKkIi1R374kRLONI0rok-_xQfY,3271
21
- mgpsogui/gui/VisualizeTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- mgpsogui/gui/images/IGOW 4 Logo.png,sha256=JixNXz5gOEj898VF-_PHthAlGU-6W-y9ucb4EVNPtjs,433752
23
- mgpsogui/gui/images/collapse.png,sha256=yicb16LaY7Nl5q9V8HHlht-Fbg5xU-l4_LJ_Arfmu1c,2989
24
- mgpsogui/gui/images/down.png,sha256=pspJkvUitD648C_2y8JLLD4Eagpk4MDEKQJGOO_yIaY,2654
25
- mgpsogui/gui/images/expand.png,sha256=YQyxXipCiNiZpTok5Y4juNU5davxoK7MTlRQI4Id27w,2922
26
- mgpsogui/gui/images/play.png,sha256=zbWtyZqvqCMT81bo6D3KhDPulWZH5lh1oCEs-X_X5Sk,2790
27
- mgpsogui/gui/images/refresh.png,sha256=B1nbOlky6nVhgSjDWT35FLZKW2LWxmliWWP_qZjZ7k8,4657
28
- mgpsogui/gui/images/refresh_hd.png,sha256=lprZtCNZ9JUm20SPwfaslr-VV4yzzmCPEB6oFfJm1tI,31242
29
- mgpsogui/gui/images/stop.png,sha256=JPuxXQerCGpLikcp7cAj3iLCOjULMYYZ2sZe0lArh68,2153
30
- mgpsogui/gui/images/trash.png,sha256=j8cf0kWbJd-4Jp20lUVV1o1NSeQ4v1Ej4gfcIA3DVRQ,2958
31
- mgpsogui/gui/images/up.png,sha256=AQvFWCUqSQNaQ1E6LKZ9zNfSvW6t4mgy8uswdg9T2Hg,2457
32
- mgpsogui/util/GraphGenerator.py,sha256=hEPhka0ZKQJ9DSSywDfwoXFQMsk3RHyG8QyTLOQnN4M,7851
33
- mgpsogui/util/PSORunner.py,sha256=7nNnKBUb8YfFL_2SjPqYugLD_SKHvLpCrp3PmtHfoRw,6328
34
- mgpsogui/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- mgpsogui/util/CTkToolTip/__init__.py,sha256=G1jxV55hGtGgwyC1sR-uUUdasDdh0XZgcI-aILgGYA0,225
36
- mgpsogui/util/CTkToolTip/ctk_tooltip.py,sha256=SZMovpQIGvdpDRbqCKl9SHs92DrFCO2MOYL2ifolvOE,6329
37
- mgpsogui/util/recosu/__init__.py,sha256=T7_iigIlowGbPOHLO3hwihjw2kbwIg6olOMhFhNiL38,236
38
- mgpsogui/util/recosu/pso/__init__.py,sha256=PQ548aEKVOk6MMzxxDg7yMO_1hHfoEoYLLkGLeij73Y,247
39
- mgpsogui/util/recosu/pso/csip_access.py,sha256=ZRE2mDmNSccOpFWAEfLBNkMxzB3zNJpwX-hkbehJQpE,3290
40
- mgpsogui/util/recosu/pso/pso.py,sha256=uqfi_uWvyhwdnWMicd2VN98RJrkfQ2Arz9n7w8noQQ8,13547
41
- mgpsogui/util/recosu/utils/__init__.py,sha256=TXz_TpNif2GeGu22pzTnkUQvaP-PmLQ9Sz4BgMIS6ig,196
42
- mgpsogui/util/recosu/utils/trace_writer.py,sha256=V9BJlOjCbNYGoXGEk3CF5wjifBxvarrMRXJMbDBWqI8,3023
43
- mgpsogui/util/recosu/utils/utils.py,sha256=QB8vftq3142ekG0ORjz0ZBHU5YknXbR0oTsrxrPAsF0,3951
44
- mgpsogui/util/recosu/utils/plot/__init__.py,sha256=h1KjM7_tNDv351pcwt8A6Ibb1jhwWyx5Gbu-zj-sI3Q,71
45
- mgpsogui/util/recosu/utils/plot/cost_steps.py,sha256=1Ce11AJyweWkmvjXPxEygzS-h8yVLmQEDLS53yjPLqQ,3779
46
- mg_pso_gui-0.1.13.dist-info/METADATA,sha256=TdfRT7u4G4Xe9uC3BlaCMkdH5goNVOAsUiohIuB9ctk,9458
47
- mg_pso_gui-0.1.13.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
48
- mg_pso_gui-0.1.13.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
49
- mg_pso_gui-0.1.13.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
50
- mg_pso_gui-0.1.13.dist-info/RECORD,,
Binary file