Closed daffidwilde closed 5 years ago
Feel free to play around with the best_prop
and lucky_prop
parameters and you will see the change in the recorded fitness scores/populations.
It makes sense that the last iteration is correct of course since nothing is popped from it.
A simple solution would be to take a copy of each population and its fitness scores during the selection process. I think I can just do that with copy.deepcopy
. Any other suggestions are welcome as always.
Implemented this fix in #23.
There may be a better way of fixing this or it could be evaded in refactoring down the line. Reopening.
In
run_algorithm
fitnesses are being calculated properly but in all cases bar the last iteration, onlybest_prop
of the fitnesses are being appended to the history of all fitnesses. Likewise with the populations.As I'm writing this, I think I know why. The best proportion of individuals are selected and taken from a population using
population.pop(best)
as required. I hadn't accounted for the fact that this would change things globally resulting in the already appended population/scores being edited as well. I assume something about pointers?Anyway, I will think of a work around on this one... but here is an example of the kind of behaviour I'm experiencing.
Using the fitness-recording-issue branch and its added
print
statements:Which certainly does not make any sense. Then to double check everything: