How to organize the choice of roulette wheels for an disordered population in the genetic algorithm?

My question is related to this: The choice of roulette in the genetic algorithm. First you need to sort the population? If we do not sort the population, what is the way to organize the choice of the roulette wheel? Of course, we must search linearly. Do you have C ++ or Java code snippets for this case?

+5
source share
1 answer

The population does not need to be sorted at all - the key to choosing roulette is that the likelihood that a given person will be selected to play will be proportional to his suitability.

Say you have an unsortable population, with activities as follows:

[12, 45, 76, 32, 54, 21]

, 0 240 ( ). , , , . , , 112, :

Step 1: 112 - 12 = 100. This is > 0, so continue.
Step 2: 100 - 45 = 55.  This is > 0, so continue.
Step 3: 55 - 76 = -21.  This is <= 0, so stop.

, № 3 . , .

, :

let s = sum of population fitness
let r = random number in range [0, s].
let i = 0.
while r > 0 do:
    r = r - fitness of individual #i
    increment i
select individual #i - 1 for reproduction.

, - 1 - increment i, ( , , ).

+12

All Articles