Evolutionary.jl icon indicating copy to clipboard operation
Evolutionary.jl copied to clipboard

Selections refactor

Open aahaselgrove opened this issue 5 years ago • 5 comments

Refactored selections.jl to fix some bugs (including issue https://github.com/wildart/Evolutionary.jl/issues/40) and improve clarity.

aahaselgrove avatar Sep 30 '19 07:09 aahaselgrove

Coverage Status

Coverage decreased (-22.5%) to 77.511% when pulling 340e30747a3532b42435ec20e94926b98db3f581 on aahaselgrove:selections_refactor into c7fb224c7d17691aaff0f5ce63987df9f3329c97 on wildart:master.

coveralls avatar Sep 30 '19 07:09 coveralls

Separated out this change from others so it may be considered independently.

aahaselgrove avatar Oct 12 '19 09:10 aahaselgrove

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.

aahaselgrove avatar Oct 15 '19 18:10 aahaselgrove

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.

wildart avatar Oct 15 '19 19:10 wildart

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.

aahaselgrove avatar Oct 16 '19 01:10 aahaselgrove