Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 36 ยท Selection

Tournament Selection

Learn tournament selection, the most popular selection method in genetic algorithms: how tournament size sets selection pressure, with probabilistic and deterministic variants.

If you remember only one selection method from this course, make it tournament selection. It is simple to code, fast, works with any fitness values (negative, huge, minimized or maximized), and gives you a single knob, the tournament size, that directly controls how greedy the search is. That combination is why most modern GA libraries default to it.

The idea is exactly what it sounds like: to pick one parent, draw k individuals at random from the population, let them "compete", and return the fittest. Repeat for as many parents as you need.

The algorithm

TEXT
select_parent(population, k):
    contenders = k random individuals from population
    return the contender with the best fitness

That is all. Notice what the algorithm does not need: it never sums fitness values, never normalizes them and never cares about their scale. It only asks "which of these is better?" so it works unchanged when fitness is -cost, when it is 1 to 1,000,000, or when you minimize.

Python Tournament selection and its selection pressure

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With k = 1 there is no selection at all: the winner is a random individual, so the mean is about 50. As k grows, winners come from higher and higher ranks. With k = 10, about two thirds of parents come from the top 10 percent.

Tournament size is selection pressure

Selection pressure is how strongly selection favors the fit. For tournaments there is a neat exact formula. If the population is ranked from worst to best and sampling is with replacement, the chance that a contender of relative rank r (a number between 0 and 1, where 1 is the best) wins is

P(win) = r^k - (r - 1/N)^k

You do not need the formula; the table of results above tells the story:

Tournament size k Behavior
1 No selection: random choice
2 Binary tournament: gentle pressure, very common default
3 to 5 Moderate to strong pressure
10 or more Very strong: fast convergence, high risk of premature convergence

Use small tournaments for hard, rugged problems that need exploration and larger ones for easy, smooth problems or short runs.

Probabilistic tournaments

A hard tournament always picks the best contender. A probabilistic tournament picks the best with probability p (say 0.8), the second best with probability p(1 - p), and so on. This reduces the pressure without changing k and lets weak individuals sometimes survive.

Python Deterministic versus probabilistic tournaments

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Lowering p brings the mean down towards the value of a smaller tournament, so there are two ways to tune the pressure: k and p.

Sampling choices

  • With or without replacement. Drawing contenders with random.sample (without replacement) prevents the same individual from filling a tournament. Drawing with random.choices allows repeats and makes the maths cleaner. For k much smaller than N the difference is negligible.
  • Contenders may include the same winner repeatedly. The same strong individual can win many tournaments in one generation; that is normal and intended.
  • Parents of crossover should differ. If you pick two parents, you can re-draw if they are the same individual, to avoid a cloning crossover.

Tournaments in a complete GA

Because tournaments need only comparisons, the same selector works for any representation and for single or constrained problems (with a suitable comparison). Below, the selector takes a key so that it can work with minimization problems.

Python Tournament selection driving a TSP GA

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This preview uses order crossover, which you will study in crossover for permutations. The point here is that tournament did not change when we moved from bit strings to tours: only the key did.

Strengths and weaknesses

Strengths: simple, O(k) per selection, no scaling needed, works for minimization and any scale, trivially parallel, adjustable pressure.

Weaknesses: pressure is discrete in k (sizes 2 and 3 are quite different), the best individual can win many tournaments, and, with very large k, diversity collapses. Pure tournaments also ignore how much better one individual is than another, only that it is better.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does tournament selection do to choose one parent?

    A random group of k contenders competes and the best one wins. The group size k controls the pressure.
  2. 2. What tournament size gives no selection pressure at all?

    With k = 1 the winner is a random individual, so selection is uniform.
  3. 3. Why does tournament selection work with minimization or negative fitness values?

    Only the comparison "which is better" is needed, so the sign and scale of the fitness do not matter.
  4. 4. How can you reduce pressure without changing the tournament size?

    If the best contender wins only with probability p, weaker contenders sometimes win and the effective pressure falls.

Summary

  • Tournament selection picks the best of k random contenders; it needs only comparisons.
  • The tournament size k sets selection pressure: 2 is gentle, 5 or more is strong.
  • Probabilistic tournaments (best wins with probability p) soften the pressure further.
  • It works for minimization, negative values and any representation by changing the comparison key.
  • It is the default in most libraries because it is simple, fast and robust.

Next: Rank and Truncation Selection