Genetic Algorithms
The Genetic Operators: Selection, Crossover and Mutation
| Operator | What it does |
|---|---|
| Selection | Chooses which chromosomes become PARENTS for the next generation, biased toward higher fitness (but not exclusively the single best, to preserve diversity) — roulette-wheel selection (probability of selection proportional to fitness) and tournament selection (pick k at random, keep the fittest of those k) are the two standard mechanisms. |
| Crossover | Combines genetic material from TWO parent chromosomes into one or two offspring — single-point crossover cuts both parents at the same random position and swaps the tails, so an offspring inherits a prefix from one parent and a suffix from the other; this is the primary EXPLOITATION operator, recombining already-promising partial solutions. |
| Mutation | Randomly flips/alters a small number of positions in a SINGLE offspring's chromosome (e.g. a bit-flip mutation), applied at a LOW probability — this is the primary EXPLORATION operator, introducing genetic material that crossover alone (which only recombines what already exists in the population) could never produce, and guarding against the population converging prematurely on a merely locally-good solution. |
The GA Cycle
- INITIALISE a population of chromosomes, typically at random.
- EVALUATE every chromosome's fitness using the problem-specific fitness function.
- SELECT parents biased toward higher fitness.
- Apply CROSSOVER to selected parent pairs to produce offspring.
- Apply MUTATION to the offspring at a low probability.
- REPLACE (all or part of) the old population with the new offspring, forming the next generation, and repeat from step 2 until a stopping criterion (a fitness threshold, or a fixed number of generations) is reached.
Problem Solving Using GAs
GAs suit problems with a HUGE, poorly-structured search space where no efficient exact algorithm is known — function optimisation with many local optima, scheduling and timetabling with many interacting constraints, and evolving the STRUCTURE of a solution (not just its parameter values) are standard application classes. A worked sketch: to maximise f(x) = x² over integer x in [0, 31], encode x as a 5-bit binary chromosome (32 possible values exactly fill 5 bits), let fitness be f(x) itself (no transformation needed, since larger x is already better), select parents biased toward higher x², apply single-point crossover and low-probability bit-flip mutation, and iterate — a population containing, say, 11111 (x = 31, the true optimum) would dominate selection quickly once discovered, since its fitness (961) is far above the rest, which is exactly the selection pressure that drives convergence toward the optimum.
Key takeaways
- A GA encodes candidate solutions as chromosomes; the fitness function is the only problem-specific part, letting the same GA machinery reuse across problems.
- Selection is biased toward fitness; crossover recombines two parents (exploitation); mutation randomly alters one offspring at low probability (exploration).
- Crossover alone cannot introduce genetic material absent from the whole population; mutation alone loses the benefit of combining distinct good partial solutions — both are needed.
- The GA cycle is initialise, evaluate, select, crossover, mutate, replace, repeat until a stopping criterion is met.
- A GA is a heuristic search — it finds a good solution, not a guaranteed global optimum, and can get stuck at a locally-good solution.
Practice questions (8)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
In a genetic algorithm, the fitness function is:
Show answer
Answer: A — The only problem-specific part, letting the same generic GA machinery be reused across different problems
The fitness function is evaluated every generation and is the sole component tailored to the specific problem being solved; the rest of the GA (selection, crossover, mutation mechanics) stays generic.Crossover, compared to mutation, is best described as the operator that mainly provides:
Show answer
Answer: A — Exploitation — recombining genetic material already present in the population
Crossover recombines material from two existing parents, refining already-promising partial solutions; it is mutation that introduces genuinely new material absent from the whole population.If no chromosome anywhere in the population has a particular useful bit pattern, that pattern can be introduced by:
Show answer
Answer: A — Mutation, but not crossover alone
Crossover only ever recombines material already present somewhere in the population; mutation is the operator capable of introducing genuinely new material that was absent everywhere.In the standard GA cycle, the correct order of steps in one generation is:
Show answer
Answer: A — Evaluate fitness, select parents, crossover, mutate, replace population
Fitness must be known before selection can be biased toward it, and crossover/mutation act on the selected parents to produce the next generation's offspring before replacement.A genetic algorithm is best described as:
Show answer
Answer: A — A heuristic search, not guaranteed to find the global optimum
Like any local-improvement-based metaheuristic, a GA can get stuck making progress toward a merely locally-good solution — it is a practical heuristic for hard search problems, not a method that proves optimality.Which of the following are standard chromosome encodings used in genetic algorithms? (More than one option may be correct.)
Show answer
Answer: A — A fixed-length binary string; B — A real-valued encoding; C — A permutation encoding (an ordering of items)
Binary strings are the classical choice, but real-valued and permutation encodings are standard alternatives chosen when they fit the problem more naturally — the travelling salesman problem's permutation encoding is a standard example.Name the selection mechanism in which the probability of a chromosome being selected is proportional to its fitness, commonly visualised as spinning a wheel divided into slices sized by fitness.
Numerical answer — type the value.
Show answer
Answer: roulette wheel selection
Roulette-wheel selection biases choice toward fitter chromosomes without excluding weaker ones entirely, alongside tournament selection as the two standard selection mechanisms.Single-point crossover on two parent chromosomes works by:
Show answer
Answer: A — Cutting both parents at the same random position and swapping the tails to form offspring
Single-point crossover picks one cut position and swaps the tails beyond it between the two parents, so each offspring inherits a prefix from one parent and a suffix from the other — a two-parent operator, unlike mutation's single-chromosome operation.