fix evolopy's GA
This commit is contained in:
parent
6e4b6f1dc9
commit
bb755f67b9
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue