1 | from FramsticksLib import FramsticksLib
|
---|
2 | from .structures.individual import Individual
|
---|
3 | from .frams_base.experiment_frams_islands import ExperimentFramsIslands
|
---|
4 |
|
---|
5 |
|
---|
6 | def main():
|
---|
7 | # random.seed(123) # see FramsticksLib.DETERMINISTIC below, set to True if you want full determinism
|
---|
8 | # must be set before FramsticksLib() constructor call
|
---|
9 | FramsticksLib.DETERMINISTIC = False
|
---|
10 | parsed_args = ExperimentFramsIslands.get_args_for_parser().parse_args()
|
---|
11 | Individual.fitness_set_negative_to_zero = parsed_args.fitness_set_negative_to_zero # setting the "static" field once
|
---|
12 | print("Argument values:", ", ".join(
|
---|
13 | ['%s=%s' % (arg, getattr(parsed_args, arg)) for arg in vars(parsed_args)]))
|
---|
14 | # multiple criteria not supported here. If needed, use FramsticksEvolution.py
|
---|
15 | opt_criteria = parsed_args.opt.split(",")
|
---|
16 | framsLib = FramsticksLib(
|
---|
17 | parsed_args.path, parsed_args.lib, parsed_args.sim)
|
---|
18 | constrains = {"max_numparts": parsed_args.max_numparts,
|
---|
19 | "max_numjoints": parsed_args.max_numjoints,
|
---|
20 | "max_numneurons": parsed_args.max_numneurons,
|
---|
21 | "max_numconnections": parsed_args.max_numconnections,
|
---|
22 | "max_numgenochars": parsed_args.max_numgenochars,
|
---|
23 | }
|
---|
24 |
|
---|
25 | experiment = ExperimentFramsIslands(frams_lib=framsLib,
|
---|
26 | optimization_criteria=opt_criteria,
|
---|
27 | hof_size=parsed_args.hof_size,
|
---|
28 | constraints=constrains,
|
---|
29 | genformat=parsed_args.genformat,
|
---|
30 | popsize=parsed_args.popsize,
|
---|
31 | migration_interval=parsed_args.generations_migration,
|
---|
32 | number_of_populations=parsed_args.islands,
|
---|
33 | save_only_best=parsed_args.save_only_best)
|
---|
34 |
|
---|
35 | experiment.evolve(hof_savefile=parsed_args.hof_savefile,
|
---|
36 | generations=parsed_args.generations,
|
---|
37 | initialgenotype=parsed_args.initialgenotype,
|
---|
38 | pmut=parsed_args.pmut,
|
---|
39 | pxov=parsed_args.pxov,
|
---|
40 | tournament_size=parsed_args.tournament)
|
---|
41 |
|
---|
42 |
|
---|
43 | if __name__ == "__main__":
|
---|
44 | main()
|
---|