mg-pso-gui 0.1.122__tar.gz → 0.1.124__tar.gz

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.
Files changed (64) hide show
  1. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/PKG-INFO +1 -1
  2. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/PKG-INFO +1 -1
  3. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/SOURCES.txt +4 -0
  4. mg-pso-gui-0.1.124/mgpsogui/util/recosu/sampling/__init__.py +9 -0
  5. mg-pso-gui-0.1.124/mgpsogui/util/recosu/sampling/sample_trace_writer.py +47 -0
  6. mg-pso-gui-0.1.124/mgpsogui/util/recosu/sampling/sampler.py +99 -0
  7. mg-pso-gui-0.1.124/mgpsogui/util/recosu/sampling/sampler_task.py +75 -0
  8. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/setup.py +1 -1
  9. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/dependency_links.txt +0 -0
  10. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/entry_points.txt +0 -0
  11. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/requires.txt +0 -0
  12. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mg_pso_gui.egg-info/top_level.txt +0 -0
  13. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/__init__.py +0 -0
  14. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/HomePage.py +0 -0
  15. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/OptionManager.py +0 -0
  16. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/PlatformTab/PlatformTab.py +0 -0
  17. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/PlatformTab/__init__.py +0 -0
  18. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/RunTab/RunTab.py +0 -0
  19. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/RunTab/__init__.py +0 -0
  20. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/BoundsEditorWindow.py +0 -0
  21. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/BoundsList.py +0 -0
  22. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/CalibrationParametersView.py +0 -0
  23. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/FunctionsList.py +0 -0
  24. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/ListParametersView.py +0 -0
  25. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/OptimalParameterView.py +0 -0
  26. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/SetupTab.py +0 -0
  27. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/StaticParameterView.py +0 -0
  28. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/StepView.py +0 -0
  29. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/SetupTab/__init__.py +0 -0
  30. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/VisualizeTab/SideBar.py +0 -0
  31. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/VisualizeTab/VisualizeTab.py +0 -0
  32. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/VisualizeTab/__init__.py +0 -0
  33. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/__init__.py +0 -0
  34. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/IGOW 4 Logo.png +0 -0
  35. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/collapse.png +0 -0
  36. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/down.png +0 -0
  37. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/expand.png +0 -0
  38. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/play.png +0 -0
  39. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/refresh.png +0 -0
  40. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/refresh_hd.png +0 -0
  41. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/stop.png +0 -0
  42. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/test.png +0 -0
  43. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/trash.png +0 -0
  44. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/gui/images/up.png +0 -0
  45. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/mgpsogui.py +0 -0
  46. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/start.yaml +0 -0
  47. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/CTkToolTip/__init__.py +0 -0
  48. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/CTkToolTip/ctk_tooltip.py +0 -0
  49. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/GraphGenerator.py +0 -0
  50. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/PSORunner.py +0 -0
  51. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/__init__.py +0 -0
  52. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/debug.py +0 -0
  53. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/helpers.py +0 -0
  54. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/__init__.py +0 -0
  55. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/pso/__init__.py +0 -0
  56. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/pso/csip_access.py +0 -0
  57. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/pso/pso.py +0 -0
  58. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/utils/__init__.py +0 -0
  59. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/utils/plot/__init__.py +0 -0
  60. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/utils/plot/cost_steps.py +0 -0
  61. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/utils/trace_writer.py +0 -0
  62. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/recosu/utils/utils.py +0 -0
  63. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/mgpsogui/util/sampler_test_driver.py +0 -0
  64. {mg-pso-gui-0.1.122 → mg-pso-gui-0.1.124}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.1.122
3
+ Version: 0.1.124
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.1.122
3
+ Version: 0.1.124
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -51,6 +51,10 @@ mgpsogui/util/recosu/__init__.py
51
51
  mgpsogui/util/recosu/pso/__init__.py
52
52
  mgpsogui/util/recosu/pso/csip_access.py
53
53
  mgpsogui/util/recosu/pso/pso.py
54
+ mgpsogui/util/recosu/sampling/__init__.py
55
+ mgpsogui/util/recosu/sampling/sample_trace_writer.py
56
+ mgpsogui/util/recosu/sampling/sampler.py
57
+ mgpsogui/util/recosu/sampling/sampler_task.py
54
58
  mgpsogui/util/recosu/utils/__init__.py
55
59
  mgpsogui/util/recosu/utils/trace_writer.py
56
60
  mgpsogui/util/recosu/utils/utils.py
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ """
4
+ LUCA/PSO toolkit
5
+ =========================================
6
+ This is ...
7
+
8
+ """
9
+
@@ -0,0 +1,47 @@
1
+ import threading
2
+
3
+
4
+ class SampleTraceWriter:
5
+ trace_file: str
6
+ parameter_indices: dict[int, str]
7
+ objective_indices: dict[int, str]
8
+ write_lock: threading.Lock
9
+
10
+ def __init__(self, trace_file: str):
11
+ assert(trace_file is not None and len(trace_file) > 0)
12
+ self.trace_file = trace_file
13
+ self.parameter_indices = {}
14
+ self.objective_indices = {}
15
+ self.write_lock = threading.Lock()
16
+
17
+ def write_header(self, parameter_names: list[str], objective_names: list[str]) -> None:
18
+ with self.write_lock:
19
+ with open(self.trace_file, 'w') as writer:
20
+ writer.write("id")
21
+ self.parameter_indices = {}
22
+ index: int = 0
23
+ for name in parameter_names:
24
+ writer.write(",{}".format(name))
25
+ self.parameter_indices[index] = name
26
+ index = index + 1
27
+ self.objective_indices = {}
28
+ index = 0
29
+ for name in objective_names:
30
+ writer.write(",{}".format(name))
31
+ self.objective_indices[index] = name
32
+ index = index + 1
33
+ writer.write("\n")
34
+
35
+ def append_sample(self, sample_id: int, parameters: dict[str, any], objectives: dict[str, any]) -> None:
36
+ with self.write_lock:
37
+ with open(self.trace_file, 'a') as writer:
38
+ writer.write("{}".format(sample_id))
39
+ index: int = 0
40
+ while index < len(self.parameter_indices):
41
+ writer.write(",{}".format(parameters[self.parameter_indices[index]]))
42
+ index = index + 1
43
+ index = 0
44
+ while index < len(self.objective_indices):
45
+ writer.write(",{}".format(objectives[self.objective_indices[index]]))
46
+ index = index + 1
47
+ writer.write("\n")
@@ -0,0 +1,99 @@
1
+ from collections.abc import Iterable
2
+ import math
3
+ import asyncio
4
+ import concurrent
5
+ import datetime
6
+ from .recosu.utils import utils
7
+ from .recosu.sampling.halton.halton import HaltonSampleGenerator
8
+ from .recosu.sampling.random.random_sampler import RandomSampleGenerator
9
+ from .recosu.sampling.sampler_task import SamplerTask
10
+ from .recosu.sampling.sample_trace_writer import SampleTraceWriter
11
+
12
+
13
+ def weighted_value(weight: float, lower: float, upper: float) -> float:
14
+ return lower + weight * (upper - lower)
15
+
16
+
17
+ def get_static_parameters(args: dict[str, any]) -> dict[str, any]:
18
+ static_parameters: dict[str, any] = {}
19
+ for param in args["param"]:
20
+ static_parameters[param["name"]] = param["value"]
21
+ return static_parameters
22
+
23
+
24
+ def get_objective_names(objfunc: dict[str, any]) -> list[str]:
25
+ objective_names: list[str] = []
26
+ for of in objfunc:
27
+ objective_names.append(of["name"])
28
+ return objective_names
29
+
30
+
31
+ def thread_function(task: SamplerTask) -> tuple[bool, SamplerTask]:
32
+ return task.run_task(), task
33
+
34
+
35
+ def create_generator(method: str, count: int, num_parameters: int, **kwargs) -> Iterable[tuple[int, list[float]]]:
36
+ if method == "halton":
37
+ offset: int = 0
38
+ if "offset" in kwargs:
39
+ offset = kwargs["offset"]
40
+ return HaltonSampleGenerator(count, offset, num_parameters)
41
+ elif method == "random":
42
+ return RandomSampleGenerator(count, num_parameters)
43
+
44
+ raise Exception("Sampling method is not recognized")
45
+
46
+
47
+ def run_sampler(steps: list[dict[str, any]], args: dict[str, any], count: int, num_threads: int, method: str = "halton",
48
+ metainfo: dict[str, any] = None, conf: dict[str, any] = None, trace_file: str = "trace.csv",
49
+ **kwargs) -> dict[int, tuple[dict[str, any], dict[str, any]]]:
50
+ param_names, bounds, objfunc = utils.get_step_info(steps, 0)
51
+ generator: Iterable[tuple[int, list[float]]] = create_generator(method, count, len(param_names), **kwargs)
52
+ objective_names: list[str] = get_objective_names(objfunc)
53
+ static_parameters: dict[str, any] = get_static_parameters(args)
54
+ url: str = args["url"]
55
+ files: list[str] = args["files"]
56
+
57
+ trace: dict[int, tuple[dict[str, float], dict[str, float]]] = {}
58
+ trace_writer: SampleTraceWriter = SampleTraceWriter(trace_file)
59
+ trace_writer.write_header(param_names, objective_names)
60
+
61
+ with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
62
+ futures = []
63
+ for sample_id, sample in generator:
64
+ params: dict[str, float] = {}
65
+ index: int = 0
66
+ while index < len(sample):
67
+ params[param_names[index]] = weighted_value(sample[index], bounds[0][index], bounds[1][index])
68
+ index += 1
69
+
70
+ task: SamplerTask = SamplerTask(sample_id, params, objfunc, static_parameters, url, files, metainfo, conf)
71
+ futures.append(executor.submit(thread_function, task))
72
+ # for future in concurrent.futures.as_completed(futures):
73
+ # pass
74
+ num_finished: int = 0
75
+ percentage: float
76
+ last_percentage: float = 0
77
+ for future in concurrent.futures.as_completed(futures):
78
+ try:
79
+ successful, task = future.result()
80
+
81
+ if successful:
82
+ trace[task.task_id] = (task.parameters, task.result)
83
+ trace_writer.append_sample(task.task_id, task.parameters, task.result)
84
+ else:
85
+ print("Failed to successfully execute task: {}", task.task_id)
86
+ except asyncio.CancelledError as ce:
87
+ pass
88
+ except asyncio.InvalidStateError as ise:
89
+ pass
90
+ except Exception as ex:
91
+ print(ex)
92
+
93
+ num_finished = num_finished + 1
94
+ percentage = math.trunc(num_finished / count * 1000) / 10
95
+ if percentage > last_percentage:
96
+ last_percentage = percentage
97
+ print("{}% Done {}".format(percentage, datetime.datetime.now()))
98
+
99
+ return trace
@@ -0,0 +1,75 @@
1
+ import os
2
+ from csip import Client
3
+
4
+
5
+ class SamplerTask:
6
+ task_id: int
7
+ parameters: dict[str, any]
8
+ objectives: list[dict[str, any]]
9
+ static_parameters: dict[str, any]
10
+ url: str
11
+ files: list[str]
12
+ metainfo: dict[str, any]
13
+ conf: dict[str, any]
14
+ result: dict[str, any]
15
+
16
+ def __init__(self, task_id: int, parameters: dict[str, any], objectives: list[dict[str, any]],
17
+ static_parameters: dict[str, any], url: str, files: list[str] = None, metainfo: dict[str, any] = None,
18
+ conf: dict[str, any] = None):
19
+ self.task_id = task_id
20
+ assert (parameters is not None and len(parameters) > 0)
21
+ self.parameters = parameters
22
+ assert (objectives is not None and len(objectives) > 0)
23
+ self.objectives = objectives
24
+ self.static_parameters = static_parameters if static_parameters is not None else []
25
+ assert (url is not None and len(url) > 0)
26
+ self.url = url
27
+ self.files = files if files is not None else []
28
+ self.metainfo = metainfo
29
+ self.conf = conf
30
+
31
+ def create_request(self) -> Client:
32
+ request: Client = Client(metainfo=self.metainfo)
33
+
34
+ for key, value in self.static_parameters.items():
35
+ request.add_data(key, value)
36
+
37
+ for key, value in self.parameters.items():
38
+ request.add_data(key, value)
39
+
40
+ for of in self.objectives:
41
+ request.add_cosu(of['name'], of['of'], of['data'])
42
+
43
+ return request
44
+
45
+ def run_task(self) -> bool:
46
+ self.result = {}
47
+ request: Client = self.create_request()
48
+ async_call: bool = self.conf.get('async_call', True) if self.conf is not None else True
49
+ # save response, set it to a folder if responses should be saved.
50
+ save_resp = self.conf.get('save_response_to', None) if self.conf is not None else None
51
+ successful: bool = False
52
+
53
+ response: Client = None
54
+ try:
55
+ if async_call:
56
+ response = request.execute_async(self.url, files=self.files, conf=self.conf)
57
+ else:
58
+ response = request.execute(self.url, files=self.files, conf=self.conf)
59
+
60
+ successful = response.is_finished()
61
+ if not successful:
62
+ print(response)
63
+
64
+ if save_resp:
65
+ response.save_to(os.path.join(save_resp, 'task_{}.json'.format(self.task_id)))
66
+
67
+ objectives: list[dict[str, str]] = response.get_metainfo("cosu")
68
+ for of in objectives:
69
+ self.result[of["name"]] = of["value"]
70
+ except Exception as ex:
71
+ print(ex)
72
+ print(response)
73
+ successful = False
74
+
75
+ return successful
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
  import codecs
3
3
  import os
4
4
 
5
- VERSION = '0.1.122'
5
+ VERSION = '0.1.124'
6
6
  DESCRIPTION = 'GUI for MG-PSO'
7
7
  LONG_DESCRIPTION = open('../README.md').read()
8
8
 
File without changes