GA: Fitness Function & Selection
Source: Unit 5 §4
The fitness function defines the criterion both for ranking hypotheses and for probabilistically selecting them for the next generation. Everything on this page is about turning a fitness number into a parent.
The four selection methods
| Method | How it works |
|---|---|
| Roulette wheel (fitness proportionate) | Selection probability is proportional to fitness / total fitness. |
| Tournament | Pick 2 chromosomes at random; with probability p, the fitter one wins. |
| Rank | Sort by fitness, then make selection probability proportional to rank rather than raw fitness. |
| Elitism | Always retain the best chromosomes into the next generation, untouched. |
Roulette wheel selection in detail
Imagine a wheel whose circumference is , the sum of all fitnesses. Each chromosome occupies an arc proportional to its fitness. Spin the wheel, and whichever arc lands at the fixed pointer is selected. Repeat times.
The worked 5-city TSP example
Ten chromosomes with :
| # | Chromosome | Fitness | Cumulative |
|---|---|---|---|
| 1 | d-e-a-b-c | 193 | 193 |
| … | … | … | … |
| 6 | c-e-d-a-b | 197 | 1089 |
| 7 | e-a-d-b-c | 222 | 1311 |
| … | … | … | … |
- Draw a random number in ; here it is 1279.
- Walk the cumulative column until the running total first exceeds it.
- , so the walk stops at chromosome 7.
- Chromosome 7,
e-a-d-b-c, is selected.
Early on, one lucky chromosome with a huge fitness eats most of the wheel and the population converges prematurely. Late on, when everything has similar fitness, the arcs are nearly equal and selection degenerates into a random choice, so evolution stalls. Rank selection is the standard fix for both.