From 4386f2c959f6f5732c5c764657521a68c8d694d1 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Wed, 2 Dec 2020 18:55:25 -0500 Subject: [PATCH] Cleaner comments --- src/parent_selection/parent_selection_methods.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/parent_selection/parent_selection_methods.py b/src/parent_selection/parent_selection_methods.py index e6ce1f7..7692cdf 100644 --- a/src/parent_selection/parent_selection_methods.py +++ b/src/parent_selection/parent_selection_methods.py @@ -204,16 +204,15 @@ class Parent_Selection: in range(len(ga.population)) ] - sum_weights = sum(weights) + offset = sum(weights) * (1 - ga.selection_probability) - # Rescale and adjust using selection_probability - # so that - # if selection_probability is high, - # parents are more likely selected based on fitness. - # if selection_probability is low, - # parents are more likely selected based on randomness. + # Rescale and adjust using selection_probability so that + # if selection_probability is high, a low offset is used, + # making selection mostly based on fitness. + # if selection_probability is low, a high offset is used, + # inflating the weights so that everyone has a more equal chance. weights = [ - weight / sum_weights - ga.selection_probability + 1 + weight + offset for weight in weights ]