-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
49 lines (34 loc) · 1.22 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy
import random
from tblup.config import parser
from pprint import PrettyPrinter
from tblup.utils import build_kwargs
from tblup.population import Population
from tblup.local import get_local_search
def main():
"""
Main entry point.
"""
args = parser.parse_args()
PrettyPrinter(indent=4).pprint({k: v for k, v in args.__dict__.items() if not k.isupper()})
random.seed(args.seed)
numpy.random.seed(args.seed)
kwargs = build_kwargs(args)
evaluator = kwargs['evaluator']
with evaluator:
population = Population(**kwargs)
population.monitor.save_indices(evaluator, args)
for gen in range(1, args.generations + 1):
should_continue = population.do_generation()
if not should_continue:
break
results = evaluator.evaluate_testing(population)
population.monitor.write(
["Testing"] + population.monitor.get_row_summary(results) + ["Final"]
)
population.monitor.save_archive(population)
if args.local_search is not None:
genome, fitness = get_local_search(args, population).search()
population.monitor.report_local(genome, fitness)
if __name__ == '__main__':
main()