CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.42k stars 493 forks source link

Population size of 1 gives Zero Division Error #201

Closed AtaTrkgl closed 3 years ago

AtaTrkgl commented 4 years ago

p = neat.Population(config) gives the following error if the pop_size is set to 1 in the config.txt

File "<Python Dir>\lib\site-packages\neat\population.py", line 47, in __init__
    self.species.speciate(config, self.population, self.generation)
  File "<Python Dir>8\lib\site-packages\neat\species.py", line 136, in speciate
    gdmean = mean(itervalues(distances.distances))
  File "<Python Dir>\lib\site-packages\neat\math_util.py", line 9, in mean
    return sum(map(float, values)) / len(values)
ZeroDivisionError: division by zero
samwincott commented 4 years ago

In neat/species.py on line 137, it is trying to calculate the average distance between genomes. However because there is only one genome there are no other genomes to calculate the distance to, and so there are no distances to average.

jbacopulos commented 4 years ago

@samwincott how do you use one genome and not get this error?

adohail2137 commented 3 years ago

naprawcie to pls