mg-pso-gui 0.1.40__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 (50) hide show
  1. {mg_pso_gui-0.1.40.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.40.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 +234 -238
  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 +90 -17
  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 +316 -25
  25. mgpsogui/gui/VisualizeTab/VisualizeTab.py +69 -8
  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/util/GraphGenerator.py +721 -50
  32. mgpsogui/util/PSORunner.py +615 -86
  33. mgpsogui/util/debug.py +559 -0
  34. mgpsogui/util/helpers.py +95 -0
  35. mgpsogui/util/recosu/__init__.py +2 -1
  36. mgpsogui/util/recosu/pso/pso.py +55 -11
  37. mgpsogui/util/recosu/sampling/__init__.py +16 -0
  38. mgpsogui/util/recosu/sampling/halton/__init__.py +0 -0
  39. mgpsogui/util/recosu/sampling/halton/halton.py +45 -0
  40. mgpsogui/util/recosu/sampling/halton/prime.py +82 -0
  41. mgpsogui/util/recosu/sampling/random/__init__.py +0 -0
  42. mgpsogui/util/recosu/sampling/random/random_sampler.py +34 -0
  43. mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
  44. mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
  45. mgpsogui/util/recosu/sampling/sampling.py +99 -0
  46. mgpsogui/util/sampler_test_driver.py +129 -0
  47. mg_pso_gui-0.1.40.dist-info/RECORD +0 -52
  48. mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
  49. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/entry_points.txt +0 -0
  50. {mg_pso_gui-0.1.40.dist-info → mg_pso_gui-0.2.75.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,11 @@ from customtkinter import CTkLabel
4
4
  from customtkinter import CTkButton
5
5
  from customtkinter import CTkEntry
6
6
  from customtkinter import CTkOptionMenu
7
+ from customtkinter import CTkImage
8
+ from .CustomFunctionEditorWindow import CustomFunctionEditorWindow as CFEW
9
+ import os
10
+ import PIL
11
+ from PIL import Image
7
12
  import tkinter as tk
8
13
 
9
14
  class FunctionsList(CTkFrame):
@@ -20,6 +25,10 @@ class FunctionsList(CTkFrame):
20
25
  self.edit_mode = False
21
26
  self.render()
22
27
 
28
+ def refresh(self, op=None):
29
+ self.clear()
30
+ self.render()
31
+
23
32
  def clear(self):
24
33
  self.containerFrame.destroy()
25
34
 
@@ -36,7 +45,7 @@ class FunctionsList(CTkFrame):
36
45
 
37
46
  row = 1
38
47
 
39
- funcs = self.option_manager.get_steps()[self.step_index]["objfunc"]
48
+ funcs = self.option_manager.get_steps()[self.step_index]["objective_functions"]
40
49
 
41
50
  index = 0
42
51
  for func in funcs:
@@ -47,19 +56,64 @@ class FunctionsList(CTkFrame):
47
56
 
48
57
  row += 1
49
58
 
59
+ columns = ["absdiff",
60
+ "absdifflog",
61
+ "ave",
62
+ "bias",
63
+ "fhf",
64
+ "ioa",
65
+ "ioa2",
66
+ "kge",
67
+ "kge09",
68
+ "mns",
69
+ "mse",
70
+ "ns",
71
+ "ns2log",
72
+ "nslog1p",
73
+ "nslog2",
74
+ "pbias",
75
+ "pmcc",
76
+ "rmse",
77
+ "trmse",
78
+ "custom"]
79
+
50
80
  CTkEntry(self.containerFrame, textvariable=func["name"]).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
51
- CTkEntry(self.containerFrame, textvariable=func["of"]).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
81
+ CTkOptionMenu(self.containerFrame, values=columns, variable=func["objective_function"], command=self.refresh).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
52
82
  CTkEntry(self.containerFrame, textvariable=func["weight"]).grid(row=row, column=2, padx=(5, 5), pady=(5, 5), sticky="ew")
53
83
 
54
84
  row += 1
85
+
86
+ if func["objective_function"].get() == "custom":
87
+
88
+ CTkLabel(self.containerFrame, text="Custom Function:").grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="nsew")
89
+ #CTkLabel(self.containerFrame, text="Target:").grid(row=row, column=2, padx=(5, 5), pady=(5, 5), sticky="nsew")
90
+
91
+ row += 1
92
+
93
+ CTkEntry(self.containerFrame, textvariable=func["custom_function"]).grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="ew")
94
+ #CTkOptionMenu(self.containerFrame, values=["Positive Best", "Zero Best"], variable=func["custom_function_goal"]).grid(row=row, column=2, padx=(5, 5), pady=(5, 5), sticky="ew")
95
+
96
+ def button_click_event(function_index):
97
+ dialog = CFEW(title="Edit Custom Function", step_index=self.step_index, function_index=function_index, option_manager=self.option_manager)
98
+
99
+
100
+ open_window = lambda event=None, function_index=index: (button_click_event(function_index))
101
+ expand_image = CTkImage(Image.open(os.path.join("./images", "expand.png")), size=(20, 20))
102
+ button = CTkButton(self.containerFrame, width=30, text=None, image=expand_image, command=open_window)
103
+ button.grid(row=row, column=3, padx=(5, 5), pady=(5, 5), sticky="new")
104
+
105
+
106
+ row += 1
55
107
 
56
- CTkLabel(self.containerFrame, text="Data:").grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="nsew")
108
+ CTkLabel(self.containerFrame, text="Observed and Simulated Data:").grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="nsew")
57
109
 
58
110
  row += 1
59
- for obj in func["data"]:
60
- CTkEntry(self.containerFrame, textvariable=obj).grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="nsew")
61
- row += 1
62
111
 
112
+ CTkEntry(self.containerFrame, textvariable=func["data_observed"]).grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="nsew")
113
+ row += 1
114
+ CTkEntry(self.containerFrame, textvariable=func["data_simulated"]).grid(row=row, column=0, columnspan=3, padx=(5, 5), pady=(5, 5), sticky="nsew")
115
+ row += 1
116
+
63
117
  if self.edit_mode:
64
118
  remove_func = lambda index=index: (self.clear(), self.option_manager.remove_function(self.step_index, index), self.render())
65
119
  dupe_func = lambda index=index: (self.clear(), self.option_manager.dupe_function(self.step_index, index), self.render())
@@ -3,24 +3,36 @@ from customtkinter import CTkFrame
3
3
  from customtkinter import CTkLabel
4
4
  from customtkinter import CTkButton
5
5
  from customtkinter import CTkEntry
6
+ from customtkinter import CTkOptionMenu
6
7
  import tkinter as tk
7
8
 
8
- global option_manager
9
-
10
- class StaticParameterView(CTkScrollableFrame):
9
+ class ListEditor(CTkFrame):
11
10
  def __init__(self, *args,
12
11
  option_manager: None,
12
+ columns: None,
13
+ parameter_name: None,
14
+ parameter_remove_func: None,
15
+ parameter_add_func: None,
16
+ title: None,
13
17
  **kwargs):
14
18
  super().__init__(*args, **kwargs)
15
19
 
16
20
  self.option_manager = option_manager
17
- self.key_values = option_manager.get_arguments()['param']
21
+ self.columns = columns
22
+ self.parameter_name = parameter_name
23
+ self.parameter_remove_func = parameter_remove_func
24
+ self.parameter_add_func = parameter_add_func
25
+ self.key_values = option_manager.get(self.parameter_name)
18
26
  self.edit_mode = False
27
+ self.title = title
19
28
 
20
29
  self.render()
21
30
 
22
31
  def clear(self):
23
32
  self.containerFrame.destroy()
33
+
34
+ def set_columns(self, columns):
35
+ self.columns = columns
24
36
 
25
37
  def toggle_edit_mode(self):
26
38
  self.clear()
@@ -31,24 +43,23 @@ class StaticParameterView(CTkScrollableFrame):
31
43
  row = 0
32
44
  index = 0
33
45
 
34
- self.containerFrame = CTkFrame(self)
35
- self.containerFrame.grid(row=0, column=0, padx=(5, 5), pady=(5, 5), sticky="nsew")
46
+ self.containerFrame = CTkFrame(self, fg_color="transparent")
47
+ self.containerFrame.grid(row=0, column=0, padx=(5, 5), pady=(5, 5), sticky="new")
36
48
  self.containerFrame.grid_columnconfigure((0, 1), weight=1)
37
49
 
38
- CTkLabel(self.containerFrame, text="Name:").grid(row=row, column=0, columnspan=1, padx=5, pady=5, sticky="")
39
- CTkLabel(self.containerFrame, text="Value:").grid(row=row, column=1, columnspan=1, padx=5, pady=5, sticky="")
50
+ CTkLabel(self.containerFrame, text=self.title).grid(row=row, column=0, columnspan=2, padx=5, pady=5, sticky="ew")
40
51
  row += 1
41
-
52
+
42
53
  for key_value_pair in self.key_values:
43
- CTkEntry(self.containerFrame, textvariable=self.key_values[index]["name"]).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
44
-
45
54
  if self.edit_mode:
46
- return_func = lambda index=index: (self.clear(), self.option_manager.remove_argument(index), self.render())
55
+ bb = CTkOptionMenu(self.containerFrame, values=self.columns, variable=self.key_values[index]["value"])
56
+ bb.grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
57
+
58
+ return_func = lambda index=index: (self.clear(), self.parameter_remove_func(index), self.render())
47
59
  CTkButton(self.containerFrame, text="Remove", command=return_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
48
60
  else:
49
- bb = CTkEntry(self.containerFrame)
50
- bb.grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
51
- bb.configure(textvariable=self.key_values[index]["value"])
61
+ bb = CTkOptionMenu(self.containerFrame, values=self.columns, variable=self.key_values[index]["value"])
62
+ bb.grid(row=row, column=0, columnspan=2, padx=(5, 5), pady=(5, 5), sticky="ew")
52
63
  row += 1
53
64
  index += 1
54
65
 
@@ -57,5 +68,5 @@ class StaticParameterView(CTkScrollableFrame):
57
68
  else:
58
69
  CTkButton(self.containerFrame, text="Edit", command=self.toggle_edit_mode).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
59
70
 
60
- add_key_func = lambda: (self.clear(), self.option_manager.add_argument("name", "value"), self.render())
71
+ add_key_func = lambda: (self.clear(), self.parameter_add_func("Param " + str(len(self.key_values)) , self.columns[2]), self.render())
61
72
  CTkButton(self.containerFrame, text="Add Parameter", command=add_key_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
@@ -26,8 +26,8 @@ class ListParametersView(CTkScrollableFrame):
26
26
  self.visual_name.set("name")
27
27
 
28
28
 
29
- self.name = self.option_manager.get_steps()[self.step_index]["param"][bound_index]["name"].get()
30
- self.default = self.option_manager.get_steps()[self.step_index]["param"][bound_index]["default_value"].get()
29
+ self.name = self.option_manager.get_steps()[self.step_index]["parameter_objects"][bound_index]["name"].get()
30
+ self.default = self.option_manager.get_steps()[self.step_index]["parameter_objects"][bound_index]["default_value"].get()
31
31
  try:
32
32
  if self.name != "" and self.default != "":
33
33
 
@@ -75,8 +75,9 @@ class ListParametersView(CTkScrollableFrame):
75
75
 
76
76
  def open_csv(self):
77
77
  # Shell out to the terminal and run "open ./example.html"
78
- info = self.option_manager.get_project_data()
79
- folder = os.path.join(info['path'], info['name'])
78
+ #info = self.option_manager.get_project_data()
79
+ #folder = os.path.join(info['path'], info['name'])
80
+ folder = self.option_manager.get_project_folder()
80
81
 
81
82
 
82
83
  path = self.visual_name.get()
@@ -182,5 +183,5 @@ class ListParametersView(CTkScrollableFrame):
182
183
 
183
184
  default_values = default_values[:-1] + "]"
184
185
 
185
- self.option_manager.get_steps()[self.step_index]["param"][self.bounds_index]["name"].set(visual_name)
186
- self.option_manager.get_steps()[self.step_index]["param"][self.bounds_index]["default_value"].set(default_values)
186
+ self.option_manager.get_steps()[self.step_index]["parameter_objects"][self.bounds_index]["name"].set(visual_name)
187
+ self.option_manager.get_steps()[self.step_index]["parameter_objects"][self.bounds_index]["default_value"].set(default_values)
@@ -3,20 +3,25 @@ from customtkinter import CTkFrame
3
3
  from customtkinter import CTkLabel
4
4
  from customtkinter import CTkButton
5
5
  from customtkinter import CTkEntry
6
+ from customtkinter import CTkOptionMenu
6
7
  import tkinter as tk
8
+ import subprocess
9
+ import platform
10
+ import os
7
11
 
8
- global option_manager
9
-
10
- class CalibrationParametersView(CTkScrollableFrame):
12
+ class OverrideParameterMetrics(CTkScrollableFrame):
11
13
  def __init__(self, *args,
12
14
  option_manager: None,
15
+ step_index: 0,
13
16
  **kwargs):
14
17
  super().__init__(*args, **kwargs)
15
18
 
16
19
  self.option_manager = option_manager
17
- self.key_values = option_manager.get_arguments()['calibration_parameters']
18
- self.edit_mode = False
20
+ self.step_index = step_index
21
+ self.key_values = option_manager.get_override(step_index)
19
22
 
23
+ self.edit_mode = False
24
+
20
25
  self.render()
21
26
 
22
27
  def clear(self):
@@ -27,6 +32,12 @@ class CalibrationParametersView(CTkScrollableFrame):
27
32
  self.edit_mode = not self.edit_mode
28
33
  self.render()
29
34
 
35
+ def add_key(self, key="iters", value="1"):
36
+ self.option_manager.add_override(self.step_index, key, value)
37
+
38
+ def remove_key(self, index):
39
+ self.option_manager.remove_override(self.step_index, index)
40
+
30
41
  def render(self):
31
42
  row = 0
32
43
  index = 0
@@ -40,10 +51,23 @@ class CalibrationParametersView(CTkScrollableFrame):
40
51
  row += 1
41
52
 
42
53
  for key_value_pair in self.key_values:
43
- CTkEntry(self.containerFrame, textvariable=self.key_values[index]["name"]).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
54
+ overwrite_values = [
55
+ 'iters',
56
+ 'ftol',
57
+ 'ftol_iter',
58
+ 'rtol',
59
+ 'rtol_iter',
60
+ 'n_threads',
61
+ 'n_particles',
62
+ 'cost_target'
63
+ ]
44
64
 
65
+
66
+ CTkOptionMenu(self.containerFrame, values=overwrite_values, variable=self.key_values[index]["name"]).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
67
+
68
+
45
69
  if self.edit_mode:
46
- return_func = lambda index=index: (self.clear(), self.option_manager.remove_calibration_parameter(index), self.render())
70
+ return_func = lambda index=index: (self.clear(), self.remove_key(index), self.render())
47
71
  CTkButton(self.containerFrame, text="Remove", command=return_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
48
72
  else:
49
73
  bb = CTkEntry(self.containerFrame)
@@ -57,5 +81,7 @@ class CalibrationParametersView(CTkScrollableFrame):
57
81
  else:
58
82
  CTkButton(self.containerFrame, text="Edit", command=self.toggle_edit_mode).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
59
83
 
60
- add_key_func = lambda: (self.clear(), self.option_manager.add_calibration_param("name", "value"), self.render())
61
- CTkButton(self.containerFrame, text="Add Parameter", command=add_key_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
84
+ add_key_func = lambda: (self.clear(), self.add_key(), self.render())
85
+ CTkButton(self.containerFrame, text="Add", command=add_key_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
86
+
87
+ row += 1
@@ -0,0 +1,40 @@
1
+ from typing import Union, Tuple, Optional
2
+
3
+ from customtkinter import CTkLabel
4
+ from customtkinter import CTkButton
5
+ from customtkinter import CTkEntry
6
+ from customtkinter import CTkInputDialog
7
+ from .OverrideParameterMetrics import OverrideParameterMetrics as ListView
8
+
9
+ class OverrideParameterWindow(CTkInputDialog):
10
+ """
11
+ Dialog with extra window, message, entry widget, cancel and ok button.
12
+ For detailed information check out the documentation.
13
+ """
14
+
15
+ def __init__(self, *args,
16
+ step_index: 0,
17
+ option_manager: None,
18
+ **kwargs):
19
+ super().__init__(*args, **kwargs)
20
+
21
+ self.geometry("400x800")
22
+
23
+ self.step_index = step_index
24
+ self.option_manager = option_manager
25
+ self.bounds = None
26
+
27
+ def _create_widgets(self):
28
+
29
+ self.grid_columnconfigure((0, 1), weight=1)
30
+ self.rowconfigure(0, weight=1)
31
+
32
+ self.bounds = ListView(
33
+ self, step_index=self.step_index, option_manager=self.option_manager)
34
+ self.bounds.grid(row=0, column=0, columnspan=2, padx=(10, 10),
35
+ pady=(10, 10), sticky="nsew")
36
+ self.bounds.grid_columnconfigure(0, weight=1)
37
+
38
+ def _on_closing(self):
39
+ self.grab_release()
40
+ self.destroy()
@@ -1,11 +1,21 @@
1
1
 
2
2
 
3
3
  from . import StepView as sv
4
- from . import StaticParameterView as spv
5
- from . import CalibrationParametersView as cpv
4
+ from ..General import ParameterView as pv
6
5
 
7
6
  import customtkinter
8
7
 
8
+ def setup_refresh(self):
9
+ self.static_param_frame.clear()
10
+ self.static_param_frame.destroy()
11
+ self.calib_param_frame.clear()
12
+ self.calib_param_frame.destroy()
13
+ #self.optimal_param_frame.clear()
14
+ #self.optimal_param_frame.destroy()
15
+ self.steps_frame.clear()
16
+ self.steps_frame.destroy()
17
+ self.paramtabview.destroy()
18
+
9
19
  def create_tab(self, tab):
10
20
 
11
21
  tab.grid_columnconfigure(0, weight=8)
@@ -13,12 +23,14 @@ def create_tab(self, tab):
13
23
  tab.grid_rowconfigure(0, weight=1)
14
24
 
15
25
  self.paramtabview = customtkinter.CTkTabview(tab, bg_color="transparent", fg_color="transparent")
16
- self.paramtabview.grid(row=0, column=1, padx=(0, 0), pady=(10, 10), sticky="nsew")
26
+ self.paramtabview.grid(row=0, column=1, padx=(0, 0), pady=(0, 0), sticky="nsew")
17
27
 
18
- tab1 = "Static Parameters"
19
- tab2 = "Calibration Parameters"
28
+ tab1 = "Model Parameters"
29
+ tab2 = "Hyperparameters"
30
+ #tab3 = "Optimal"
20
31
  self.paramtabview.add(tab1)
21
32
  self.paramtabview.add(tab2)
33
+ #self.paramtabview.add(tab3)
22
34
 
23
35
  self.paramtabview.tab(tab1).grid_columnconfigure(0, weight=1)
24
36
  self.paramtabview.tab(tab1).grid_rowconfigure(0, weight=1)
@@ -26,18 +38,26 @@ def create_tab(self, tab):
26
38
  self.paramtabview.tab(tab2).grid_columnconfigure(0, weight=1)
27
39
  self.paramtabview.tab(tab2).grid_rowconfigure(0, weight=1)
28
40
 
29
- self.static_param_frame = spv.StaticParameterView(self.paramtabview.tab(tab1), option_manager=self.option_manager)
30
- self.static_param_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
41
+ #self.paramtabview.tab(tab3).grid_columnconfigure(0, weight=1)
42
+ #self.paramtabview.tab(tab3).grid_rowconfigure(0, weight=1)
43
+
44
+ self.static_param_frame = pv.ParameterView(self.paramtabview.tab(tab1), option_manager=self.option_manager, list_name="model_parameters")
45
+ self.static_param_frame.grid(row=0, column=0, padx=(5, 10), pady=(10, 0), sticky="nsew")
31
46
  self.static_param_frame.grid_columnconfigure(0, weight=1)
32
47
  self.static_param_frame.grid_rowconfigure(0, weight=1)
33
48
 
34
- self.calib_param_frame = cpv.CalibrationParametersView(self.paramtabview.tab(tab2), option_manager=self.option_manager)
35
- self.calib_param_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
49
+ self.calib_param_frame = pv.ParameterView(self.paramtabview.tab(tab2), option_manager=self.option_manager, list_name="hyperparameters")
50
+ self.calib_param_frame.grid(row=0, column=0, padx=(5, 10), pady=(10, 0), sticky="nsew")
36
51
  self.calib_param_frame.grid_columnconfigure(0, weight=1)
37
52
  self.calib_param_frame.grid_rowconfigure(0, weight=1)
38
53
 
39
- self.steps_frame = sv.StepView(tab, label_text="Group Editor", option_manager=self.option_manager)
40
- self.steps_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
54
+ #self.optimal_param_frame = opv.OptimalParameterView(self.paramtabview.tab(tab3), option_manager=self.option_manager)
55
+ #self.optimal_param_frame.grid(row=0, column=0, padx=(10, 10), pady=(10, 0), sticky="nsew")
56
+ #self.optimal_param_frame.grid_columnconfigure(0, weight=1)
57
+ #self.optimal_param_frame.grid_rowconfigure(0, weight=1)
58
+
59
+ self.steps_frame = sv.StepView(tab, label_text="Group Editor", option_manager=self.option_manager, home_page=self)
60
+ self.steps_frame.grid(row=0, column=0, padx=(10, 5), pady=(10, 0), sticky="nsew")
41
61
  self.steps_frame.grid_columnconfigure(0, weight=1)
42
62
  self.steps_frame.grid_rowconfigure(0, weight=1)
43
63
 
@@ -5,38 +5,55 @@ from customtkinter import CTkButton
5
5
  from customtkinter import CTkEntry
6
6
  from customtkinter import CTkTextbox
7
7
  from customtkinter import CTkImage
8
+ from customtkinter import CTkOptionMenu
9
+ from .OverrideParameterWindow import OverrideParameterWindow as OPW
8
10
  from PIL import Image
9
11
  import os
10
12
 
11
13
  from . import BoundsList
12
14
  from . import FunctionsList
15
+ from . import ListEditor
13
16
 
14
17
 
15
18
  class StepView(CTkScrollableFrame):
16
19
  def __init__(self, *args,
17
20
  option_manager: None,
21
+ home_page: None,
18
22
  **kwargs):
19
23
  super().__init__(*args, **kwargs)
20
24
 
21
25
  self.option_manager = option_manager
22
-
26
+ self.analysisFrame = None
27
+ self.containerFrame = None
28
+ self.home_page = home_page
29
+
30
+ self.render()
31
+
32
+ def refresh(self, *args):
33
+ self.clear()
23
34
  self.render()
24
35
 
25
36
  def clear(self):
26
- self.containerFrame.destroy()
37
+ if self.containerFrame != None:
38
+ self.containerFrame.destroy()
39
+
40
+ if self.analysisFrame != None:
41
+ self.analysisFrame.destroy()
27
42
 
28
43
  def create_new_step(self):
29
44
 
30
45
  self.clear()
31
46
  example_step = [{ # step 1
32
- 'param': [
47
+ 'parameter_objects': [
33
48
  {
34
49
  'name': 'soilOutLPS',
35
- 'bounds': (0.0, 2.0)
50
+ 'min_bound': 0.0,
51
+ 'max_bound': 2.0
36
52
  },
37
53
  {
38
54
  'name': 'lagInterflow',
39
- 'bounds': (10.0, 80.0)
55
+ 'min_bound': 10.0,
56
+ 'max_bound': 80.0
40
57
  }
41
58
  ],
42
59
  'objfunc': [
@@ -64,6 +81,52 @@ class StepView(CTkScrollableFrame):
64
81
  self.containerFrame.grid_columnconfigure((0, 1), weight=1)
65
82
 
66
83
  self.steps = self.option_manager.get_steps()
84
+ self.mode = self.option_manager.get_mode()
85
+
86
+ if (self.mode == "Sensitivity Analysis"):
87
+ folder = self.option_manager.get_project_folder()
88
+ folder = os.path.join(folder, "results")
89
+
90
+ # File all CSV files in folder and put them into list with strings as path
91
+ files = []
92
+ if os.path.exists(folder):
93
+ files = [f for f in os.listdir(folder) if f.endswith('.csv')]
94
+
95
+ if len(files) == 0:
96
+ files = [" No CSV files found! Run sampling first! "]
97
+ elif self.option_manager.get("sensitivity_analysis_path").get() not in files:
98
+ self.option_manager.get("sensitivity_analysis_path").set(files[0])
99
+
100
+ header_padding_x = (5, 5)
101
+ header_padding_y = (10, 10)
102
+
103
+ self.file_selector_frame = CTkFrame(self.containerFrame)
104
+ self.file_selector_frame.grid(row=0, column=0, sticky="nsew", columnspan=2)
105
+ self.logo_label = CTkLabel(self.file_selector_frame, text="Select File:")
106
+ self.logo_label.grid(row=0, column=0, padx=(10, 10), pady=header_padding_y)
107
+
108
+ self.file_selector = CTkOptionMenu(self.file_selector_frame, values=files, width=50, variable=self.option_manager.get("sensitivity_analysis_path"), command=self.refresh)
109
+ self.file_selector.grid(row=0, column=1, padx=(10, 10), pady=header_padding_y)
110
+
111
+ row += 1
112
+
113
+ elif (self.mode == "Sampling: Halton" or self.mode == "Sampling: Random"):
114
+ header_padding_x = (5, 5)
115
+ header_padding_y = (10, 10)
116
+
117
+ self.file_selector_frame = CTkFrame(self.containerFrame)
118
+ self.file_selector_frame.grid(row=0, column=0, sticky="nsew", columnspan=2)
119
+
120
+ self.logo_label2 = CTkLabel(self.file_selector_frame, text="Output:")
121
+ self.logo_label2.grid(row=0, column=1, padx=(20, 10), pady=header_padding_y)
122
+
123
+ self.output_method = CTkOptionMenu(self.file_selector_frame, values=["Replace", "Append"], width=50, variable=self.option_manager.get("sampling_output_mode"))
124
+ if self.option_manager.get("sampling_output_mode").get() == "":
125
+ self.option_manager.get("sampling_output_mode").set("Replace")
126
+ self.output_method.grid(row=0, column=2, padx=(10, 10), pady=header_padding_y)
127
+
128
+ row += 1
129
+
67
130
 
68
131
  for step in self.steps:
69
132
 
@@ -72,30 +135,33 @@ class StepView(CTkScrollableFrame):
72
135
  trash_image = CTkImage(Image.open(os.path.join("./images", "trash.png")), size=(20, 20))
73
136
  expand_image = CTkImage(Image.open(os.path.join("./images", "expand.png")), size=(20, 20))
74
137
  collapse_image = CTkImage(Image.open(os.path.join("./images", "collapse.png")), size=(20, 20))
138
+ override_image = CTkImage(Image.open(os.path.join("./images", "plus.png")), size=(20, 20))
75
139
 
76
140
 
77
141
  expand_func = lambda index=index: (self.clear(), self.option_manager.toggle_step_open(index), self.render())
78
142
  up_func = lambda index=index: (self.clear(), self.option_manager.move_step_up(index), self.render())
79
143
  down_func = lambda index=index: (self.clear(), self.option_manager.move_step_down(index), self.render())
80
144
  remove_func = lambda index=index: (self.clear(), self.option_manager.remove_step(index), self.render())
145
+ open_override_window = lambda index=index: (OPW(title="Edit Override Parameters", step_index=index, option_manager=self.option_manager))
146
+
147
+ if (self.mode == "Optimization"):
148
+ button_container = CTkFrame(self.containerFrame, width=200)
149
+ button_container.grid(row=row, column=1, sticky="nse", padx=(10, 10), pady=(10, 10))
150
+ button_container.grid_rowconfigure(0, weight=1)
151
+ button_container.grid_columnconfigure(0, weight=1)
152
+
153
+ CTkEntry(self.containerFrame, textvariable=step['name'], width=500).grid(row=row, column=0, padx=(20, 20), pady=(20, 20), sticky="nsw")
81
154
 
82
- #CTkLabel(self.containerFrame, text="Step:").grid(row=row, column=0, padx=10, pady=5, sticky="nsew")
83
-
84
- button_container = CTkFrame(self.containerFrame, width=200)
85
- button_container.grid(row=row, column=1, sticky="nse", padx=(10, 10), pady=(10, 10))
86
- button_container.grid_rowconfigure(0, weight=1)
87
- button_container.grid_columnconfigure(0, weight=1)
88
-
89
- CTkEntry(self.containerFrame, textvariable=step['name'], width=500).grid(row=row, column=0, padx=(20, 20), pady=(20, 20), sticky="nsw")
90
- #CTkLabel(self.containerFrame, textvariable=step['message']).grid(row=row, column=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
91
- 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")
92
- 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")
93
- 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")
94
- 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")
155
+
156
+ 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=(20, 10), pady=(10, 10), sticky="nsew")
157
+ CTkButton(button_container, width=30, text=None, image=override_image, command=open_override_window).grid(row=0, column=1, padx=(5, 5), pady=(10, 10), sticky="nsew")
158
+ 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=2, padx=(5, 5), pady=(10, 10), sticky="nsew")
159
+ 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=3, padx=(5, 10), pady=(10, 10), sticky="nsew")
160
+ CTkButton(button_container, width=30, text=None, image=trash_image, command=remove_func).grid(row=0, column=4, padx=(5, 20), pady=(10, 10), sticky="nsew")
95
161
 
96
- row += 1
162
+ row += 1
97
163
 
98
- if step['open']:
164
+ if step['open'] or (self.mode == "Sampling: Halton" or self.mode == "Sampling: Random" or self.mode == "Sensitivity Analysis"):
99
165
  bounds = BoundsList.BoundsList(
100
166
  self.containerFrame, option_manager=self.option_manager, step_index=index)
101
167
  bounds.grid(row=row, column=0, padx=(10, 10),
@@ -112,7 +178,12 @@ class StepView(CTkScrollableFrame):
112
178
 
113
179
  row += 1
114
180
  index += 1
181
+
182
+ if (self.mode != "Optimization"):
183
+ break
115
184
 
116
185
  # Create an "Add step button that is centered
117
- CTkButton(self.containerFrame, text="Add Group", command=self.create_new_step).grid(
118
- row=row, columnspan=2, column=0, padx=(10, 10), pady=(10, 10), sticky="ew")
186
+ if (self.mode == "Optimization" or len(self.steps) == 0):
187
+ CTkButton(self.containerFrame, text="Add Group", command=self.create_new_step).grid(
188
+ row=row, columnspan=2, column=0, padx=(10, 10), pady=(10, 10), sticky="ew")
189
+
@@ -0,0 +1,68 @@
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 CTkOptionMenu
7
+ import tkinter as tk
8
+
9
+ global option_manager
10
+
11
+ class MatrixEditor(CTkFrame):
12
+ def __init__(self, *args,
13
+ option_manager: None,
14
+ home_page: None,
15
+ columns: None,
16
+ **kwargs):
17
+ super().__init__(*args, **kwargs)
18
+
19
+ self.option_manager = option_manager
20
+ self.home_page = home_page
21
+ self.columns = columns
22
+ self.key_values = option_manager.get('figure_parameters')
23
+ self.edit_mode = False
24
+
25
+ self.render()
26
+
27
+ def clear(self):
28
+ self.containerFrame.destroy()
29
+
30
+ def set_columns(self, columns):
31
+ self.columns = columns
32
+
33
+ def toggle_edit_mode(self):
34
+ self.clear()
35
+ self.edit_mode = not self.edit_mode
36
+ self.render()
37
+
38
+ def render(self):
39
+ row = 0
40
+ index = 0
41
+
42
+ self.containerFrame = CTkFrame(self)
43
+ self.containerFrame.grid(row=0, column=0, padx=(0, 0), pady=(0, 0), sticky="new")
44
+ self.containerFrame.grid_columnconfigure((0, 1), weight=1)
45
+
46
+ CTkLabel(self.containerFrame, text="X Axes:").grid(row=row, column=0, columnspan=2, padx=5, pady=5, sticky="ew")
47
+ row += 1
48
+
49
+ for key_value_pair in self.key_values:
50
+ if self.edit_mode:
51
+ bb = CTkOptionMenu(self.containerFrame, values=self.columns, variable=self.key_values[index]["value"], command=self.home_page.update_graph)
52
+ bb.grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
53
+
54
+ return_func = lambda index=index: (self.clear(), self.option_manager.remove_key_value('figure_parameters', index), self.home_page.update_graph(0), self.render())
55
+ CTkButton(self.containerFrame, text="Remove", command=return_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
56
+ else:
57
+ bb = CTkOptionMenu(self.containerFrame, values=self.columns, variable=self.key_values[index]["value"], command=self.home_page.update_graph)
58
+ bb.grid(row=row, column=0, columnspan=2, padx=(5, 5), pady=(5, 5), sticky="ew")
59
+ row += 1
60
+ index += 1
61
+
62
+ if self.edit_mode:
63
+ CTkButton(self.containerFrame, text="Exit", width=100, command=self.toggle_edit_mode).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
64
+ else:
65
+ CTkButton(self.containerFrame, text="Edit", width=100, command=self.toggle_edit_mode).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
66
+
67
+ add_key_func = lambda: (self.clear(), self.option_manager.add_key_value('figure_parameters', "Fig " + str(len(self.key_values)), self.columns[2], destination="NONE"), self.home_page.update_graph(0), self.render())
68
+ CTkButton(self.containerFrame, text="Add Figure", width=100, command=add_key_func).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")