Evolutionary.jl
Evolutionary.jl copied to clipboard
Selections refactor
Refactored selections.jl to fix some bugs (including issue https://github.com/wildart/Evolutionary.jl/issues/40) and improve clarity.
Coverage decreased (-22.5%) to 77.511% when pulling 340e30747a3532b42435ec20e94926b98db3f581 on aahaselgrove:selections_refactor into c7fb224c7d17691aaff0f5ce63987df9f3329c97 on wildart:master.
Separated out this change from others so it may be considered independently.
I can see that this change has broken the new selections.jl tests. Could you please explain what uniformranking is meant to do? My understanding of a 'uniform' selection is that each individual has an equal change of being selected. As the sum of probabilities must equal 1, your current implementation and tests don't make sense to me.
It isn't just uniform, it is (μ, λ)-uniform ranking which takes μ fittest individuals and selects uniformly from them. λ is a total number of individuals in the population. If you want a uniform selection you need to make that μ = λ.
I test the following:
s = uniformranking(2)
s([1,2,3], 2) == [2,3]
s
is the selection function which takes two fittest individuals that are in position 2 & 3 of the first parameters and then selects uniformly from them. I think the better test would be
sort(unique(s([1,2,3], 10))) == [2,3]
It wouldn't rely on RNG settings.
I don't think that removed the dependency on RNG settings, as the selector still chooses randomly. eg. in your example [2, 2] and [3, 3] would be equally valid results.