Description
Describe the bug
In the config documentation, it is written that Elitism is “the number of most-fit individuals in each species that will be preserved as-is from one generation to the next.” (https://neat-python.readthedocs.io/en/latest/config_file.html). However, when plotting the mean/max fitness of all species over time (see screenshot below), some species eventually lost their most-fit individual, as seen by the fluctuations of their maximum fitness value. The elitism got set to 5 in my case.
To Reproduce
Looking at the source code of the reproduction-class, I observed that the elitism only gets applied to the non-stagnant species (https://neat-python.readthedocs.io/en/latest/_modules/reproduction.html), which explains the fluctuations.
Proposal regarding behaviour of Elitism
I would therefore like to propose to consider adding an additional boolean parameter to the config-file, by which the user can select whether elitism should be applied to all species, or only to the non-stagnant ones. Depending on the use case, users might want to choose how the elitism gets applied.
For the current implementation of elitism, I observed cases where the total best individual from the whole population got lost due to their species stagnating (e.g. species 5 in the screenshot at generation ~65). Some species also started to worsen in their fitness after loosing their best performing genome (e.g. species 4 in screenshot). This might also be related to this currently open issue:
#271
If adding an additional parameter to the config-file is not possible, I would at least like to propose to either change the description of Elitism to “the number of most-fit individuals in each non-stagnant species that will be preserved as-is from one generation to the next.”, or to apply elitism to all species.
Thank you!
Desktop:
- OS: Windows 10 64-bit
- Version neat-python 0.92
Screenshot: