mg-pso-gui 0.1.12__py3-none-any.whl → 0.1.40__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,21 +19,7 @@ def create_tab(self, tab):
19
19
  tab.grid_columnconfigure(0, weight=1)
20
20
  tab.grid_rowconfigure(0, weight=1)
21
21
  tab.grid_rowconfigure(1, weight=200)
22
-
23
- """
24
- self.url = customtkinter.CTkEntry(tab, textvariable=self.option_manager.get_arguments()['url'])
25
- self.url.grid(row=0, column=0, columnspan=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
26
22
 
27
- self.run_button = customtkinter.CTkButton(tab, text="Run", command=self.run)
28
- self.run_button.grid(row=0, column=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
29
- ctt(self.run_button, delay=0.5, message="Start calibration...")
30
-
31
- self.stop_button = customtkinter.CTkButton(tab, text="Stop", command=self.stop)
32
- self.stop_button.grid(row=0, column=2, padx=(20, 20), pady=(20, 20), sticky="nsew")
33
- ctt(self.stop_button, delay=0.5, message="Stop calibration...")
34
-
35
- """
36
-
37
23
  self.progress_container = customtkinter.CTkFrame(tab)
38
24
  self.progress_container.grid_columnconfigure(0, weight=1)
39
25
  self.progress_container.grid_columnconfigure(1, weight=1)
@@ -50,12 +36,7 @@ def create_tab(self, tab):
50
36
  self.progress_message_right = customtkinter.CTkLabel(self.progress_container, text="")
51
37
  self.progress_message_right.grid(row=0, column=2, padx=(10, 10), pady=(10, 10), sticky="e")
52
38
 
53
- #self.progress_bar = customtkinter.CTkProgressBar(self.progress_container)
54
- #self.progress_bar.grid(row=1, column=0, columnspan=3, padx=(10, 10), pady=(10, 10), sticky="ew")
55
- #self.progress_bar.set(0)
56
- #ctt(self.progress_bar, delay=0.5, message="Current calibration progress")
57
-
58
39
  self.textbox = customtkinter.CTkTextbox(tab)
59
40
  self.textbox.grid(row=1, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
60
- self.textbox.insert("0.0", "Welcome to the CSIP PSO Calibration Tool!\n\nUse the Calibration tab to define steps and calibration parameters. Use this tab to run and observe calibration progress. Once finished, use the Visualization tab to generate figures and graphs.")
41
+ self.textbox.insert("0.0", "Welcome to the CSIP PSO Calibration Tool!\n\nUse the Setup tab to define steps and calibration parameters. Use this tab to view logs and observe calibration progress. Once finished, use the Results tab to generate figures and graphs.")
61
42
 
@@ -0,0 +1,108 @@
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
+ elif (selected_graph == "Custom CSV"):
58
+
59
+ info = self.option_manager.get_project_data()
60
+ folder = os.path.join(info['path'], info['name'])
61
+ if not os.path.exists(folder):
62
+ os.makedirs(folder)
63
+
64
+ # Get all CSV files in the folder and add their paths to a list
65
+ path_map = {}
66
+ name_list = []
67
+ for root, dirs, files in os.walk(folder):
68
+ for file in files:
69
+ if file.endswith(".csv"):
70
+ name = file.replace(".csv", "")
71
+ name_list.append(name)
72
+ path_map[name] = os.path.join(root, file)
73
+
74
+ if (len(name_list) == 0):
75
+ name_list.append("No files found...")
76
+ else:
77
+ if (self.home_page.selected_csv.get() not in name_list):
78
+ self.home_page.selected_csv.set(name_list[0])
79
+
80
+ self.home_page.csv_file_selector = CTkOptionMenu(self.containerFrame, values=name_list, variable=self.home_page.selected_csv, command=self.home_page.update_graph)
81
+ self.home_page.csv_file_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
82
+
83
+ selected_file = self.home_page.selected_csv.get()
84
+ if (selected_file in path_map and selected_file != self.home_page.open_file):
85
+ self.home_page.csv_data = pd.read_csv(path_map[selected_file], skiprows=3)
86
+ self.home_page.open_file = selected_file
87
+
88
+ if (self.home_page.csv_data != None):
89
+ # Get all column names of CSV
90
+ columns = self.home_page.csv_data.columns
91
+
92
+ self.home_page.csv_x_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_x, command=self.home_page.update_graph)
93
+ self.home_page.csv_x_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
94
+
95
+ if (self.home_page.csv_x_selector.get() not in columns):
96
+ self.home_page.csv_x_selector.set(columns[1])
97
+
98
+ self.home_page.csv_y1_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y1, command=self.home_page.update_graph)
99
+ self.home_page.csv_y1_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
100
+
101
+ if (self.home_page.csv_y1_selector.get() not in columns):
102
+ self.home_page.csv_y1_selector.set(columns[2])
103
+
104
+ self.home_page.csv_y2_selector = CTkOptionMenu(self.containerFrame, values=columns, variable=self.home_page.selected_y2, command=self.home_page.update_graph)
105
+ self.home_page.csv_y2_selector.grid(row=2, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
106
+
107
+ if (self.home_page.csv_y2_selector.get() not in columns):
108
+ self.home_page.csv_y2_selector.set(columns[3])
@@ -5,6 +5,8 @@ import os
5
5
  import platform
6
6
  import subprocess
7
7
 
8
+ from . import SideBar
9
+
8
10
  def create_tab(self, tab):
9
11
 
10
12
  def open_graph_in_browser():
@@ -45,7 +47,7 @@ def create_tab(self, tab):
45
47
  self.graph_label.update_idletasks()
46
48
 
47
49
 
48
- tab.grid_columnconfigure(0, weight=1)
50
+ tab.grid_columnconfigure(0, weight=2)
49
51
  tab.grid_columnconfigure(1, weight=8)
50
52
  tab.grid_rowconfigure(0, weight=1)
51
53
 
@@ -55,15 +57,17 @@ def create_tab(self, tab):
55
57
  self.graph_container.grid(row=0, column=1, padx=(20, 20), pady=(20, 20), sticky="nsew")
56
58
 
57
59
  self.graph_sidebar.grid_columnconfigure(0, weight=1)
58
- self.graph_sidebar.grid_rowconfigure(8, weight=1)
60
+ self.graph_sidebar.grid_rowconfigure(1, weight=1)
59
61
  self.graph_container.grid_columnconfigure(0, weight=1)
60
62
  self.graph_container.grid_rowconfigure(0, weight=1)
61
63
 
62
- self.graph_selector_value = tk.StringVar()
63
- self.graph_selector_value.set("Best Cost Stacked")
64
- self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table"], 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"], 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
+ # Create SideBar
68
+ self.vis_sidebar = SideBar.SideBar(self.graph_sidebar, option_manager=self.option_manager, home_page=self, fg_color="transparent")
69
+ self.vis_sidebar.grid(row=1, column=0, rowspan=8, padx=(0, 0), pady=(0, 0), sticky="nsew")
70
+
67
71
  # Add a button to call open_graph_in_browser
68
72
  self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Open in Browser", command=open_graph_in_browser)
69
73
  self.graph_button.grid(row=9, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
Binary file
@@ -3,6 +3,40 @@ import plotly.graph_objs as go
3
3
  import pandas as pd
4
4
  import numpy as np
5
5
  import os
6
+ from PIL import Image, ImageTk
7
+ import customtkinter
8
+
9
+ def generate_graphs(HomePage):
10
+ try:
11
+ selected_graph = HomePage.graph_selector_value.get()
12
+ info = HomePage.option_manager.get_project_data()
13
+ folder = os.path.join(info['path'], info['name'])
14
+ if not os.path.exists(folder):
15
+ os.makedirs(folder)
16
+
17
+ if (selected_graph == "Best Cost Stacked"):
18
+ HomePage.selected_graph_name = "best_cost_stacked"
19
+ best_cost_stacked(HomePage.running_config['steps'], HomePage.progress_data, HomePage.option_manager)
20
+ elif (selected_graph == "Best Cost by Round"):
21
+ HomePage.selected_graph_name = "best_cost_by_round"
22
+ best_cost_by_round(HomePage.running_config['steps'], HomePage.progress_data, HomePage.option_manager)
23
+ elif (selected_graph == "Iteration Table"):
24
+ HomePage.selected_graph_name = "table"
25
+ table(HomePage.running_config['steps'], HomePage.progress_data, HomePage.option_manager)
26
+ elif (selected_graph == "Calibrated Parameters"):
27
+ HomePage.selected_graph_name = "calibrated_params_by_round"
28
+ calibrated_params_by_round(HomePage.running_config['steps'], HomePage.calibration_data, HomePage.option_manager)
29
+
30
+ image_path = os.path.join(folder, HomePage.selected_graph_name + ".png")
31
+
32
+ if not os.path.exists(image_path):
33
+ image_path = os.path.join("./images", "up.png")
34
+
35
+ HomePage.graph_image_obj = Image.open(image_path)
36
+ HomePage.graph_image = customtkinter.CTkImage(HomePage.graph_image_obj, size=(HomePage.image_width * HomePage.image_scale, HomePage.image_height * HomePage.image_scale))
37
+ HomePage.graph_label.configure(image=HomePage.graph_image)
38
+ except Exception as e:
39
+ pass
6
40
 
7
41
  def best_cost_stacked(config, dataframe, option_manager):
8
42
  fig = go.Figure()
@@ -1,4 +1,5 @@
1
1
  import csip
2
+ from csip import Client
2
3
  import cosu
3
4
  import sys
4
5
  from multiprocessing import Process, Queue
@@ -99,81 +100,43 @@ def run_process(stdout_queue, stderr_queue, results_queue, cosu_queue, data, fol
99
100
  sys.stderr = old_stderr
100
101
  results_queue.put((optimizer, trace))
101
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)
102
141
 
103
142
 
104
-
105
- """import csip
106
- import cosu
107
- import sys
108
- import multiprocessing
109
- import threading
110
- import time
111
- import os
112
-
113
- from cosu.pso import global_best
114
-
115
- def run_process(process_queue, data, folder):
116
- steps = data['steps']
117
- args = data['arguments']
118
- calib = data['calibration_parameters']
119
-
120
- calibration_map = {}
121
- for param in calib:
122
- param_name = param['name']
123
- param_value = param['value']
124
- calibration_map[param_name] = param_value
125
-
126
- if not os.path.exists(folder):
127
- os.makedirs(folder)
128
-
129
- if (os.path.exists(os.path.join(folder, 'output.txt'))):
130
- os.remove(os.path.join(folder, 'output.txt'))
131
-
132
- if (os.path.exists(os.path.join(folder, 'error.txt'))):
133
- os.remove(os.path.join(folder, 'error.txt'))
134
-
135
- sys.stdout = open(os.path.join(folder, 'output.txt'), 'w', buffering=1)
136
- sys.stderr = open(os.path.join(folder, 'error.txt'), 'w', buffering=1)
137
-
138
- options = {}
139
- oh_strategy = {}
140
-
141
- for key in calibration_map.keys():
142
- if "options_" in key:
143
- options[key.replace("options_", "")] = float(calibration_map[key])
144
- if "strategy_" in key:
145
- oh_strategy[key.replace("strategy_", "")] = calibration_map[key]
146
-
147
- print("\n")
148
- print(calibration_map)
149
- print("\n")
150
- print(options)
151
- print("\n")
152
- print(oh_strategy)
153
- print("\n")
154
-
155
- print("Running global_best...\n")
156
-
157
- optimizer, trace = global_best(steps, # step definition
158
- rounds=(int(calibration_map['min_rounds']), int(calibration_map['max_rounds'])), # min/max number of rounds
159
- args=args, # static arguments
160
- n_particles=int(calibration_map['n_particles']), # number of particle candidates for each param
161
- iters=int(calibration_map['iters']), # max # of iterations
162
- n_threads=int(calibration_map['n_threads']), # number of threads to use
163
- # ftol=0.00000001, # min cost function delta for convergence
164
- options=options, # hyperparameter
165
- oh_strategy=oh_strategy, # adaptive hyperparameter adjustments based on current and max # of iterations
166
- conf={
167
- 'service_timeout': int(calibration_map['service_timeout']),
168
- 'http_retry': int(calibration_map['http_retry']),
169
- 'http_allow_redirects': True if calibration_map['allow_redirects'] == "True" else False,
170
- 'async_call': True if calibration_map['async_call'] == "True" else False,
171
- 'http_conn_timeout': int(calibration_map['conn_timeout']),
172
- 'http_read_timeout': int(calibration_map['read_timeout']),
173
- 'particles_fail': int(calibration_map['particles_fail'])
174
- },
175
- )
176
-
177
- process_queue.put((optimizer, trace))
178
-
179
- """
@@ -9,52 +9,34 @@ def csip_worker(reqq: queue.Queue, thread_no: int, stop, full_trace,
9
9
  async_call = conf.get('async_call', True) # default is async
10
10
  save_resp = conf.get('save_response_to', None) # save response, set it to a folder if responses should be saved.
11
11
 
12
- print("client1")
13
-
14
12
  while not stop():
15
- print("client2")
16
13
 
17
14
  try:
18
15
  (rnd, step, iteration, particle, x, step_param_names, calib_params, objfunc, resq) = reqq.get(True, 0.5)
19
16
  # print(thread_no, particle)
20
-
21
- print("client3")
22
17
 
23
18
  c = Client(metainfo=metainfo)
24
19
 
25
- print("client4")
26
-
27
20
  # static params (from args)
28
21
  for param in arg_params:
29
22
  c.add_data(param['name'], param['value'])
30
23
 
31
- print("client5")
32
-
33
24
  # particle params (generated from steps)
34
25
  # for i, value in enumerate(x):
35
26
  for idx, value in enumerate(x[particle, :]):
36
27
  c.add_data(step_param_names[idx], value)
37
28
 
38
-
39
- print("client6")
40
-
41
29
  # other, previously calibrated params (other steps)
42
30
  for name, value in calib_params.items():
43
31
  c.add_data(name, value)
44
32
 
45
- print("client7")
46
-
47
33
  # objective function info
48
34
  for of in objfunc:
49
35
  c.add_cosu(of['name'], of['of'], of['data'])
50
36
  # c.add_data(of['name'], (of['data'][0], of['data'][1]))
51
37
 
52
- print("client8")
53
-
54
38
  print('.', end='', flush=True)
55
39
 
56
- print("client9")
57
-
58
40
  try:
59
41
  # print(c)
60
42
  if async_call:
@@ -62,47 +44,32 @@ def csip_worker(reqq: queue.Queue, thread_no: int, stop, full_trace,
62
44
  else:
63
45
  res = c.execute(url, files=files, conf=conf)
64
46
 
65
- print("client10")
66
-
67
47
  if res.is_failed():
68
48
  print(res)
69
49
 
70
- print("client11")
71
-
72
50
  if save_resp:
73
51
  res.save_to(os.path.join(save_resp, 'r{}s{}i{}p{}.json'.format(rnd, step, iteration, particle)))
74
-
75
- print("client12")
76
-
52
+
77
53
  # print(res)
78
- print(u'\u2714', end='', flush=True)
79
-
80
- print("client13")
54
+ print('O', end='', flush=True)
81
55
 
82
56
  cost = utils.calc_cost(res, objfunc)
83
57
 
84
- print("client14")
85
-
86
58
  if full_trace is not None:
87
59
  all_params = {}
88
60
  # for i, value in enumerate(x):
89
61
  for idx, value in enumerate(x[particle, :]):
90
62
  all_params[step_param_names[idx]] = value
91
-
92
- print("client15")
93
63
 
94
64
  for name, value in calib_params.items():
95
65
  all_params[name] = value
96
66
  full_trace.append((all_params, cost))
97
67
 
98
- print("client16")
99
-
100
68
  resq.put((particle, cost))
101
69
  except Exception as e:
102
70
  print(res)
103
71
  print(e)
104
-
105
- print("client17")
72
+
106
73
  reqq.task_done()
107
74
  except queue.Empty:
108
75
  continue
@@ -29,44 +29,30 @@ def eval_cost(x, iteration, step_param_names, step_objfunc, calib_params, req_qu
29
29
  step):
30
30
  particles = len(x[:, 0])
31
31
 
32
- print("c1")
33
-
34
32
  pfail_count = conf.get('particles_fail', 1) # Number of particles allowed to fail.
35
33
  pfail_retry = conf.get('particles_retry', 3) # retry number of times if more than allowed fail
36
34
 
37
- print("c2")
38
-
39
35
  while pfail_retry > 0:
40
36
  cost = np.ones(particles)
41
37
  res_queue = queue.Queue()
42
38
 
43
39
  print(' ', end='', flush=True)
44
40
 
45
- print("c3")
46
-
47
41
  # submit for processing
48
42
  # for i_particle, v in enumerate(x[:, 0]):
49
43
  for particle in range(particles):
50
44
  req_queue.put((rnd, step, iteration, particle, x, step_param_names, calib_params, step_objfunc, res_queue))
51
45
  # req_queue.put((i_particle, x[i_particle,:], step_param_names, calib_params, step_objfunc, res_queue))
52
46
 
53
- print("c4")
54
-
55
47
  # wait for the cost value to come back
56
48
  # for i, v in enumerate(x[:, 0]):
57
49
  for idx in range(particles):
58
- print("c4.1")
59
50
  (particle, p_cost) = res_queue.get()
60
51
  cost[particle] = p_cost
61
- print("c4.2")
62
52
  res_queue.task_done()
63
53
 
64
- print("c5")
65
-
66
54
  res_queue.join()
67
55
 
68
- print("c6")
69
-
70
56
  # replace the 'nan' cost values (failed/missing runs) with the mean of the
71
57
  # rest of the cost values, hence ignore it
72
58
 
@@ -74,24 +60,15 @@ def eval_cost(x, iteration, step_param_names, step_objfunc, calib_params, req_qu
74
60
  nan_idx = np.where(np.isnan(cost))
75
61
  failed_particles = len(nan_idx[0])
76
62
 
77
- print("c7")
78
-
79
63
  # leave the loop if fails acceptable
80
64
  if failed_particles <= pfail_count:
81
65
  break
82
66
 
83
- print("c8")
84
-
85
67
  print("Re-running particles, since ", failed_particles, ' out of ', particles, ' particles failed.')
86
68
  pfail_retry -= 1
87
69
 
88
- print("c9")
89
-
90
- print("c10")
91
-
92
70
  if pfail_retry == 0:
93
71
  print('Particle evaluation failed ', conf.get('particles_retry', 3), ' times. PSO stopped.')
94
- print("c11")
95
72
  return None
96
73
 
97
74
  # print("mean ", mean)
@@ -102,18 +79,6 @@ def eval_cost(x, iteration, step_param_names, step_objfunc, calib_params, req_qu
102
79
  print(flush=True)
103
80
  return cost
104
81
 
105
- # Simulator
106
- def global_best_sim(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters: int, options: Dict,
107
- oh_strategy: Dict = None, n_threads: int = 4, rtol: float = 0.001, ftol: float = -np.inf,
108
- ftol_iter: int = 1, full_trace: List = None, rtol_iter: int = 1,
109
- conf: Dict = None, metainfo: Dict = None, cost_target: float = -np.inf, result_queue: Queue = None) -> Tuple:
110
- import time
111
- while True:
112
- print("WOW", flush=True)
113
- if result_queue is not None:
114
- result_queue.put('WOW')
115
- time.sleep(1)
116
-
117
82
  def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters: int, options: Dict,
118
83
  oh_strategy: Dict = None, n_threads: int = 4, rtol: float = 0.001, ftol: float = -np.inf,
119
84
  ftol_iter: int = 1, full_trace: List = None, rtol_iter: int = 1,
@@ -275,16 +240,12 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
275
240
 
276
241
  args['rnd'] = r + 1
277
242
  args['step'] = s + 1
278
-
279
- print("g1")
280
243
 
281
244
  # perform optimization
282
245
  cost, pos = optimizer[s].optimize(eval_cost, iters=step.get('iters', iters), **args)
283
246
  if cost is None:
284
247
  early_exit = True
285
248
  break
286
-
287
- print("g2")
288
249
 
289
250
  # capture the best cost
290
251
  # if cost < best_cost[s] and np.abs(cost - best_cost[s]) > rtol:
@@ -293,8 +254,6 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
293
254
  no_improvement[s] = False
294
255
  utils.annotate_step(best_cost[s], pos, steps, s)
295
256
 
296
- print("g3")
297
-
298
257
  print('\n Step summary, best particle values: {} '.format(pos))
299
258
 
300
259
  if result_queue is not None:
@@ -306,24 +265,17 @@ def global_best(steps: Dict, rounds: Tuple, args: Dict, n_particles: int, iters:
306
265
  step_trace[key]['best_costs'] = best_cost
307
266
  step_trace[key]['steps'] = copy.deepcopy(steps)
308
267
 
309
- print("g4")
310
-
311
268
  if step_file is not None:
312
269
  with open(step_file, "w") as fo:
313
270
  json.dump(step_trace, fo)
314
271
 
315
- print("g5")
316
-
317
272
  # print(json.dumps(steps, sort_keys=False, indent=2))
318
273
 
319
274
  if early_exit:
320
- print("g6")
321
275
  step_trace['exit'] = '1'
322
276
  break
323
277
 
324
278
  round_cost = np.sum(best_cost)
325
-
326
- print("g7")
327
279
 
328
280
  # if no improvement in all steps, break out of rounds prematurely
329
281
  # but start checking only after min_rounds