source: framspy/evolalg/run_numerical_islands_example.py @ 1248

Last change on this file since 1248 was 1190, checked in by Maciej Komosinski, 2 years ago

Added the "evolalg" module for evolutionary optimization

File size: 1.2 KB
Line 
1from .numerical_example.numerical_islands_example import \
2    ExperimentNumericalIslands
3
4
5def main():
6    parsed_args = ExperimentNumericalIslands.get_args_for_parser().parse_args()
7    print("Argument values:", ", ".join(
8        ['%s=%s' % (arg, getattr(parsed_args, arg)) for arg in vars(parsed_args)]))
9
10    initialgenotype = [100, 100, 100, 100]
11    print('Best individuals:')
12    experiment = ExperimentNumericalIslands(
13        hof_size=parsed_args.hof_size,
14        popsize=parsed_args.popsize,
15        migration_interval=parsed_args.generations_migration,
16        number_of_populations=parsed_args.islands,
17        save_only_best=parsed_args.save_only_best)
18
19    hof, stats = experiment.evolve(hof_savefile=parsed_args.hof_savefile,
20                                   generations=parsed_args.generations,
21                                   initialgenotype=initialgenotype,
22                                   pmut=parsed_args.pmut,
23                                   pxov=parsed_args.pxov,
24                                   tournament_size=parsed_args.tournament)
25    print(len(hof))
26    for ind in hof:
27        print(ind.genotype, ind.rawfitness)
28
29
30if __name__ == "__main__":
31    main()
Note: See TracBrowser for help on using the repository browser.