Skip to content

keep_elitism only works when crossover_type==None #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mxflknbrg opened this issue Sep 19, 2022 · 1 comment
Open

keep_elitism only works when crossover_type==None #132

mxflknbrg opened this issue Sep 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@mxflknbrg
Copy link

With PyGAD 2.18.0 the keep_elitism=1 paramter was introduced. Apparently this only works when no crossover operation is selected. This is a strange behavior, because in my understanding Selection(e.g. Elitism) and Crossover build on each other. A normal (simplified) generation cycle should therefore look something like this:

  1. Init
  2. Evaluate fitness
  3. Selection (e.g. steady-state, rank, elitism)
  4. Crossover (e.g. one-point, uniform)
  5. Mutation (e.g. random, swap)
  6. -> 2.

To summarize, I would expect the elitism parameter to allow some of the best parents to pass unchanged into the next generation. This is not the case, and therefor the fitness value didn't converge.
Compare the lines 1348 - 1373 of the pygad.py file

@mxflknbrg mxflknbrg changed the title keep_elitism only works when crossover_type==None keep_elitism only works when crossover_type==None Sep 19, 2022
@ahmedfgad ahmedfgad added the bug Something isn't working label Sep 19, 2022
ahmedfgad added a commit that referenced this issue Sep 19, 2022
A big fix when `keep_elitism` is used. #132
@ahmedfgad
Copy link
Owner

Thank you. The issue is solved and a new release is published (2.18.1). Please update the package using pip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants