Skip to content

fix NoCrossover missing offsprings #744

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gideonoludeyi
Copy link
Contributor

Resolves #743

NoCrossover does random selection which fails to propagate certain parents.
This PR ensures that all parents are propagated as offsprings.

Thanks @oxinabox for the catch.

@@ -7,4 +9,4 @@ def __init__(self, *, n_parents=1, n_offsprings=1, prob=0.0, **kwargs):
super().__init__(n_parents, n_offsprings, prob, **kwargs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it this way means you always have exactly as many offsping as parents.
So either you can't take both as rguments (or you can but you need to error if they are not equal)

Or you need to do it differently:
e.g. start with list(itertools.chain.from_iterable(pop)) and if noffspring less than npartents randomly select a subset.
Or if it is higher randomly duplicate some

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NoCrossOver does random selection
2 participants