Total Complexity | 5 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # Author: Simon Blanke |
||
2 | # Email: [email protected] |
||
3 | # License: MIT License |
||
4 | |||
5 | |||
6 | import numpy as np |
||
7 | |||
8 | |||
9 | def init_candidate(_main_args_, nth_process, Candidate): |
||
10 | _main_args_._set_random_seed(nth_process) |
||
11 | _cand_ = Candidate(nth_process, _main_args_) |
||
12 | |||
13 | return _cand_ |
||
14 | |||
15 | |||
16 | def merge_dicts(base_dict, added_dict): |
||
17 | # overwrite default values |
||
18 | for key in base_dict.keys(): |
||
19 | if key in list(added_dict.keys()): |
||
20 | base_dict[key] = added_dict[key] |
||
21 | |||
22 | return base_dict |
||
23 | |||
24 | |||
25 | def sort_for_best(sort, sort_by): |
||
26 | # Returns two lists sorted by the second |
||
27 | sort = np.array(sort) |
||
28 | sort_by = np.array(sort_by) |
||
29 | |||
30 | index_best = list(sort_by.argsort()[::-1]) |
||
31 | |||
32 | sort_sorted = sort[index_best] |
||
33 | sort_by_sorted = sort_by[index_best] |
||
34 | |||
35 | return sort_sorted, sort_by_sorted |
||
36 |