Skip to content

Division by 0 if fitness_sum is 0 #129

Open
@ghost

Description

Hi,

I encountered a case where, if I'm using roulette wheel selection or stochastic universal selection and if the fitness sum is 0, there will be a division by 0. I know that probably it's very little probability to encounter such a case, but my suggestion would be to instead of having probs = fitness / fitness_sum
to have:

if fitness_sum !=0:
   probs = fitness / fitness_sum
else:
   probs = 0

or instead of probs=0, to divide fitness by a very large number.

Best Regards!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions