|
children = one_point_crossover(chosen_selections[parent_index], |
I know it's just an example but IMHO there are two problems with the actual implementation of the reproduction step:
the reproduce_children() function is called with 100 genes but
- half of the parents are not used at all:
- it combines chosen_selections[0] with chosen_selections[1]
- then chosen_selections[1] with chosen_selections[2]
- and so on and until chosen_selections[48] is combined with chosen_selections[49]
- chosen_selections[50:] is not used at all
- it forget the results of reproduction:
- only the two children of last iteration are returned
- all others are ignored
Grokking-Artificial-Intelligence-Algorithms/ch04-evolutionary_algorithms/knapsack_genetic_algorithm.py
Line 171 in 89002a4
I know it's just an example but IMHO there are two problems with the actual implementation of the reproduction step:
the reproduce_children() function is called with 100 genes but