source: framspy/evolalg/run_frams_niching.py @ 1292

Last change on this file since 1292 was 1289, checked in by Maciej Komosinski, 11 months ago

fitness_set_negative_to_zero boolean (a.k.a. "only positive fitness", needed for novelty and niching diversity control) becomes a command-line flag instead of a hardcoded value

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