1
|
|
|
# Author: Simon Blanke |
2
|
|
|
# Email: [email protected] |
3
|
|
|
# License: MIT License |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
from .search import Search |
7
|
|
|
from .search_process import SearchProcess |
8
|
|
|
from .process_arguments import ProcessArguments |
9
|
|
|
from .verbosity import Verbosity |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class Optimizer: |
13
|
|
|
def __init__( |
14
|
|
|
self, random_state=None, verbosity=3, warnings=False, ext_warnings=False, |
15
|
|
|
): |
16
|
|
|
self.verb = Verbosity(verbosity, warnings) |
17
|
|
|
self.random_state = random_state |
18
|
|
|
self.search_processes = [] |
19
|
|
|
|
20
|
|
|
def add_search(self, *args, **kwargs): |
21
|
|
|
pro_arg = ProcessArguments(args, kwargs, random_state=self.random_state) |
22
|
|
|
|
23
|
|
|
for nth_job in range(pro_arg.n_jobs): |
24
|
|
|
new_search_process = SearchProcess(nth_job, pro_arg, self.verb) |
25
|
|
|
self.search_processes.append(new_search_process) |
26
|
|
|
|
27
|
|
|
self.search = Search(self.search_processes) |
28
|
|
|
|
29
|
|
|
def run(self, max_time=None): |
30
|
|
|
if max_time is not None: |
31
|
|
|
max_time = max_time * 60 |
32
|
|
|
|
33
|
|
|
self.search.run(max_time) |
34
|
|
|
|
35
|
|
|
""" |
36
|
|
|
dist = Distribution() |
37
|
|
|
dist.dist(Search, self._main_args_) |
38
|
|
|
|
39
|
|
|
self.results = dist.results |
40
|
|
|
self.pos_list = dist.pos |
41
|
|
|
# self.para_list = None |
42
|
|
|
self.score_list = dist.scores |
43
|
|
|
|
44
|
|
|
self.eval_times = dist.eval_times |
45
|
|
|
self.iter_times = dist.iter_times |
46
|
|
|
self.best_scores = dist.best_scores |
47
|
|
|
""" |
48
|
|
|
|