From bb755f67b9c4dcfd398cdb61e3af72ed28389f5c Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 6 May 2023 20:41:47 -0700 Subject: [PATCH] fix evolopy's GA --- evolopy/GA.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evolopy/GA.py b/evolopy/GA.py index 3a6b8c7..32b58de 100644 --- a/evolopy/GA.py +++ b/evolopy/GA.py @@ -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