Skip to content

Keep Parents Issue #49

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

Closed
edgardohb opened this issue Jun 18, 2021 · 4 comments
Closed

Keep Parents Issue #49

edgardohb opened this issue Jun 18, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@edgardohb
Copy link

Hello, first of all I would like to say you did an excellent job with the pygad project.

Secondly, I would like to address an issue I am having with the keep_parents parameter. I was running an algorithm yesterday and it was working fine, but some changes were made to the code apparently, and now everytime I assign a value to that parameter an error pops up. It is because some part of the code related to it has a variable as a tuple, but the atribute .shape is called upon, which is only supported for numpy arrays.

The error is the following:
AttributeError: 'tuple' object has no attribute 'shape'

And it happens on the line 1202 of the pygad.py code.

1200 elif (self.keep_parents > 0): 1201 parents_to_keep = self.steady_state_selection(self.last_generation_fitness, num_parents=self.keep_parents) -> 1202 self.population[0:parents_to_keep.shape[0], :] = parents_to_keep 1203 self.population[parents_to_keep.shape[0]:, :] = self.last_generation_offspring_mutation 1204

Is there a different way to implement this parameter now? Or if there is not is there a posibility that you would mind fixing the code?

Thanks for your time and work on the pygad project.

ahmedfgad added a commit that referenced this issue Jun 18, 2021
Fix a bug when keep_parents is set to a positive integer. #49
@ahmedfgad ahmedfgad self-assigned this Jun 18, 2021
@ahmedfgad ahmedfgad added the bug Something isn't working label Jun 18, 2021
@ahmedfgad
Copy link
Owner

Hello,

Thanks for opening this issue. It is solved now. The project is updated.

PyGAD 2.15.1 will be released shortly to address the issue.

Please feel free to get in touch if any issues arise.

ahmedfgad added a commit that referenced this issue Jun 18, 2021
Fix a bug when keep_parents is set to a positive integer. #49
@ahmedfgad
Copy link
Owner

PyGAD 2.15.1 is released that solves the issue.

Feel free to upgrade to the latest version:

pip3 install --upgrade pygad

Thank you!

@edgardohb
Copy link
Author

edgardohb commented Jun 18, 2021 via email

@ahmedfgad
Copy link
Owner

@edgardohb
Yes use this command to upgrade to latest version:

pip install --upgrade pygad

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