Skip to content

Keep Parents Issue #49

Closed
Closed
@edgardohb

Description

@edgardohb

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions