|
1
|
|
|
# Author: Simon Blanke |
|
2
|
|
|
# Email: [email protected] |
|
3
|
|
|
# License: MIT License |
|
4
|
|
|
|
|
5
|
|
|
indent = " " |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
def _print_times(eval_time, iter_time, n_iter): |
|
9
|
|
|
opt_time = iter_time - eval_time |
|
10
|
|
|
iterPerSec = n_iter / iter_time |
|
11
|
|
|
|
|
12
|
|
|
print( |
|
13
|
|
|
indent, |
|
14
|
|
|
"Evaluation time :", |
|
15
|
|
|
eval_time, |
|
16
|
|
|
"sec", |
|
17
|
|
|
indent, |
|
18
|
|
|
"[{} %]".format(round(eval_time / iter_time * 100, 2)), |
|
19
|
|
|
) |
|
20
|
|
|
print( |
|
21
|
|
|
indent, |
|
22
|
|
|
"Optimization time :", |
|
23
|
|
|
opt_time, |
|
24
|
|
|
"sec", |
|
25
|
|
|
indent, |
|
26
|
|
|
"[{} %]".format(round(opt_time / iter_time * 100, 2)), |
|
27
|
|
|
) |
|
28
|
|
|
if iterPerSec >= 1: |
|
29
|
|
|
print( |
|
30
|
|
|
indent, |
|
31
|
|
|
"Iteration time :", |
|
32
|
|
|
iter_time, |
|
33
|
|
|
"sec", |
|
34
|
|
|
indent, |
|
35
|
|
|
"[{} iter/sec]".format(round(iterPerSec, 2)), |
|
36
|
|
|
) |
|
37
|
|
|
else: |
|
38
|
|
|
secPerIter = iter_time / n_iter |
|
39
|
|
|
print( |
|
40
|
|
|
indent, |
|
41
|
|
|
"Iteration time :", |
|
42
|
|
|
iter_time, |
|
43
|
|
|
"sec", |
|
44
|
|
|
indent, |
|
45
|
|
|
"[{} sec/iter]".format(round(secPerIter, 2)), |
|
46
|
|
|
) |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
def _print_results(objective_function, score_best, para_best): |
|
50
|
|
|
print("\nResults: '{}'".format(objective_function.__name__), " ") |
|
51
|
|
|
if para_best is None: |
|
52
|
|
|
print(indent, "Best score:", score_best, " ") |
|
53
|
|
|
print(indent, "Best parameter:", para_best, " ") |
|
54
|
|
|
else: |
|
55
|
|
|
print(indent, "Best score:", score_best, " ") |
|
56
|
|
|
print(indent, "Best parameter:") |
|
57
|
|
|
for key in para_best.keys(): |
|
58
|
|
|
print(indent, indent, "'{}'".format(key), para_best[key], " ") |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
def print_info( |
|
62
|
|
|
verbosity, |
|
63
|
|
|
objective_function, |
|
64
|
|
|
score_best, |
|
65
|
|
|
para_best, |
|
66
|
|
|
eval_time, |
|
67
|
|
|
iter_time, |
|
68
|
|
|
n_iter, |
|
69
|
|
|
): |
|
70
|
|
|
|
|
71
|
|
|
if verbosity["print_results"] is True: |
|
72
|
|
|
_print_results(objective_function, score_best, para_best) |
|
73
|
|
|
|
|
74
|
|
|
if verbosity["print_times"] is True: |
|
75
|
|
|
_print_times(eval_time, iter_time, n_iter) |
|
76
|
|
|
|
|
77
|
|
|
|