mg-pso-gui 0.2.126__py3-none-any.whl → 0.2.127__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.2.126
3
+ Version: 0.2.127
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -57,7 +57,8 @@ mgpsogui/util/CTkToolTip/__init__.py,sha256=G1jxV55hGtGgwyC1sR-uUUdasDdh0XZgcI-a
57
57
  mgpsogui/util/CTkToolTip/ctk_tooltip.py,sha256=SZMovpQIGvdpDRbqCKl9SHs92DrFCO2MOYL2ifolvOE,6329
58
58
  mgpsogui/util/recosu/__init__.py,sha256=pPR0lB6clIi6q73H1W8eT5u0dd3bIemwa9-XFmOaVVk,279
59
59
  mgpsogui/util/recosu/pso/__init__.py,sha256=PQ548aEKVOk6MMzxxDg7yMO_1hHfoEoYLLkGLeij73Y,247
60
- mgpsogui/util/recosu/pso/csip_access.py,sha256=_oA71d6CSwhKSa3pgywIW7mXRJtgJTNu1X2DiBkQkuA,4152
60
+ mgpsogui/util/recosu/pso/csip_access.py,sha256=jBli1MSShUUwQCMKOUvMaGuNwBViCrjXJi_FmSEJsZA,2721
61
+ mgpsogui/util/recosu/pso/csip_access_new.py,sha256=_oA71d6CSwhKSa3pgywIW7mXRJtgJTNu1X2DiBkQkuA,4152
61
62
  mgpsogui/util/recosu/pso/pso modified.py,sha256=sFY1csASu5Os5SSheWWdpVcjpPwJeBqZKsv89DLXdxk,21648
62
63
  mgpsogui/util/recosu/pso/pso.py,sha256=iPqT6aI1vi8LYuWmtxuHkLEM9sQwhUznPInBgps7ANI,13708
63
64
  mgpsogui/util/recosu/pso/pso_new.py,sha256=qUwpp6gjhCTXA6twKGAda84HIeQebKGB6MJ4K9GfcdM,23181
@@ -75,8 +76,8 @@ mgpsogui/util/recosu/utils/trace_writer.py,sha256=V9BJlOjCbNYGoXGEk3CF5wjifBxvar
75
76
  mgpsogui/util/recosu/utils/utils.py,sha256=6MIoJb0nhIa4tNv7qhBfZi-AtL3L95CgJf6eAf12NQs,4140
76
77
  mgpsogui/util/recosu/utils/plot/__init__.py,sha256=h1KjM7_tNDv351pcwt8A6Ibb1jhwWyx5Gbu-zj-sI3Q,71
77
78
  mgpsogui/util/recosu/utils/plot/cost_steps.py,sha256=1Ce11AJyweWkmvjXPxEygzS-h8yVLmQEDLS53yjPLqQ,3779
78
- mg_pso_gui-0.2.126.dist-info/METADATA,sha256=WoBCQFVK_l0TIamnui7_FpcDK8hr6Tc0-a5kYKXAQV0,9542
79
- mg_pso_gui-0.2.126.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
80
- mg_pso_gui-0.2.126.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
81
- mg_pso_gui-0.2.126.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
82
- mg_pso_gui-0.2.126.dist-info/RECORD,,
79
+ mg_pso_gui-0.2.127.dist-info/METADATA,sha256=CKrIBp-9Wkp8fyOPmG0KADmYCL5jRNH3OBKdhit0Rl8,9542
80
+ mg_pso_gui-0.2.127.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
81
+ mg_pso_gui-0.2.127.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
82
+ mg_pso_gui-0.2.127.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
83
+ mg_pso_gui-0.2.127.dist-info/RECORD,,
@@ -10,56 +10,25 @@ def csip_worker(reqq: queue.Queue, thread_no: int, stop, full_trace,
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
12
  while not stop():
13
+
13
14
  try:
14
- (rnd, step, iteration, particle, x, step_param, calib_params, objfunc, resq) = reqq.get(True, 0.5)
15
+ (rnd, step, iteration, particle, x, step_param_names, calib_params, objfunc, resq) = reqq.get(True, 0.5)
15
16
  # print(thread_no, particle)
16
-
17
+
17
18
  c = Client(metainfo=metainfo)
18
19
 
19
- all_params = {}
20
-
21
20
  # static params (from args)
22
21
  for param in arg_params:
23
22
  c.add_data(param['name'], param['value'])
24
23
 
25
24
  # particle params (generated from steps)
26
25
  # for i, value in enumerate(x):
27
- # for idx, value in enumerate(x[particle, :]):
28
- # c.add_data(step_param_names[idx], value)
29
- values = x[particle]
30
- idx = 0
31
- for p in step_param:
32
- value_type = p.get('type', 'float')
33
- if 'float' == value_type:
34
- c.add_data(p['name'], values[idx])
35
- all_params[p['name']] = values[idx]
36
- idx = idx + 1
37
- elif 'list' == value_type:
38
- base_name = p['name']
39
- calibration_strategy = p.get('calibration_strategy', 'mean')
40
-
41
- if 'mean' == calibration_strategy:
42
- mean = values[idx]
43
- default_value = p['default_value']
44
- value = [(1 + mean) * x for x in default_value]
45
- c.add_data(base_name, value)
46
- all_params[base_name] = value
47
- idx = idx + 1
48
- elif 'single' == calibration_strategy:
49
- default_value = p['default_value']
50
- sub_index = 0
51
- value = default_value.copy()
52
- while sub_index < len(default_value):
53
- value[sub_index] = values[idx]
54
- idx = idx + 1
55
- sub_index = sub_index + 1
56
- c.add_data(base_name, value)
57
- all_params[base_name] = value
26
+ for idx, value in enumerate(x[particle, :]):
27
+ c.add_data(step_param_names[idx], value)
58
28
 
59
29
  # other, previously calibrated params (other steps)
60
30
  for name, value in calib_params.items():
61
31
  c.add_data(name, value)
62
- all_params[name] = value
63
32
 
64
33
  # objective function info
65
34
  for of in objfunc:
@@ -75,31 +44,31 @@ def csip_worker(reqq: queue.Queue, thread_no: int, stop, full_trace,
75
44
  else:
76
45
  res = c.execute(url, files=files, conf=conf)
77
46
 
78
- # run_string = 'r{}s{}i{}p{}.json'.format(rnd, step, iteration, particle)
47
+ if res.is_failed():
48
+ print(res)
79
49
 
80
50
  if save_resp:
81
51
  res.save_to(os.path.join(save_resp, 'r{}s{}i{}p{}.json'.format(rnd, step, iteration, particle)))
82
-
83
- if res.is_failed():
84
- print(u'F')
85
- # print(res)
86
- resq.put((particle, 100))
87
- else:
88
- # print(res)
89
- # print(u'\u2714', end='', flush=True)
90
- print(u'O', end='', flush=True)
91
- cost = utils.calc_cost(res, objfunc)
92
- resq.put((particle, cost))
93
- # break
52
+
53
+ # print(res)
54
+ print('O', end='', flush=True)
55
+
56
+ cost = utils.calc_cost(res, objfunc)
94
57
 
95
58
  if full_trace is not None:
59
+ all_params = {}
60
+ # for i, value in enumerate(x):
61
+ for idx, value in enumerate(x[particle, :]):
62
+ all_params[step_param_names[idx]] = value
63
+
64
+ for name, value in calib_params.items():
65
+ all_params[name] = value
96
66
  full_trace.append((all_params, cost))
97
67
 
98
68
  resq.put((particle, cost))
99
- except:
100
- print(u'sF')
101
- resq.put((particle, 100))
102
- continue
69
+ except Exception as e:
70
+ print(res)
71
+ print(e)
103
72
 
104
73
  reqq.task_done()
105
74
  except queue.Empty:
@@ -0,0 +1,106 @@
1
+ from cosu import utils
2
+ from csip import Client
3
+ from typing import List, Dict, Tuple
4
+ import queue, os
5
+
6
+
7
+ def csip_worker(reqq: queue.Queue, thread_no: int, stop, full_trace,
8
+ url, files, arg_params, conf: Dict, metainfo: Dict) -> None:
9
+ async_call = conf.get('async_call', True) # default is async
10
+ save_resp = conf.get('save_response_to', None) # save response, set it to a folder if responses should be saved.
11
+
12
+ while not stop():
13
+ try:
14
+ (rnd, step, iteration, particle, x, step_param, calib_params, objfunc, resq) = reqq.get(True, 0.5)
15
+ # print(thread_no, particle)
16
+
17
+ c = Client(metainfo=metainfo)
18
+
19
+ all_params = {}
20
+
21
+ # static params (from args)
22
+ for param in arg_params:
23
+ c.add_data(param['name'], param['value'])
24
+
25
+ # particle params (generated from steps)
26
+ # for i, value in enumerate(x):
27
+ # for idx, value in enumerate(x[particle, :]):
28
+ # c.add_data(step_param_names[idx], value)
29
+ values = x[particle]
30
+ idx = 0
31
+ for p in step_param:
32
+ value_type = p.get('type', 'float')
33
+ if 'float' == value_type:
34
+ c.add_data(p['name'], values[idx])
35
+ all_params[p['name']] = values[idx]
36
+ idx = idx + 1
37
+ elif 'list' == value_type:
38
+ base_name = p['name']
39
+ calibration_strategy = p.get('calibration_strategy', 'mean')
40
+
41
+ if 'mean' == calibration_strategy:
42
+ mean = values[idx]
43
+ default_value = p['default_value']
44
+ value = [(1 + mean) * x for x in default_value]
45
+ c.add_data(base_name, value)
46
+ all_params[base_name] = value
47
+ idx = idx + 1
48
+ elif 'single' == calibration_strategy:
49
+ default_value = p['default_value']
50
+ sub_index = 0
51
+ value = default_value.copy()
52
+ while sub_index < len(default_value):
53
+ value[sub_index] = values[idx]
54
+ idx = idx + 1
55
+ sub_index = sub_index + 1
56
+ c.add_data(base_name, value)
57
+ all_params[base_name] = value
58
+
59
+ # other, previously calibrated params (other steps)
60
+ for name, value in calib_params.items():
61
+ c.add_data(name, value)
62
+ all_params[name] = value
63
+
64
+ # objective function info
65
+ for of in objfunc:
66
+ c.add_cosu(of['name'], of['of'], of['data'])
67
+ # c.add_data(of['name'], (of['data'][0], of['data'][1]))
68
+
69
+ print('.', end='', flush=True)
70
+
71
+ try:
72
+ # print(c)
73
+ if async_call:
74
+ res = c.execute_async(url, files=files, conf=conf)
75
+ else:
76
+ res = c.execute(url, files=files, conf=conf)
77
+
78
+ # run_string = 'r{}s{}i{}p{}.json'.format(rnd, step, iteration, particle)
79
+
80
+ if save_resp:
81
+ res.save_to(os.path.join(save_resp, 'r{}s{}i{}p{}.json'.format(rnd, step, iteration, particle)))
82
+
83
+ if res.is_failed():
84
+ print(u'F')
85
+ # print(res)
86
+ resq.put((particle, 100))
87
+ else:
88
+ # print(res)
89
+ # print(u'\u2714', end='', flush=True)
90
+ print(u'O', end='', flush=True)
91
+ cost = utils.calc_cost(res, objfunc)
92
+ resq.put((particle, cost))
93
+ # break
94
+
95
+ if full_trace is not None:
96
+ full_trace.append((all_params, cost))
97
+
98
+ resq.put((particle, cost))
99
+ except:
100
+ print(u'sF')
101
+ resq.put((particle, 100))
102
+ continue
103
+
104
+ reqq.task_done()
105
+ except queue.Empty:
106
+ continue