Cleaner comments

This commit is contained in:
SimpleArt
2020-12-02 18:55:25 -05:00
parent 23efae27dc
commit 4386f2c959

View File

@ -204,16 +204,15 @@ class Parent_Selection:
in range(len(ga.population)) in range(len(ga.population))
] ]
sum_weights = sum(weights) offset = sum(weights) * (1 - ga.selection_probability)
# Rescale and adjust using selection_probability # Rescale and adjust using selection_probability so that
# so that # if selection_probability is high, a low offset is used,
# if selection_probability is high, # making selection mostly based on fitness.
# parents are more likely selected based on fitness. # if selection_probability is low, a high offset is used,
# if selection_probability is low, # inflating the weights so that everyone has a more equal chance.
# parents are more likely selected based on randomness.
weights = [ weights = [
weight / sum_weights - ga.selection_probability + 1 weight + offset
for weight for weight
in weights in weights
] ]