[1289] | 1 | import numpy as np
|
---|
[1190] | 2 | from .numerical_example.numerical_example import ExperimentNumerical
|
---|
[1289] | 3 | from .structures.individual import Individual
|
---|
[1190] | 4 |
|
---|
| 5 |
|
---|
| 6 | def main():
|
---|
| 7 | parsed_args = ExperimentNumerical.get_args_for_parser().parse_args()
|
---|
[1289] | 8 | Individual.fitness_set_negative_to_zero = parsed_args.fitness_set_negative_to_zero # setting the "static" field once
|
---|
[1190] | 9 | print("Argument values:", ", ".join(
|
---|
| 10 | ['%s=%s' % (arg, getattr(parsed_args, arg)) for arg in vars(parsed_args)]))
|
---|
| 11 |
|
---|
[1289] | 12 | initialgenotype = np.array([100, 100, 100, 100])
|
---|
[1190] | 13 | experiment = ExperimentNumerical(
|
---|
| 14 | hof_size=parsed_args.hof_size,
|
---|
| 15 | popsize=parsed_args.popsize,
|
---|
| 16 | save_only_best=parsed_args.save_only_best)
|
---|
| 17 |
|
---|
| 18 | hof, stats = experiment.evolve(hof_savefile=parsed_args.hof_savefile,
|
---|
| 19 | generations=parsed_args.generations,
|
---|
| 20 | initialgenotype=initialgenotype,
|
---|
| 21 | pmut=parsed_args.pmut,
|
---|
| 22 | pxov=parsed_args.pxov,
|
---|
| 23 | tournament_size=parsed_args.tournament)
|
---|
[1289] | 24 | print('Best individuals:')
|
---|
[1190] | 25 | for ind in hof:
|
---|
[1293] | 26 | print(ind.rawfitness, '\t<--\t', ind.genotype)
|
---|
[1190] | 27 |
|
---|
| 28 |
|
---|
| 29 | if __name__ == "__main__":
|
---|
| 30 | main()
|
---|