fix evolopy's GA

This commit is contained in:
Connor Olding 2023-05-06 20:41:47 -07:00
parent 6e4b6f1dc9
commit bb755f67b9

View file

@ -181,14 +181,14 @@ def rouletteWheelSelectionId(scores, popSize):
"""
##reverse score because minimum value should have more chance of selection
reverse = max(scores) + min(scores)
reverse = max(scores)
reverseScores = reverse - scores.copy()
sumScores = sum(reverseScores)
pick = random.uniform(0, sumScores)
current = 0
for individualId in range(popSize):
current += reverseScores[individualId]
if current > pick:
if current >= pick:
return individualId