mg-pso-gui 0.1.36__tar.gz → 0.1.87__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/PKG-INFO +1 -1
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/PKG-INFO +1 -1
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/SOURCES.txt +1 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/HomePage.py +46 -4
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/OptionManager.py +21 -1
- mg-pso-gui-0.1.87/mgpsogui/gui/SetupTab/OptimalParameterView.py +47 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/SetupTab.py +13 -2
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/StepView.py +13 -6
- mg-pso-gui-0.1.87/mgpsogui/gui/VisualizeTab/SideBar.py +262 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/VisualizeTab/VisualizeTab.py +2 -2
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/GraphGenerator.py +164 -1
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/PSORunner.py +7 -43
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/pso/pso.py +5 -2
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/setup.py +1 -1
- mg-pso-gui-0.1.36/mgpsogui/gui/VisualizeTab/SideBar.py +0 -83
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/dependency_links.txt +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/entry_points.txt +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/requires.txt +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mg_pso_gui.egg-info/top_level.txt +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/PlatformTab/PlatformTab.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/PlatformTab/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/RunTab/RunTab.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/RunTab/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/BoundsEditorWindow.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/BoundsList.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/CalibrationParametersView.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/FunctionsList.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/ListParametersView.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/StaticParameterView.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/SetupTab/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/VisualizeTab/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/collapse.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/down.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/expand.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/play.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/refresh.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/refresh_hd.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/stop.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/test.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/trash.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/gui/images/up.png +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/mgpsogui.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/start.yaml +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/CTkToolTip/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/CTkToolTip/ctk_tooltip.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/pso/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/pso/csip_access.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/utils/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/utils/plot/__init__.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/utils/plot/cost_steps.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/utils/trace_writer.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/mgpsogui/util/recosu/utils/utils.py +0 -0
- {mg-pso-gui-0.1.36 → mg-pso-gui-0.1.87}/setup.cfg +0 -0
@@ -20,6 +20,7 @@ mgpsogui/gui/SetupTab/BoundsList.py
|
|
20
20
|
mgpsogui/gui/SetupTab/CalibrationParametersView.py
|
21
21
|
mgpsogui/gui/SetupTab/FunctionsList.py
|
22
22
|
mgpsogui/gui/SetupTab/ListParametersView.py
|
23
|
+
mgpsogui/gui/SetupTab/OptimalParameterView.py
|
23
24
|
mgpsogui/gui/SetupTab/SetupTab.py
|
24
25
|
mgpsogui/gui/SetupTab/StaticParameterView.py
|
25
26
|
mgpsogui/gui/SetupTab/StepView.py
|
@@ -67,6 +67,22 @@ class App(customtkinter.CTk):
|
|
67
67
|
|
68
68
|
self.selected_csv = tk.StringVar()
|
69
69
|
self.selected_csv.set("No files found...")
|
70
|
+
self.open_file = "None"
|
71
|
+
self.csv_data = None
|
72
|
+
|
73
|
+
self.selected_csv2 = tk.StringVar()
|
74
|
+
self.selected_csv2.set("No files found...")
|
75
|
+
self.open_file2 = "None"
|
76
|
+
self.csv_data2 = None
|
77
|
+
|
78
|
+
self.selected_x = tk.StringVar()
|
79
|
+
self.selected_x.set("time")
|
80
|
+
|
81
|
+
self.selected_y1 = tk.StringVar()
|
82
|
+
self.selected_y1.set("NONE")
|
83
|
+
|
84
|
+
self.selected_y2 = tk.StringVar()
|
85
|
+
self.selected_y2.set("NONE")
|
70
86
|
|
71
87
|
self.running_config = None
|
72
88
|
self.selected_graph_name = None
|
@@ -81,7 +97,8 @@ class App(customtkinter.CTk):
|
|
81
97
|
self.image_height = 720
|
82
98
|
self.progress_data = None
|
83
99
|
self.calibration_data = None
|
84
|
-
|
100
|
+
self.testing = False
|
101
|
+
|
85
102
|
# configure window
|
86
103
|
self.title("CSIP PSO")
|
87
104
|
self.geometry(f"{1920}x{1080}")
|
@@ -157,7 +174,7 @@ class App(customtkinter.CTk):
|
|
157
174
|
self.footer_progress_bar.grid(row=0, column=4, padx=(50, 100), pady=header_padding_y, sticky="ew")
|
158
175
|
self.footer_progress_bar.set(0)
|
159
176
|
|
160
|
-
self.algorithm_optionmenu = customtkinter.CTkOptionMenu(self.footer_frame, values=["PSO", "Halton"], width=50)
|
177
|
+
self.algorithm_optionmenu = customtkinter.CTkOptionMenu(self.footer_frame, variable=self.option_manager.get_arguments()['mode'], values=["PSO", "Halton"], width=50)
|
161
178
|
self.algorithm_optionmenu.grid(row=0, column=6, padx=header_padding_x, pady=header_padding_y)
|
162
179
|
self.algorithm_optionmenu.set("PSO")
|
163
180
|
|
@@ -167,7 +184,7 @@ class App(customtkinter.CTk):
|
|
167
184
|
self.run_button.grid(row=0, column=7, padx=(20, 5), pady=header_padding_y)
|
168
185
|
|
169
186
|
test_image = customtkinter.CTkImage(Image.open(os.path.join("./images", "test.png")), size=(20, 20))
|
170
|
-
self.test_button = customtkinter.CTkButton(self.footer_frame, text=None, width=30, image=test_image, command=self.
|
187
|
+
self.test_button = customtkinter.CTkButton(self.footer_frame, text=None, width=30, image=test_image, command=self.run_test)
|
171
188
|
ctt(self.test_button, delay=0.1, alpha=0.95, message="Start Testing")
|
172
189
|
self.test_button.grid(row=0, column=8, padx=(5, 5), pady=header_padding_y)
|
173
190
|
|
@@ -305,6 +322,9 @@ class App(customtkinter.CTk):
|
|
305
322
|
self.calib_param_frame.clear()
|
306
323
|
self.calib_param_frame.render()
|
307
324
|
|
325
|
+
self.optimal_param_frame.clear()
|
326
|
+
self.optimal_param_frame.render()
|
327
|
+
|
308
328
|
info = self.option_manager.get_project_data()
|
309
329
|
folder = os.path.join(info['path'], info['name'])
|
310
330
|
self.HRU_data = pd.read_csv(os.path.join(folder, "results", "HRU_1.csv"), skiprows=3)
|
@@ -363,13 +383,24 @@ class App(customtkinter.CTk):
|
|
363
383
|
self.after(10, self.make_request)
|
364
384
|
self.after(3000, lambda: self.refresh_button.configure(fg_color=self.default_button_color))
|
365
385
|
|
386
|
+
def run_test(self):
|
387
|
+
self.testing = True
|
388
|
+
self.run()
|
389
|
+
|
366
390
|
def run(self):
|
367
391
|
metrics = self.option_manager.get_metrics()
|
368
392
|
self.running_config = metrics
|
369
393
|
|
394
|
+
if self.testing:
|
395
|
+
steps = metrics['steps']
|
396
|
+
for step in steps:
|
397
|
+
for param in step['param']:
|
398
|
+
param['default_value'] = param['optimal_value']
|
399
|
+
self.testing = False
|
400
|
+
|
370
401
|
self.progress_data = None
|
371
402
|
self.calibration_data = None
|
372
|
-
|
403
|
+
|
373
404
|
#self.progress_bar.configure(mode="indeterminnate")
|
374
405
|
#self.progress_bar.start()
|
375
406
|
self.footer_progress_bar.configure(mode="indeterminnate")
|
@@ -495,6 +526,17 @@ class App(customtkinter.CTk):
|
|
495
526
|
print("COSU " + cosu_line, flush=True)
|
496
527
|
except Empty:
|
497
528
|
break
|
529
|
+
|
530
|
+
while True:
|
531
|
+
try:
|
532
|
+
trace = results_queue.get_nowait()
|
533
|
+
|
534
|
+
print("TRACE " + str(trace), flush=True)
|
535
|
+
except Empty:
|
536
|
+
break
|
537
|
+
except Exception as e:
|
538
|
+
print("Some error happened when getting the trace!")
|
539
|
+
print(e)
|
498
540
|
|
499
541
|
if (os.path.exists(os.path.join(folder, 'output.txt'))):
|
500
542
|
with open(os.path.join(folder, 'output.txt'), 'r') as f:
|
@@ -11,6 +11,7 @@ class OptionManager():
|
|
11
11
|
self.project_data = {"name": "", "path": ""}
|
12
12
|
self.arguments = {"param": [],
|
13
13
|
"url": sv(),
|
14
|
+
"mode": sv(),
|
14
15
|
"files": {},
|
15
16
|
"calibration_parameters": []}
|
16
17
|
self.steps = []
|
@@ -19,6 +20,7 @@ class OptionManager():
|
|
19
20
|
def clear(self):
|
20
21
|
self.arguments['param'].clear()
|
21
22
|
self.arguments['url'].set("")
|
23
|
+
self.arguments['mode'].set("PSO")
|
22
24
|
self.arguments['files'] = {}
|
23
25
|
self.arguments['calibration_parameters'].clear()
|
24
26
|
self.steps = []
|
@@ -29,6 +31,9 @@ class OptionManager():
|
|
29
31
|
if ("url" in arguments):
|
30
32
|
self.arguments["url"].set(arguments["url"])
|
31
33
|
|
34
|
+
if ("mode" in arguments):
|
35
|
+
self.arguments["mode"].set(arguments["mode"])
|
36
|
+
|
32
37
|
if ("files" in arguments):
|
33
38
|
for file in arguments["files"]:
|
34
39
|
name = file["name"]
|
@@ -65,6 +70,7 @@ class OptionManager():
|
|
65
70
|
"name": sv(),
|
66
71
|
"bounds": (sv(), sv()),
|
67
72
|
"default_value": sv(),
|
73
|
+
"optimal_value": sv(),
|
68
74
|
"type": sv(),
|
69
75
|
"calibration_strategy": sv()
|
70
76
|
}
|
@@ -75,18 +81,27 @@ class OptionManager():
|
|
75
81
|
else:
|
76
82
|
param_obj["bounds"][0].set(0)
|
77
83
|
param_obj["bounds"][1].set(1)
|
84
|
+
|
78
85
|
if "type" in param:
|
79
86
|
param_obj["type"].set(param["type"])
|
80
87
|
else:
|
81
88
|
param_obj["type"].set("float")
|
89
|
+
|
82
90
|
if "default_value" in param:
|
83
91
|
param_obj["default_value"].set(param["default_value"])
|
84
92
|
else:
|
85
93
|
param_obj["default_value"].set(1)
|
94
|
+
|
95
|
+
if "optimal_value" in param:
|
96
|
+
param_obj["optimal_value"].set(param["optimal_value"])
|
97
|
+
else:
|
98
|
+
param_obj["optimal_value"].set(0)
|
99
|
+
|
86
100
|
if "calibration_strategy" in param:
|
87
101
|
param_obj["calibration_strategy"].set(param["calibration_strategy"])
|
88
102
|
else:
|
89
103
|
param_obj["calibration_strategy"].set("none")
|
104
|
+
|
90
105
|
obj["param"].append(param_obj)
|
91
106
|
|
92
107
|
for objfunc in step["objfunc"]:
|
@@ -135,17 +150,20 @@ class OptionManager():
|
|
135
150
|
max=1,
|
136
151
|
type="float",
|
137
152
|
default_value=1,
|
153
|
+
optimal_value=0,
|
138
154
|
calibration_strategy="none"):
|
139
155
|
obj = {
|
140
156
|
"name": sv(),
|
141
157
|
"bounds": (sv(), sv()),
|
142
158
|
"default_value": sv(),
|
159
|
+
"optimal_value": sv(),
|
143
160
|
"type": sv(),
|
144
161
|
"calibration_strategy": sv()
|
145
162
|
}
|
146
163
|
obj["name"].set(name)
|
147
164
|
obj["type"].set(type)
|
148
165
|
obj["default_value"].set(default_value)
|
166
|
+
obj["optimal_value"].set(optimal_value)
|
149
167
|
obj["calibration_strategy"].set(calibration_strategy)
|
150
168
|
obj["bounds"][0].set(min)
|
151
169
|
obj["bounds"][1].set(max)
|
@@ -227,7 +245,7 @@ class OptionManager():
|
|
227
245
|
result['service_parameters'] = {}
|
228
246
|
result['project_data'] = self.project_data
|
229
247
|
for key, value in self.arguments.items():
|
230
|
-
if key == 'url':
|
248
|
+
if key == 'url' or key == 'mode':
|
231
249
|
result['arguments'][key] = value.get()
|
232
250
|
elif key == 'files':
|
233
251
|
result['arguments'][key] = {}
|
@@ -257,6 +275,7 @@ class OptionManager():
|
|
257
275
|
'bounds': (float(param['bounds'][0].get()),
|
258
276
|
float(param['bounds'][1].get())),
|
259
277
|
'default_value': float(param['default_value'].get()),
|
278
|
+
'optimal_value': float(param['optimal_value'].get()),
|
260
279
|
'type': 'float',
|
261
280
|
'calibration_strategy': param['calibration_strategy'].get()
|
262
281
|
}
|
@@ -268,6 +287,7 @@ class OptionManager():
|
|
268
287
|
'bounds': (float(param['bounds'][0].get()),
|
269
288
|
float(param['bounds'][1].get())),
|
270
289
|
'default_value': param['default_value'].get(),
|
290
|
+
'optimal_value': param['optimal_value'].get(),
|
271
291
|
'type': 'list',
|
272
292
|
'calibration_strategy': param['calibration_strategy'].get()
|
273
293
|
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
from customtkinter import CTkScrollableFrame
|
2
|
+
from customtkinter import CTkFrame
|
3
|
+
from customtkinter import CTkLabel
|
4
|
+
from customtkinter import CTkButton
|
5
|
+
from customtkinter import CTkEntry
|
6
|
+
import tkinter as tk
|
7
|
+
|
8
|
+
global option_manager
|
9
|
+
|
10
|
+
class OptimalParameterView(CTkScrollableFrame):
|
11
|
+
def __init__(self, *args,
|
12
|
+
option_manager: None,
|
13
|
+
**kwargs):
|
14
|
+
super().__init__(*args, **kwargs)
|
15
|
+
|
16
|
+
self.option_manager = option_manager
|
17
|
+
|
18
|
+
self.render()
|
19
|
+
|
20
|
+
def clear(self):
|
21
|
+
self.containerFrame.destroy()
|
22
|
+
|
23
|
+
def render(self):
|
24
|
+
row = 0
|
25
|
+
|
26
|
+
self.containerFrame = CTkFrame(self)
|
27
|
+
self.containerFrame.grid(row=0, column=0, padx=(5, 5), pady=(5, 5), sticky="nsew")
|
28
|
+
self.containerFrame.grid_columnconfigure((0, 1), weight=1)
|
29
|
+
|
30
|
+
#CTkLabel(self.containerFrame, text="Name:").grid(row=row, column=0, columnspan=1, padx=5, pady=5, sticky="")
|
31
|
+
#CTkLabel(self.containerFrame, text="Value:").grid(row=row, column=1, columnspan=1, padx=5, pady=5, sticky="")
|
32
|
+
#row += 1
|
33
|
+
|
34
|
+
self.steps = self.option_manager.get_steps()
|
35
|
+
|
36
|
+
for step in self.steps:
|
37
|
+
name = step['name'].get()
|
38
|
+
CTkLabel(self.containerFrame, text=name).grid(row=row, column=0, columnspan=1, padx=5, pady=5, sticky="")
|
39
|
+
row += 1
|
40
|
+
|
41
|
+
for param in step['param']:
|
42
|
+
CTkEntry(self.containerFrame, textvariable=param['name']).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
|
43
|
+
|
44
|
+
bb = CTkEntry(self.containerFrame)
|
45
|
+
bb.grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
|
46
|
+
bb.configure(textvariable=param['optimal_value'])
|
47
|
+
row += 1
|
@@ -3,6 +3,7 @@
|
|
3
3
|
from . import StepView as sv
|
4
4
|
from . import StaticParameterView as spv
|
5
5
|
from . import CalibrationParametersView as cpv
|
6
|
+
from . import OptimalParameterView as opv
|
6
7
|
|
7
8
|
import customtkinter
|
8
9
|
|
@@ -15,10 +16,12 @@ def create_tab(self, tab):
|
|
15
16
|
self.paramtabview = customtkinter.CTkTabview(tab, bg_color="transparent", fg_color="transparent")
|
16
17
|
self.paramtabview.grid(row=0, column=1, padx=(0, 0), pady=(10, 10), sticky="nsew")
|
17
18
|
|
18
|
-
tab1 = "Static
|
19
|
-
tab2 = "Calibration
|
19
|
+
tab1 = "Static"
|
20
|
+
tab2 = "Calibration"
|
21
|
+
tab3 = "Optimal Parameters"
|
20
22
|
self.paramtabview.add(tab1)
|
21
23
|
self.paramtabview.add(tab2)
|
24
|
+
self.paramtabview.add(tab3)
|
22
25
|
|
23
26
|
self.paramtabview.tab(tab1).grid_columnconfigure(0, weight=1)
|
24
27
|
self.paramtabview.tab(tab1).grid_rowconfigure(0, weight=1)
|
@@ -26,6 +29,9 @@ def create_tab(self, tab):
|
|
26
29
|
self.paramtabview.tab(tab2).grid_columnconfigure(0, weight=1)
|
27
30
|
self.paramtabview.tab(tab2).grid_rowconfigure(0, weight=1)
|
28
31
|
|
32
|
+
self.paramtabview.tab(tab3).grid_columnconfigure(0, weight=1)
|
33
|
+
self.paramtabview.tab(tab3).grid_rowconfigure(0, weight=1)
|
34
|
+
|
29
35
|
self.static_param_frame = spv.StaticParameterView(self.paramtabview.tab(tab1), option_manager=self.option_manager)
|
30
36
|
self.static_param_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
31
37
|
self.static_param_frame.grid_columnconfigure(0, weight=1)
|
@@ -36,6 +42,11 @@ def create_tab(self, tab):
|
|
36
42
|
self.calib_param_frame.grid_columnconfigure(0, weight=1)
|
37
43
|
self.calib_param_frame.grid_rowconfigure(0, weight=1)
|
38
44
|
|
45
|
+
self.optimal_param_frame = opv.OptimalParameterView(self.paramtabview.tab(tab3), option_manager=self.option_manager)
|
46
|
+
self.optimal_param_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
47
|
+
self.optimal_param_frame.grid_columnconfigure(0, weight=1)
|
48
|
+
self.optimal_param_frame.grid_rowconfigure(0, weight=1)
|
49
|
+
|
39
50
|
self.steps_frame = sv.StepView(tab, label_text="Group Editor", option_manager=self.option_manager)
|
40
51
|
self.steps_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
41
52
|
self.steps_frame.grid_columnconfigure(0, weight=1)
|
@@ -64,6 +64,7 @@ class StepView(CTkScrollableFrame):
|
|
64
64
|
self.containerFrame.grid_columnconfigure((0, 1), weight=1)
|
65
65
|
|
66
66
|
self.steps = self.option_manager.get_steps()
|
67
|
+
self.mode = self.option_manager.get_arguments()['mode'].get()
|
67
68
|
|
68
69
|
for step in self.steps:
|
69
70
|
|
@@ -88,10 +89,11 @@ class StepView(CTkScrollableFrame):
|
|
88
89
|
|
89
90
|
CTkEntry(self.containerFrame, textvariable=step['name'], width=500).grid(row=row, column=0, padx=(20, 20), pady=(20, 20), sticky="nsw")
|
90
91
|
#CTkLabel(self.containerFrame, textvariable=step['message']).grid(row=row, column=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
if (self.mode == "PSO"):
|
93
|
+
CTkButton(button_container, width=30, text=None, image=expand_image if not step['open'] else collapse_image, command=expand_func).grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="nsew")
|
94
|
+
CTkButton(button_container, width=30, text=None, image=up_image, state="disabled" if index==0 else "normal", fg_color="gray" if index==0 else None, command=up_func).grid(row=0, column=1, padx=(10, 10), pady=(10, 10), sticky="nsew")
|
95
|
+
CTkButton(button_container, width=30, text=None, image=down_image, state="disabled" if index==(len(self.steps)-1) else "normal", fg_color="gray" if index==(len(self.steps)-1) else None, command=down_func).grid(row=0, column=2, padx=(10, 10), pady=(10, 10), sticky="nsew")
|
96
|
+
CTkButton(button_container, width=30, text=None, image=trash_image, command=remove_func).grid(row=0, column=3, padx=(10, 10), pady=(10, 10), sticky="nsew")
|
95
97
|
|
96
98
|
row += 1
|
97
99
|
|
@@ -112,7 +114,12 @@ class StepView(CTkScrollableFrame):
|
|
112
114
|
|
113
115
|
row += 1
|
114
116
|
index += 1
|
117
|
+
|
118
|
+
if (self.mode != "PSO"):
|
119
|
+
break
|
115
120
|
|
116
121
|
# Create an "Add step button that is centered
|
117
|
-
|
118
|
-
|
122
|
+
|
123
|
+
if (self.mode == "PSO" or len(self.steps) == 0):
|
124
|
+
CTkButton(self.containerFrame, text="Add Group", command=self.create_new_step).grid(
|
125
|
+
row=row, columnspan=2, column=0, padx=(10, 10), pady=(10, 10), sticky="ew")
|
@@ -0,0 +1,262 @@
|
|
1
|
+
from customtkinter import CTkScrollableFrame
|
2
|
+
from customtkinter import CTkFrame
|
3
|
+
from customtkinter import CTkLabel
|
4
|
+
from customtkinter import CTkButton
|
5
|
+
from customtkinter import CTkEntry
|
6
|
+
from customtkinter import CTkTextbox
|
7
|
+
from customtkinter import CTkImage
|
8
|
+
from customtkinter import CTkOptionMenu
|
9
|
+
from PIL import Image
|
10
|
+
import os
|
11
|
+
|
12
|
+
import pandas as pd
|
13
|
+
|
14
|
+
class SideBar(CTkScrollableFrame):
|
15
|
+
def __init__(self, *args,
|
16
|
+
option_manager: None,
|
17
|
+
home_page: None,
|
18
|
+
**kwargs):
|
19
|
+
super().__init__(*args, **kwargs)
|
20
|
+
|
21
|
+
self.option_manager = option_manager
|
22
|
+
self.home_page = home_page
|
23
|
+
|
24
|
+
self.render()
|
25
|
+
|
26
|
+
def clear(self):
|
27
|
+
self.containerFrame.destroy()
|
28
|
+
|
29
|
+
def refresh(self):
|
30
|
+
self.clear()
|
31
|
+
self.render()
|
32
|
+
|
33
|
+
def render(self):
|
34
|
+
|
35
|
+
self.containerFrame = CTkFrame(self, width=300, fg_color="transparent")
|
36
|
+
self.containerFrame.grid(row=0, column=0, padx=(
|
37
|
+
0, 0), pady=(0, 0), sticky="ew")
|
38
|
+
self.containerFrame.grid_columnconfigure(0, weight=1)
|
39
|
+
|
40
|
+
selected_graph = self.home_page.graph_selector_value.get()
|
41
|
+
|
42
|
+
if (selected_graph == "Best Cost Stacked"):
|
43
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
|
44
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
45
|
+
pass
|
46
|
+
elif (selected_graph == "Best Cost by Round"):
|
47
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
|
48
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
49
|
+
pass
|
50
|
+
elif (selected_graph == "Iteration Table"):
|
51
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
|
52
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
53
|
+
pass
|
54
|
+
elif (selected_graph == "Calibrated Parameters"):
|
55
|
+
#self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
|
56
|
+
#self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
57
|
+
pass
|
58
|
+
elif (selected_graph == "Custom CSV"):
|
59
|
+
|
60
|
+
info = self.option_manager.get_project_data()
|
61
|
+
folder = os.path.join(info['path'], info['name'])
|
62
|
+
if not os.path.exists(folder):
|
63
|
+
os.makedirs(folder)
|
64
|
+
|
65
|
+
# Get all CSV files in the folder and add their paths to a list
|
66
|
+
path_map = {}
|
67
|
+
name_list = []
|
68
|
+
for root, dirs, files in os.walk(folder):
|
69
|
+
for file in files:
|
70
|
+
if file.endswith(".csv"):
|
71
|
+
name = file.replace(".csv", "")
|
72
|
+
name_list.append(name)
|
73
|
+
path_map[name] = os.path.join(root, file)
|
74
|
+
|
75
|
+
if (len(name_list) == 0):
|
76
|
+
name_list.append("No files found...")
|
77
|
+
else:
|
78
|
+
if (self.home_page.selected_csv.get() not in name_list):
|
79
|
+
self.home_page.selected_csv.set(name_list[0])
|
80
|
+
|
81
|
+
file_label = CTkLabel(self.containerFrame, text="CSV File:")
|
82
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
83
|
+
|
84
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv, command=self.home_page.update_graph)
|
85
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
86
|
+
|
87
|
+
selected_file = self.home_page.selected_csv.get()
|
88
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
89
|
+
self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
|
90
|
+
print(self.home_page.csv_data)
|
91
|
+
self.home_page.open_file = selected_file
|
92
|
+
|
93
|
+
if (self.home_page.csv_data is not None):
|
94
|
+
# Get all column names of CSV
|
95
|
+
columns = self.home_page.csv_data["data"].columns
|
96
|
+
|
97
|
+
x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
|
98
|
+
x_axis_label.grid(row=2, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
99
|
+
|
100
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_x, command=self.home_page.update_graph)
|
101
|
+
self.home_page.csv_x_selector.grid(row=3, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
102
|
+
|
103
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
104
|
+
self.home_page.csv_x_selector.set(columns[1])
|
105
|
+
|
106
|
+
y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
107
|
+
y1_axis_label.grid(row=4, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
108
|
+
|
109
|
+
self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y1, command=self.home_page.update_graph)
|
110
|
+
self.home_page.csv_y1_selector.grid(row=5, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
111
|
+
|
112
|
+
if (self.home_page.csv_y1_selector.get() not in columns):
|
113
|
+
self.home_page.csv_y1_selector.set(columns[2])
|
114
|
+
|
115
|
+
y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
|
116
|
+
y2_axis_label.grid(row=6, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
117
|
+
|
118
|
+
self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y2, command=self.home_page.update_graph)
|
119
|
+
self.home_page.csv_y2_selector.grid(row=7, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
120
|
+
|
121
|
+
if (self.home_page.csv_y2_selector.get() not in columns):
|
122
|
+
self.home_page.csv_y2_selector.set(columns[3])
|
123
|
+
|
124
|
+
elif (selected_graph == "Compare CSV"):
|
125
|
+
info = self.option_manager.get_project_data()
|
126
|
+
folder = os.path.join(info['path'], info['name'])
|
127
|
+
if not os.path.exists(folder):
|
128
|
+
os.makedirs(folder)
|
129
|
+
|
130
|
+
# Get all CSV files in the folder and add their paths to a list
|
131
|
+
path_map = {}
|
132
|
+
name_list = []
|
133
|
+
for root, dirs, files in os.walk(folder):
|
134
|
+
for file in files:
|
135
|
+
if file.endswith(".csv"):
|
136
|
+
name = file.replace(".csv", "")
|
137
|
+
name_list.append(name)
|
138
|
+
path_map[name] = os.path.join(root, file)
|
139
|
+
|
140
|
+
if (len(name_list) == 0):
|
141
|
+
name_list.append("No files found...")
|
142
|
+
else:
|
143
|
+
if (self.home_page.selected_csv.get() not in name_list):
|
144
|
+
self.home_page.selected_csv.set(name_list[0])
|
145
|
+
if (self.home_page.selected_csv2.get() not in name_list):
|
146
|
+
self.home_page.selected_csv2.set(name_list[0])
|
147
|
+
|
148
|
+
file_label = CTkLabel(self.containerFrame, text="CSV Files:")
|
149
|
+
file_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
150
|
+
|
151
|
+
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv, command=self.home_page.update_graph)
|
152
|
+
self.home_page.csv_file_selector.grid(row=1, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
153
|
+
|
154
|
+
self.home_page.csv_file_selector2 = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv2, command=self.home_page.update_graph)
|
155
|
+
self.home_page.csv_file_selector2.grid(row=2, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
156
|
+
|
157
|
+
selected_file = self.home_page.selected_csv.get()
|
158
|
+
if (selected_file in path_map and selected_file != self.home_page.open_file):
|
159
|
+
self.home_page.csv_data = self.load_special_csv(path_map[selected_file])
|
160
|
+
print(self.home_page.csv_data)
|
161
|
+
self.home_page.open_file = selected_file
|
162
|
+
|
163
|
+
selected_file2 = self.home_page.selected_csv2.get()
|
164
|
+
if (selected_file2 in path_map and selected_file2 != self.home_page.open_file2):
|
165
|
+
self.home_page.csv_data2 = self.load_special_csv(path_map[selected_file2])
|
166
|
+
print(self.home_page.csv_data2)
|
167
|
+
self.home_page.open_file2 = selected_file2
|
168
|
+
|
169
|
+
if (self.home_page.csv_data is not None and self.home_page.csv_data2 is not None):
|
170
|
+
# Get all column names of CSV
|
171
|
+
columns = self.home_page.csv_data["data"].columns
|
172
|
+
columns2 = self.home_page.csv_data2["data"].columns
|
173
|
+
|
174
|
+
x_axis_label = CTkLabel(self.containerFrame, text="X Axis:")
|
175
|
+
x_axis_label.grid(row=3, column=0, padx=(20, 20), pady=(40, 5), sticky="w")
|
176
|
+
|
177
|
+
self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_x, command=self.home_page.update_graph)
|
178
|
+
self.home_page.csv_x_selector.grid(row=4, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
179
|
+
|
180
|
+
if (self.home_page.csv_x_selector.get() not in columns):
|
181
|
+
self.home_page.csv_x_selector.set(columns[1])
|
182
|
+
|
183
|
+
y1_axis_label = CTkLabel(self.containerFrame, text="Y Axis:")
|
184
|
+
y1_axis_label.grid(row=5, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
185
|
+
|
186
|
+
self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y1, command=self.home_page.update_graph)
|
187
|
+
self.home_page.csv_y1_selector.grid(row=6, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
188
|
+
|
189
|
+
if (self.home_page.csv_y1_selector.get() not in columns):
|
190
|
+
self.home_page.csv_y1_selector.set(columns[2])
|
191
|
+
|
192
|
+
y2_axis_label = CTkLabel(self.containerFrame, text="Secondary Y Axis:")
|
193
|
+
y2_axis_label.grid(row=7, column=0, padx=(20, 20), pady=(20, 5), sticky="w")
|
194
|
+
|
195
|
+
self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns2, variable=self.home_page.selected_y2, command=self.home_page.update_graph)
|
196
|
+
self.home_page.csv_y2_selector.grid(row=8, column=0, padx=(20, 20), pady=(5, 5), sticky="ew")
|
197
|
+
|
198
|
+
if (self.home_page.csv_y2_selector.get() not in columns2):
|
199
|
+
self.home_page.csv_y2_selector.set(columns2[2])
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
def load_special_csv(self, file_path):
|
204
|
+
file_metadata = {}
|
205
|
+
data_metadata = {}
|
206
|
+
mode = "file_metadata"
|
207
|
+
columns = []
|
208
|
+
data_lines = []
|
209
|
+
|
210
|
+
with open(file_path, "r") as file:
|
211
|
+
lines = file.readlines()
|
212
|
+
|
213
|
+
if (not lines[0].startswith("@")):
|
214
|
+
return {
|
215
|
+
"file_attributes": {},
|
216
|
+
"data_attributes": {},
|
217
|
+
"data": pd.read_csv(file_path)
|
218
|
+
}
|
219
|
+
|
220
|
+
for line in lines:
|
221
|
+
if (line.startswith("@H,")):
|
222
|
+
mode = "data_metadata"
|
223
|
+
columns = line.strip().rstrip(",").split(",")[1:]
|
224
|
+
continue
|
225
|
+
elif (line.startswith("@T,")):
|
226
|
+
mode = "file_metadata"
|
227
|
+
continue
|
228
|
+
elif (line.startswith(",") and mode == "data_metadata"):
|
229
|
+
mode = "file_data"
|
230
|
+
|
231
|
+
if (mode == "file_metadata"):
|
232
|
+
try:
|
233
|
+
key, value = line.strip().rstrip(",").split(",")
|
234
|
+
file_metadata[key] = value
|
235
|
+
except:
|
236
|
+
pass
|
237
|
+
|
238
|
+
elif (mode == "data_metadata"):
|
239
|
+
try:
|
240
|
+
values = line.strip().rstrip(",").split(",")
|
241
|
+
key = values[0]
|
242
|
+
values = values[1:]
|
243
|
+
if len(values) == len(columns):
|
244
|
+
data_metadata[key] = {}
|
245
|
+
for i in range(len(columns)):
|
246
|
+
data_metadata[key][columns[i]] = values[i]
|
247
|
+
except:
|
248
|
+
pass
|
249
|
+
|
250
|
+
elif (mode == "file_data"):
|
251
|
+
try:
|
252
|
+
values = line.strip().rstrip(",").split(",")[1:]
|
253
|
+
if len(values) == len(columns):
|
254
|
+
data_lines.append(values)
|
255
|
+
except:
|
256
|
+
pass
|
257
|
+
|
258
|
+
return {
|
259
|
+
"file_attributes": file_metadata,
|
260
|
+
"data_attributes": data_metadata,
|
261
|
+
"data": pd.DataFrame(data_lines, columns=columns)
|
262
|
+
}
|
@@ -61,11 +61,11 @@ def create_tab(self, tab):
|
|
61
61
|
self.graph_container.grid_columnconfigure(0, weight=1)
|
62
62
|
self.graph_container.grid_rowconfigure(0, weight=1)
|
63
63
|
|
64
|
-
self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table", "Custom CSV"], variable=self.graph_selector_value, command=self.update_graph)
|
64
|
+
self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table", "Custom CSV", "Compare CSV"], variable=self.graph_selector_value, command=self.update_graph)
|
65
65
|
self.graph_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
66
66
|
|
67
67
|
# Create SideBar
|
68
|
-
self.vis_sidebar = SideBar.SideBar(self.graph_sidebar, option_manager=self.option_manager, home_page=self, fg_color="transparent"
|
68
|
+
self.vis_sidebar = SideBar.SideBar(self.graph_sidebar, option_manager=self.option_manager, home_page=self, fg_color="transparent")
|
69
69
|
self.vis_sidebar.grid(row=1, column=0, rowspan=8, padx=(0, 0), pady=(0, 0), sticky="nsew")
|
70
70
|
|
71
71
|
# Add a button to call open_graph_in_browser
|
@@ -5,6 +5,7 @@ import numpy as np
|
|
5
5
|
import os
|
6
6
|
from PIL import Image, ImageTk
|
7
7
|
import customtkinter
|
8
|
+
import traceback
|
8
9
|
|
9
10
|
def generate_graphs(HomePage):
|
10
11
|
try:
|
@@ -26,6 +27,12 @@ def generate_graphs(HomePage):
|
|
26
27
|
elif (selected_graph == "Calibrated Parameters"):
|
27
28
|
HomePage.selected_graph_name = "calibrated_params_by_round"
|
28
29
|
calibrated_params_by_round(HomePage.running_config['steps'], HomePage.calibration_data, HomePage.option_manager)
|
30
|
+
elif (selected_graph == "Custom CSV"):
|
31
|
+
HomePage.selected_graph_name = "custom_csv"
|
32
|
+
custom_csv(HomePage, HomePage.option_manager)
|
33
|
+
elif (selected_graph == "Compare CSV"):
|
34
|
+
HomePage.selected_graph_name = "compare_csv"
|
35
|
+
compare_csv(HomePage, HomePage.option_manager)
|
29
36
|
|
30
37
|
image_path = os.path.join(folder, HomePage.selected_graph_name + ".png")
|
31
38
|
|
@@ -36,7 +43,10 @@ def generate_graphs(HomePage):
|
|
36
43
|
HomePage.graph_image = customtkinter.CTkImage(HomePage.graph_image_obj, size=(HomePage.image_width * HomePage.image_scale, HomePage.image_height * HomePage.image_scale))
|
37
44
|
HomePage.graph_label.configure(image=HomePage.graph_image)
|
38
45
|
except Exception as e:
|
39
|
-
|
46
|
+
print(f"An exception occurred in Graph Generator: {str(e)}")
|
47
|
+
print(f"Exception type: {type(e).__name__}")
|
48
|
+
print("Traceback:")
|
49
|
+
traceback.print_exc()
|
40
50
|
|
41
51
|
def best_cost_stacked(config, dataframe, option_manager):
|
42
52
|
fig = go.Figure()
|
@@ -272,4 +282,157 @@ def calibrated_params_by_round(config, list_of_objs, option_manager):
|
|
272
282
|
with open(os.path.join(folder, "calibrated_params_by_round.html"), "w") as f:
|
273
283
|
f.write(html)
|
274
284
|
|
285
|
+
return fig
|
286
|
+
|
287
|
+
def custom_csv(homepage, option_manager):
|
288
|
+
fig = go.Figure()
|
289
|
+
|
290
|
+
data = homepage.csv_data["data"]
|
291
|
+
|
292
|
+
x = homepage.csv_x_selector.get()
|
293
|
+
val = homepage.csv_y1_selector.get()
|
294
|
+
val2 = homepage.csv_y2_selector.get()
|
295
|
+
|
296
|
+
xx = None
|
297
|
+
if x == "time":
|
298
|
+
xx = pd.to_datetime(data["time"], format='%Y-%m-%d', errors='coerce')
|
299
|
+
elif x == "date":
|
300
|
+
xx = pd.to_datetime(data["date"], format='%d-%m-%Y', errors='coerce')
|
301
|
+
else:
|
302
|
+
xx = pd.to_numeric(data[x], errors="coerce")
|
303
|
+
|
304
|
+
yy = pd.to_numeric(data[val], errors="coerce")
|
305
|
+
|
306
|
+
yy_unit = "-"
|
307
|
+
if "Unit" in homepage.csv_data["data_attributes"]:
|
308
|
+
yy_unit = homepage.csv_data["data_attributes"]["Unit"][val]
|
309
|
+
|
310
|
+
yy2 = pd.to_numeric(data[val2], errors="coerce")
|
311
|
+
|
312
|
+
yy2_unit = "-"
|
313
|
+
if "Unit" in homepage.csv_data["data_attributes"]:
|
314
|
+
yy2_unit = homepage.csv_data["data_attributes"]["Unit"][val2]
|
315
|
+
|
316
|
+
fig.add_trace(go.Scatter(x=xx, y=yy, name=val))
|
317
|
+
fig.add_trace(go.Scatter(x=xx, y=yy2, name=val2, yaxis='y2'))
|
318
|
+
|
319
|
+
fig.update_layout(
|
320
|
+
title="",
|
321
|
+
xaxis_title=x,
|
322
|
+
yaxis_title=val,
|
323
|
+
font=dict(color='white'),
|
324
|
+
paper_bgcolor='rgba(42, 42, 42, 0)',
|
325
|
+
plot_bgcolor='rgb(62, 62, 62)',
|
326
|
+
xaxis=dict(
|
327
|
+
gridcolor='rgb(72, 72, 72)',
|
328
|
+
gridwidth=1
|
329
|
+
),
|
330
|
+
yaxis=dict(
|
331
|
+
title=val + " (" + str(yy_unit) + ")",
|
332
|
+
autorange=True,
|
333
|
+
gridcolor='rgb(72, 72, 72)',
|
334
|
+
gridwidth=0.1
|
335
|
+
),
|
336
|
+
yaxis2=dict(
|
337
|
+
title=val2 + " (" + str(yy2_unit) + ")",
|
338
|
+
overlaying='y',
|
339
|
+
side='right'
|
340
|
+
)
|
341
|
+
)
|
342
|
+
|
343
|
+
info = option_manager.get_project_data()
|
344
|
+
folder = os.path.join(info['path'], info['name'])
|
345
|
+
|
346
|
+
if not os.path.exists(folder):
|
347
|
+
os.makedirs(folder)
|
348
|
+
|
349
|
+
fig.write_image(os.path.join(folder, "custom_csv.png"), width=1280, height=720)
|
350
|
+
fig.write_html(os.path.join(folder, "custom_csv.html"), include_plotlyjs='cdn', auto_open=False)
|
351
|
+
with open(os.path.join(folder, "custom_csv.html"), "r") as f:
|
352
|
+
html = f.read()
|
353
|
+
html = html.replace("<body>", "<body bgcolor='#2a2a2a'>")
|
354
|
+
with open(os.path.join(folder, "custom_csv.html"), "w") as f:
|
355
|
+
f.write(html)
|
356
|
+
|
357
|
+
return fig
|
358
|
+
|
359
|
+
def compare_csv(homepage, option_manager):
|
360
|
+
fig = go.Figure()
|
361
|
+
|
362
|
+
data = homepage.csv_data["data"]
|
363
|
+
data2 = homepage.csv_data2["data"]
|
364
|
+
|
365
|
+
x = homepage.csv_x_selector.get()
|
366
|
+
val = homepage.csv_y1_selector.get()
|
367
|
+
val2 = homepage.csv_y2_selector.get()
|
368
|
+
|
369
|
+
xx = None
|
370
|
+
if x == "time":
|
371
|
+
xx = pd.to_datetime(data["time"], format='%Y-%m-%d', errors='coerce')
|
372
|
+
elif x == "date":
|
373
|
+
xx = pd.to_datetime(data["date"], format='%d-%m-%Y', errors='coerce')
|
374
|
+
else:
|
375
|
+
xx = pd.to_numeric(data[x], errors="coerce")
|
376
|
+
|
377
|
+
yy = pd.to_numeric(data[val], errors="coerce")
|
378
|
+
|
379
|
+
xx2 = None
|
380
|
+
if x == "time":
|
381
|
+
xx2 = pd.to_datetime(data2["time"], format='%Y-%m-%d', errors='coerce')
|
382
|
+
elif x == "date":
|
383
|
+
xx2 = pd.to_datetime(data2["date"], format='%d-%m-%Y', errors='coerce')
|
384
|
+
else:
|
385
|
+
xx2 = pd.to_numeric(data2[x], errors="coerce")
|
386
|
+
|
387
|
+
yy_unit = "-"
|
388
|
+
if "Unit" in homepage.csv_data["data_attributes"]:
|
389
|
+
yy_unit = homepage.csv_data["data_attributes"]["Unit"][val]
|
390
|
+
|
391
|
+
yy2 = pd.to_numeric(data[val2], errors="coerce")
|
392
|
+
|
393
|
+
yy2_unit = "-"
|
394
|
+
if "Unit" in homepage.csv_data["data_attributes"]:
|
395
|
+
yy2_unit = homepage.csv_data["data_attributes"]["Unit"][val2]
|
396
|
+
|
397
|
+
fig.add_trace(go.Scatter(x=xx, y=yy, name=val))
|
398
|
+
fig.add_trace(go.Scatter(x=xx2, y=yy2, name=val2, yaxis='y2'))
|
399
|
+
|
400
|
+
fig.update_layout(
|
401
|
+
title="",
|
402
|
+
xaxis_title=x,
|
403
|
+
yaxis_title=val,
|
404
|
+
font=dict(color='white'),
|
405
|
+
paper_bgcolor='rgba(42, 42, 42, 0)',
|
406
|
+
plot_bgcolor='rgb(62, 62, 62)',
|
407
|
+
xaxis=dict(
|
408
|
+
gridcolor='rgb(72, 72, 72)',
|
409
|
+
gridwidth=1
|
410
|
+
),
|
411
|
+
yaxis=dict(
|
412
|
+
title=val + " (" + str(yy_unit) + ")",
|
413
|
+
autorange=True,
|
414
|
+
gridcolor='rgb(72, 72, 72)',
|
415
|
+
gridwidth=0.1
|
416
|
+
),
|
417
|
+
yaxis2=dict(
|
418
|
+
title=val2 + " (" + str(yy2_unit) + ")",
|
419
|
+
overlaying='y',
|
420
|
+
side='right'
|
421
|
+
)
|
422
|
+
)
|
423
|
+
|
424
|
+
info = option_manager.get_project_data()
|
425
|
+
folder = os.path.join(info['path'], info['name'])
|
426
|
+
|
427
|
+
if not os.path.exists(folder):
|
428
|
+
os.makedirs(folder)
|
429
|
+
|
430
|
+
fig.write_image(os.path.join(folder, "compare_csv.png"), width=1280, height=720)
|
431
|
+
fig.write_html(os.path.join(folder, "compare_csv.html"), include_plotlyjs='cdn', auto_open=False)
|
432
|
+
with open(os.path.join(folder, "compare_csv.html"), "r") as f:
|
433
|
+
html = f.read()
|
434
|
+
html = html.replace("<body>", "<body bgcolor='#2a2a2a'>")
|
435
|
+
with open(os.path.join(folder, "compare_csv.html"), "w") as f:
|
436
|
+
f.write(html)
|
437
|
+
|
275
438
|
return fig
|
@@ -88,55 +88,19 @@ def run_process(stdout_queue, stderr_queue, results_queue, cosu_queue, data, fol
|
|
88
88
|
'http_conn_timeout': int(calibration_map['conn_timeout']),
|
89
89
|
'http_read_timeout': int(calibration_map['read_timeout']),
|
90
90
|
'particles_fail': int(calibration_map['particles_fail'])
|
91
|
+
#,'step_trace': os.path.join(folder, 'trace.json')
|
91
92
|
},
|
92
93
|
result_queue = cosu_queue
|
93
94
|
)
|
94
95
|
|
96
|
+
results_queue.put(trace)
|
97
|
+
print(trace)
|
98
|
+
|
99
|
+
print("Finishing up...")
|
100
|
+
time.sleep(5)
|
95
101
|
|
96
102
|
stdour_thread.join()
|
97
103
|
stderr_thread.join()
|
98
104
|
|
99
105
|
sys.stdout = old_stdout
|
100
|
-
sys.stderr = old_stderr
|
101
|
-
results_queue.put((optimizer, trace))
|
102
|
-
|
103
|
-
def get_results():
|
104
|
-
request: Client = Client()
|
105
|
-
for name, value in parameters.items():
|
106
|
-
# if parameter name has a / in it assume that is a file based parameter and therefore value needs to be an array
|
107
|
-
if "/" in name and type(value) is not list:
|
108
|
-
request.add_data(name, [value])
|
109
|
-
else:
|
110
|
-
request.add_data(name, value)
|
111
|
-
|
112
|
-
conf = {
|
113
|
-
'service_timeout': 60.0 # (sec)
|
114
|
-
}
|
115
|
-
files: List[str] = [] #optional list of filenames
|
116
|
-
|
117
|
-
#Synchronous Call
|
118
|
-
result: Client = request.execute(CSIP_ENDPOINT, files=files, sync=True, conf=conf)
|
119
|
-
|
120
|
-
#Asynchronous Call
|
121
|
-
tsamp: float = 0
|
122
|
-
def callback(c: Client, progress: str):
|
123
|
-
tsamp2: float = time.time()
|
124
|
-
print('Halton Update {} - {} - {}'.format(halton_id, c.get_status(), tsamp2 - tsamp))
|
125
|
-
|
126
|
-
|
127
|
-
tsamp = time.time()
|
128
|
-
result: Client = request.execute_async(
|
129
|
-
CSIP_ENDPOINT,
|
130
|
-
files=files,
|
131
|
-
callback=callback,
|
132
|
-
first_poll=poll_time,
|
133
|
-
next_poll=poll_time,
|
134
|
-
conf=conf
|
135
|
-
)
|
136
|
-
# After recieving response
|
137
|
-
if result.is_finished():
|
138
|
-
print(result)
|
139
|
-
else:
|
140
|
-
print(result)
|
141
|
-
|
142
|
-
|
106
|
+
sys.stderr = old_stderr
|
@@ -168,7 +168,7 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
|
|
168
168
|
step_trace['min_rounds'] = min_rounds
|
169
169
|
step_trace['max_rounds'] = max_rounds
|
170
170
|
step_trace['iters'] = iters
|
171
|
-
step_trace['ftol'] = ftol
|
171
|
+
#step_trace['ftol'] = ftol BUG DOES NOT HANDLE -INF
|
172
172
|
step_trace['ftol_iter'] = ftol_iter
|
173
173
|
step_trace['rtol'] = rtol
|
174
174
|
step_trace['rtol_iter'] = rtol_iter
|
@@ -176,7 +176,7 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
|
|
176
176
|
step_trace['n_particles'] = n_particles
|
177
177
|
step_trace['n_steps'] = len(steps)
|
178
178
|
step_trace['steps'] = copy.deepcopy(steps)
|
179
|
-
step_trace['args'] = args
|
179
|
+
#step_trace['args'] = args BUG MUST BE REMOVED
|
180
180
|
|
181
181
|
if step_file is not None:
|
182
182
|
with open(step_file, "w") as fo:
|
@@ -336,4 +336,7 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
|
|
336
336
|
with open(step_file, "w") as fo:
|
337
337
|
json.dump(step_trace, fo)
|
338
338
|
|
339
|
+
result_queue.put("Step Trace")
|
340
|
+
result_queue.put(step_trace)
|
341
|
+
|
339
342
|
return optimizer, step_trace
|
@@ -1,83 +0,0 @@
|
|
1
|
-
from customtkinter import CTkScrollableFrame
|
2
|
-
from customtkinter import CTkFrame
|
3
|
-
from customtkinter import CTkLabel
|
4
|
-
from customtkinter import CTkButton
|
5
|
-
from customtkinter import CTkEntry
|
6
|
-
from customtkinter import CTkTextbox
|
7
|
-
from customtkinter import CTkImage
|
8
|
-
from customtkinter import CTkOptionMenu
|
9
|
-
from PIL import Image
|
10
|
-
import os
|
11
|
-
|
12
|
-
class SideBar(CTkScrollableFrame):
|
13
|
-
def __init__(self, *args,
|
14
|
-
option_manager: None,
|
15
|
-
home_page: None,
|
16
|
-
**kwargs):
|
17
|
-
super().__init__(*args, **kwargs)
|
18
|
-
|
19
|
-
self.option_manager = option_manager
|
20
|
-
self.home_page = home_page
|
21
|
-
|
22
|
-
self.render()
|
23
|
-
|
24
|
-
def clear(self):
|
25
|
-
self.containerFrame.destroy()
|
26
|
-
|
27
|
-
def refresh(self):
|
28
|
-
self.clear()
|
29
|
-
self.render()
|
30
|
-
|
31
|
-
def render(self):
|
32
|
-
|
33
|
-
self.containerFrame = CTkFrame(self, fg_color="transparent", bg_color="transparent")
|
34
|
-
self.containerFrame.grid(row=0, column=0, padx=(
|
35
|
-
0, 0), pady=(0, 0), width=300, sticky="nsew")
|
36
|
-
self.containerFrame.grid_columnconfigure(0, weight=1)
|
37
|
-
|
38
|
-
selected_graph = self.home_page.graph_selector_value.get()
|
39
|
-
|
40
|
-
if (selected_graph == "Best Cost Stacked"):
|
41
|
-
self.graph_label = CTkLabel(self.containerFrame, text="Best Cost Stacked")
|
42
|
-
self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
43
|
-
pass
|
44
|
-
elif (selected_graph == "Best Cost by Round"):
|
45
|
-
self.graph_label = CTkLabel(self.containerFrame, text="Best Cost by Round")
|
46
|
-
self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
47
|
-
pass
|
48
|
-
elif (selected_graph == "Iteration Table"):
|
49
|
-
self.graph_label = CTkLabel(self.containerFrame, text="Iteration Table")
|
50
|
-
self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
51
|
-
pass
|
52
|
-
elif (selected_graph == "Calibrated Parameters"):
|
53
|
-
self.graph_label = CTkLabel(self.containerFrame, text="Calibrated Parameters")
|
54
|
-
self.graph_label.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
55
|
-
elif (selected_graph == "Custom CSV"):
|
56
|
-
|
57
|
-
info = self.option_manager.get_project_data()
|
58
|
-
folder = os.path.join(info['path'], info['name'])
|
59
|
-
if not os.path.exists(folder):
|
60
|
-
os.makedirs(folder)
|
61
|
-
|
62
|
-
# Get all CSV files in the folder and add their paths to a list
|
63
|
-
path_list = []
|
64
|
-
name_list = []
|
65
|
-
for root, dirs, files in os.walk(folder):
|
66
|
-
for file in files:
|
67
|
-
if file.endswith(".csv"):
|
68
|
-
path_list.append(os.path.join(root, file))
|
69
|
-
name_list.append(file.replace(".csv", ""))
|
70
|
-
|
71
|
-
if (len(name_list) == 0):
|
72
|
-
name_list.append("No files found...")
|
73
|
-
else:
|
74
|
-
if (self.home_page.selected_csv.get() not in name_list):
|
75
|
-
self.home_page.selected_csv.set(name_list[0])
|
76
|
-
|
77
|
-
print("PATH LIST")
|
78
|
-
print(path_list)
|
79
|
-
print("NAME LIST")
|
80
|
-
print(name_list)
|
81
|
-
|
82
|
-
self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv, command=self.home_page.update_graph)
|
83
|
-
self.home_page.csv_file_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|