source: framspy/evolalg/run_frams_niching.py @ 1316

Last change on this file since 1316 was 1308, checked in by Maciej Komosinski, 6 months ago

Added the ability to select a dissimilarity measure for crowding distance (for NSGA2 and NSLC) independently from the main dissimilarity measure

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                                        crowding_dissim=parsed_args.crowding_dissim,
33                                        fit=parsed_args.fit,
34                                        genformat=parsed_args.genformat,
35                                        popsize=parsed_args.popsize,
36                                        archive_size=parsed_args.archive,
37                                        save_only_best=parsed_args.save_only_best,
38                                        knn_niching=parsed_args.knn_niching,
39                                        knn_nslc=parsed_args.knn_nslc)
40
41    experiment.evolve(hof_savefile=parsed_args.hof_savefile,
42                      generations=parsed_args.generations,
43                      initialgenotype=parsed_args.initialgenotype,
44                      pmut=parsed_args.pmut,
45                      pxov=parsed_args.pxov,
46                      tournament_size=parsed_args.tournament)
47
48
49if __name__ == "__main__":
50    main()
Note: See TracBrowser for help on using the repository browser.