Selection operator picks out individuals in the population for reproduction in genetic algorithms. Roulette wheel selection that an imaginary proportion of the wheel is assigned to each of the chromosomes based on their fitness value. The fitter chromosome has more chance to select than worse one. Roulette wheel selection is a kind of elitist selection that retaining the best individuals in a generation unchanged in the next generation.
Here an example of roulette wheel selection via pyhton. Imagine that you have population like
And you use a proper fitness function regarding to your problem, and get a python dictionary to wrap your individuals and their fitness values like
Firstly, we can create a probability list (imaginary proportion of the wheel)
After that, we can write the roulette wheel selection function. Parameters of the function are our population, probability list of the population and a number to select desired individuals for reproduction.