Last change
on this file since 1220 was
1190,
checked in by Maciej Komosinski, 2 years ago
|
Added the "evolalg" module for evolutionary optimization
|
File size:
1.1 KB
|
Rev | Line | |
---|
[1190] | 1 | from .numerical_example.numerical_example import ExperimentNumerical
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | def main():
|
---|
| 5 | parsed_args = ExperimentNumerical.get_args_for_parser().parse_args()
|
---|
| 6 | print("Argument values:", ", ".join(
|
---|
| 7 | ['%s=%s' % (arg, getattr(parsed_args, arg)) for arg in vars(parsed_args)]))
|
---|
| 8 |
|
---|
| 9 | initialgenotype = [100, 100, 100, 100]
|
---|
| 10 | print('Best individuals:')
|
---|
| 11 | experiment = ExperimentNumerical(
|
---|
| 12 | hof_size=parsed_args.hof_size,
|
---|
| 13 | popsize=parsed_args.popsize,
|
---|
| 14 | save_only_best=parsed_args.save_only_best)
|
---|
| 15 |
|
---|
| 16 | hof, stats = experiment.evolve(hof_savefile=parsed_args.hof_savefile,
|
---|
| 17 | generations=parsed_args.generations,
|
---|
| 18 | initialgenotype=initialgenotype,
|
---|
| 19 | pmut=parsed_args.pmut,
|
---|
| 20 | pxov=parsed_args.pxov,
|
---|
| 21 | tournament_size=parsed_args.tournament)
|
---|
| 22 | print(len(hof))
|
---|
| 23 | for ind in hof:
|
---|
| 24 | print(ind.genotype, ind.rawfitness)
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | if __name__ == "__main__":
|
---|
| 28 | main()
|
---|
Note: See
TracBrowser
for help on using the repository browser.