ahmedfgad / GeneticAlgorithmPython

Source code of PyGAD, a Python 3 library for building the genetic algorithm and training machine learning algorithms (Keras & PyTorch).
https://pygad.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.9k stars 467 forks source link

Rank versus Steady State Parent Selection #20

Closed DSKritzinger closed 4 years ago

DSKritzinger commented 4 years ago

It seems that the two parent selection technique are exactly the same. Rank parent selection is however meant to be more of an explorative parent selection approach where every chromosome/solution is assigned a selection probability with respect to its rank (which is based on its fitness). This is meant to decouple the selection probability from the population fitness distribution in order to avoid selection exploitation from very strong solutions.

Rank selection is essentially the same as Roulette Wheel Selection, but instead of weighting each solutions selection probability by its fitness, the weighting should be done the rank of the solutions compared to the other solutions.

urowietu commented 4 years ago

Another option which is what I tend to use is “quantile” survival selection, where the best quarter of all parents survive. I do so on the intuition that this keeps all equally good parents and is more like nature, the inspiration.

Sent from my iPhone

On 17 Nov 2020, at 07:34, DSKritzinger notifications@github.com wrote:

 It seems that the two parent selection technique are exactly the same. Rank parent selection is however meant to be more of an explorative parent selection approach where every chromosome/solution is assigned a selection probability with respect to its rank (which is based on its fitness). This is meant to decouple the selection probability from the population fitness distribution in order to avoid selection exploitation from very strong solutions.

Rank selection is essentially the same as Roulette Wheel Selection, but instead of weighting each solutions selection probability by its fitness, the weighting should be done the rank of the solutions compared to the other solutions.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

DSKritzinger commented 4 years ago

Although 'quantile' parent selection is an option, the main reason for my raised 'issue', is due to the incorrect implementation of 'rank parent selection'. It is also maybe necessary to provide more details in the project documentation regarding the details of the selection methods or at least link an article off of which the selection methods were based for the reader to understand the method.

These recommendations are solely made as I really enjoy using this project and feel it has a lot of potential.

ahmedfgad commented 4 years ago

Hi,

Thanks for raising this issue. It opened my eyes over something to be changed.

First of all, I confirm that there is no issue in the implementation. It could be regarded as duplicating the same feature. Let me make things clear.

For the rank parent selecting, the parents are ranked according to their fitness values and the ones with the highest fitness values are selected as parents. Based on those selected parents, offspring are created. In the next generation, the population will be formed only from the offspring and the parents are not selected.

For the steady-state parent selection, then it already works as the rank parent selection type but the difference is that it keeps the parents in the current generation in the population of the next generation. This is why this selection type is called steady-state as it keeps the best state (solution) until better state (solution) is found.

You can find more information about the selection types at this link.

In this project (PyGAD), initially I made the steady-state parent selection to include the parent in the next generation. So, keeping the parents in the next generation was an exclusive feature to the steady-state parent selection only.

In a later release of PyGAD, I made a change to make things general to support keeping the parents in the next population for any type of parent selection. This is by using the keep_parents parameter in the constructor of the pygad.ga class. Check the documentation of the parameters here: https://pygad.readthedocs.io/en/latest/README_pygad_ReadTheDocs.html#init

When the keep_parents parameter is set to-1, then all the parents are kept in the next population. This is exactly what the steady-state selection was working initially.

After supporting the keep_parents parameter, I should have removed the steady-state selection and just kept the rank selection as it works exactly as the steady-state selection when keep_parents=-1.

I keep this into consideration in the next release of PyGAD.

Thank you too much for the notice.

Please let me know if you have any more doubts or suggestions.

Regards, Ahmed

DSKritzinger commented 4 years ago

This makes sense now! Thank you.