# Selection Strategies & Elitism

Selection is an important part of an evolutionary algorithm. Without selection directing the algorithm towards fitter solutions there would be no progress. Selection must favour fitter candidates over weaker candidates but beyond that there are no fixed rules. Furthermore, there is no one strategy that is best for all problems. Some strategies result in fast convergence, others will tend to produce a more thorough exploration of the search space. An evolutionary algorithm that appears ineffective with one selection strategy may be transformed by switching to a strategy with different characteristics. This chapter describes the most commonly used selection strategies (all of these strategies are supported in the Watchmaker Framework for Evolutionary Computation via different implementations of the `SelectionStrategy` interface).

## Truncation Selection

Truncation selection is the simplest and arguably least useful selection strategy. Truncation selection simply retains the fittest `x`% of the population. These fittest individuals are duplicated so that the population size is maintained. For example, we might select the fittest 25% from a population of 100 individuals. In this case we would create four copies of each of the 25 candidates in order to maintain a population of 100 individuals. This is an easy selection strategy to implement but it can result in premature convergence as less fit candidates are ruthlessly culled without being given the opportunity to evolve into something better. Nevertheless, truncation selection can be an effective strategy for certain problems.

## Fitness-Proportionate Selection

A better approach to selection is to give every individual a chance of being selected to breed but to make fitter candidates more likely to be chosen than weaker individuals. This is achieved by making an individual's survival probability a function of its fitness score. Such strategies are known as fitness-proportionate selection.

### Roulette Wheel Selection

The most common fitness-proportionate selection technique is called Roulette Wheel Selection. Conceptually, each member of the population is allocated a section of an imaginary roulette wheel. Unlike a real roulette wheel the sections are different sizes, proportional to the individual's fitness, such that the fittest candidate has the biggest slice of the wheel and the weakest candidate has the smallest. The wheel is then spun and the individual associated with the winning section is selected. The wheel is spun as many times as is necessary to select the full set of parents for the next generation.

Using this technique it is possible (probable) that one or more individuals is selected multiple times. That's OK, it's what we want to happen. Remember that we are not selecting the members of the next generation, we are selecting their parents and it is possible for an individual to be a parent multiple times. If there is a particularly fit member of the population we would expect it to be more successful at producing offspring than a weaker rival.

### Stochastic Universal Sampling

Stochastic Universal Sampling is an elaborately-named variation of roulette wheel selection. Stochastic Universal Sampling ensures that the observed selection frequencies of each individual are in line with the expected frequencies. So if we have an individual that occupies 4.5% of the wheel and we select 100 individuals, we would expect on average for that individual to be selected between four and five times. Stochastic Universal Sampling guarantees this. The individual will be selected either four times or five times, not three times, not zero times and not 100 times. Standard roulette wheel selection does not make this guarantee.

Stochastic Universal Sampling works by making a single spin of the roulette wheel. This provides a starting position and the first selected individual. The selection process then proceeds by advancing all the way around the wheel in equal sized steps, where the step size is determined by the number of individuals to be selected. So if we are selecting 30 individuals we will advance by 1/30 x 360 degrees for each selection. Note that this does not mean that every candidate on the wheel will be selected. Some weak individuals will have very thin slices of the wheel and these might be stepped over completely depending on the random starting position.

## Rank Selection

Rank Selection is similar to fitness-proportionate selection except that selection probability is proportional to relative fitness rather than absolute fitness. In other words, it doesn't make any difference whether the fittest candidate is ten times fitter than the next fittest or 0.001% fitter. In both cases the selection probabilities would be the same; all that matters is the ranking relative to other individuals.

Rank selection will tend to avoid premature convergence by tempering selection pressure for large fitness differentials that occur in early generations. Conversely, by amplifying small fitness differences in later generations, selection pressure is increased compared to alternative selection strategies.

## Tournament Selection

Tournament Selection is among the most widely used selection strategies in evolutionary algorithms. It works well for a wide range of problems, it can be implemented efficiently, and it is amenable to parallelisation.

At its simplest tournament selection involves randomly picking two individuals from the population and staging a tournament to determine which one gets selected. The "tournament" isn't much of a tournament at all, it just involves generating a random value between zero and one and comparing it to a pre-determined selection probability. If the random value is less than or equal to the selection probability, the fitter candidate is selected, otherwise the weaker candidate is chosen. The probability parameter provides a convenient mechanism for adjusting the selection pressure. In practise it is always set to be greater than 0.5 in order to favour fitter candidates. The tournament can be extended to involve more than two individuals if desired.

## Sigma Scaling

Like rank selection, Sigma Scaling attempts to moderate selection pressure over time so that it is not too strong in early generations and not too weak once the population has stabilised and fitness differences are smaller. The Greek letter Sigma is used in statistics to denote standard deviation and that's what it means here too. The standard deviation of the population fitness is used to scale the fitness scores so that selection pressure is relatively constant over the lifetime of the evolutionary program.

## Elitism

Sometimes good candidates can be lost when cross-over or mutation results in offspring that are weaker than the parents. Often the EA will re-discover these lost improvements in a subsequent generation but there is no guarantee. To combat this we can use a feature known as elitism. Elitism involves copying a small propotion of the fittest candidates, unchanged, into the next generation. This can sometimes have a dramatic impact on performance by ensuring that the EA does not waste time re-discovering previously discarded partial solutions. Candidate solutions that are preserved unchanged through elitism remain eligible for selection as parents when breeding the remainder of the next generation.

The Watchmaker Framework supports elitism via the second parameter to the `evolve` method of an EvolutionEngine. This elite count is the number of candidates in a generation that should be copied unchanged from the previous generation, rather than created via evolution. Collectively these candidates are the elite. So for a population size of 100, setting the elite count to 5 will result in the fittest 5% of each generation being copied, without modification, into the next generation.