Search by simulated evolution β for problems where you can score a solution but not construct one.
π Where this lives: genetic algorithms earn their place where the search space is huge, the landscape is rugged, and you have no gradient to follow. Antenna shapes for spacecraft, timetables, circuit layouts, wind-farm turbine placement, and the neural-architecture searches that designed some deployed networks β all cases where a human can evaluate a candidate easily and design one only with difficulty. NASA's evolved antenna for the ST5 mission looks like a bent paperclip and outperformed the hand-designed alternative. Search "evolved antenna NASA ST5 genetic algorithm design".
The idea and the vocabulary
A GENETIC ALGORITHM (GA) is a search and optimisation method
inspired by natural selection. It maintains a POPULATION of
candidate solutions and improves it over GENERATIONS by
SELECTION, CROSSOVER and MUTATION.
IT IS A METAHEURISTIC β a general strategy for searching, not a
method tied to one problem. Compare the search of ACtE0902: A*
explores one path at a time guided by a heuristic, while a GA
maintains many candidates at once and has no notion of a path.
THE BIOLOGICAL VOCABULARY, mapped to computation:
BIOLOGY COMPUTATION
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
individual one candidate solution
chromosome the encoded representation of it
gene one element of the encoding
allele the value a gene takes
population the set of candidates in the current
generation
fitness the quality of a candidate, from the
objective function
generation one iteration of the algorithm
selection choosing which candidates reproduce
crossover (recombination) combining two parents
mutation a random change to one individual
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
THE ALGORITHM:
initialise a population of N random individuals
evaluate the fitness of each
repeat until a termination condition holds:
SELECT parents according to fitness
CROSSOVER pairs of parents to produce offspring
MUTATE the offspring with small probability
evaluate the offspring's fitness
form the next generation
return the best individual found
THE THREE OPERATORS DO DIFFERENT JOBS, and understanding the
division is the key to the topic:
SELECTION applies the PRESSURE β it decides what survives,
and so it EXPLOITS what has been found
CROSSOVER RECOMBINES existing good material, exploring
combinations of features already present
MUTATION INTRODUCES NEW material that no parent had, which
is the only way to recover a value lost from the
whole population
SELECTION WITHOUT VARIATION CONVERGES IMMEDIATELY AND STOPS;
VARIATION WITHOUT SELECTION IS RANDOM SEARCH. The balance
between them is the explorationβexploitation trade-off from
the reinforcement learning topic, appearing in a new form.
ENCODING β the first and most consequential design decision:
BINARY STRINGS the classic, and the form the syllabus
expects
REAL-VALUED VECTORS for continuous parameters
PERMUTATIONS for ordering problems such as the
travelling salesman, where standard
crossover would produce invalid tours and
special operators are required
TREES for evolving programs β GENETIC
PROGRAMMING
A GOOD ENCODING MAKES SMALL CHANGES IN THE CHROMOSOME
CORRESPOND TO SMALL CHANGES IN THE SOLUTION. If a one-bit flip
can transform a good solution into a terrible one, the search
cannot make progress β which is the representation argument
from the problem-formulation topic, applying again.
The operators, worked
THE STANDARD WORKED EXAMPLE (following Goldberg): maximise
f(x) = xΒ² for integer x in 0β¦31, using 5-bit binary chromosomes.
ββ THE INITIAL POPULATION AND FITNESS ββββββββββββββββββββββββ
chromosome x f(x) = xΒ² share of total
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
01100 12 144 12.5%
11001 25 625 54.1%
00101 5 25 2.2%
10011 19 361 31.3%
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
total fitness 1155 average 288.75 best 625
ββ SELECTION ββββββββββββββββββββββββββββββββββββββββββββββββ
ROULETTE WHEEL (fitness-proportionate): each individual gets a
slice of a wheel proportional to its fitness, and the wheel is
spun once per parent needed.
11001 occupies 54.1% of the wheel and 00101 only 2.2%, so
the strong candidate is roughly TWENTY-FIVE TIMES more likely
to be chosen. THE EXPECTED NUMBER OF COPIES of individual i
is fα΅’ / fΜ β here 625/288.75 = 2.16 copies of 11001 and
25/288.75 = 0.09 of 00101.
THE PROBLEMS WITH ROULETTE WHEEL, and each has a fix:
PREMATURE CONVERGENCE β one very fit individual dominates
the wheel early, fills the population, and diversity is
lost before the space has been explored
it fails if fitness can be NEGATIVE, and is distorted if all
fitnesses are large and similar (little selection
pressure)
FIXES:
RANK SELECTION β select by rank order rather than raw
fitness, so the pressure is constant regardless of the
fitness spread
TOURNAMENT SELECTION β pick k individuals at random and
take the best. Simple, cheap, and the pressure is tuned
by k. THE MOST USED METHOD IN PRACTICE.
FITNESS SCALING β rescale fitnesses to control the spread
ELITISM β copy the best individual(s) unchanged into the
next generation, guaranteeing the best solution is never
lost. NEARLY ALWAYS USED, because without it a GA can
get worse from one generation to the next.
ββ CROSSOVER ββββββββββββββββββββββββββββββββββββββββββββββββ
SINGLE-POINT CROSSOVER: choose a cut position and exchange the
tails.
parents chosen: 01100 and 11001, cut after position 3:
01100 β 011 | 00
11001 β 110 | 01
offspring:
011|01 = 01101 = 13, f = 169
110|00 = 11000 = 24, f = 576
NOTE THAT ONE CHILD IS WORSE THAN BOTH PARENTS AND ONE IS
BETWEEN THEM. Crossover is not guaranteed to improve
anything β it explores, and selection does the improving.
OTHER FORMS:
TWO-POINT CROSSOVER β exchange a middle segment
UNIFORM CROSSOVER β decide each gene independently from
either parent, which mixes more aggressively
ARITHMETIC CROSSOVER β for real-valued encodings, take a
weighted average of the parents
ORDER-BASED CROSSOVER (OX, PMX) β for permutations, designed
so the offspring is still a valid permutation
CROSSOVER PROBABILITY p_c is typically 0.6 to 0.9 β most pairs
are crossed.
ββ MUTATION ββββββββββββββββββββββββββββββββββββββββββββββββ
Flip each bit with a small probability p_m.
11000 (24, f = 576), flipping bit 1:
11000 β 10000 = 16, f = 256
HERE MUTATION MADE IT WORSE, which is typical β most
mutations are harmful, and the useful ones are rare and
essential.
MUTATION PROBABILITY is typically 1/L, where L is the
chromosome length β so on average ONE BIT PER INDIVIDUAL
changes. For a 5-bit chromosome that is p_m = 0.2; for a
100-bit chromosome, 0.01.
TOO LOW and the population loses diversity and stagnates;
TOO HIGH and the search becomes random, destroying the good
material selection has accumulated.
ββ TERMINATION βββββββββββββββββββββββββββββββββββββββββββββ
a fixed number of generations; a fitness threshold reached;
no improvement for k generations; or a time budget.
A GA HAS NO NATURAL STOPPING POINT β it does not know when it
has found the optimum, which is the price of having no
optimality guarantee.
Why it works, and when to use it
WHY A GA CAN WORK AT ALL β the schema theorem, in outline:
A SCHEMA is a template with wildcards: 1**01 matches 11001,
11101, 10001 and 10101. It names a SUBSET of the search
space sharing certain positions.
THE BUILDING BLOCK HYPOTHESIS: a GA works by discovering
short, low-order schemata of above-average fitness β BUILDING
BLOCKS β and recombining them into better solutions.
Holland's SCHEMA THEOREM states that short, low-order,
above-average schemata receive exponentially increasing
numbers of trials in successive generations.
THE HYPOTHESIS IS PLAUSIBLE AND CONTESTED β it does not fully
explain GA behaviour, and problems can be constructed
(DECEPTIVE problems) where recombining good building blocks
leads away from the optimum. IT IS WORTH KNOWING AS THE
STANDARD EXPLANATION AND NOT AS A PROOF.
THE IMPLICIT PARALLELISM ARGUMENT is stronger: a population of N
individuals of length L samples many schemata simultaneously, so
a GA evaluates a great deal of structural information with each
generation of fitness evaluations.
WHEN A GA IS THE RIGHT TOOL:
Β· the search space is LARGE and poorly understood
Β· there is NO GRADIENT β the objective is not
differentiable, or is a simulation, or a black box
Β· the landscape is RUGGED with many local optima, where hill
climbing gets stuck
Β· a GOOD-ENOUGH answer is acceptable; GAs give no optimality
guarantee
Β· fitness is CHEAP TO EVALUATE relative to the number of
evaluations needed
Β· the problem is MULTI-OBJECTIVE β a population can maintain
a set of trade-off solutions (a PARETO FRONT), which
single-solution methods cannot
WHEN IT IS NOT:
Β· a gradient exists β then gradient descent is far faster,
which is why neural networks are trained by
backpropagation and not by evolution
Β· the problem has known structure a specialised algorithm
exploits β use the specialised algorithm
Β· fitness evaluation is EXPENSIVE. A GA may need tens of
thousands of evaluations, and if each is a ten-minute
simulation the budget is impossible.
Β· an exact optimum is required with proof
THE HONEST ASSESSMENT:
ADVANTAGES
Β· needs no derivative and no model of the objective
Β· escapes local optima better than hill climbing, because a
population explores several regions at once
Β· PARALLELISES trivially β every fitness evaluation is
independent
Β· applies to almost any problem for which an encoding and a
fitness function can be written
Β· handles multi-objective problems naturally
DISADVANTAGES
Β· NO GUARANTEE of optimality, and no way to know how close
you are
Β· MANY PARAMETERS to tune β population size, p_c, p_m,
selection method β and performance is sensitive to them
Β· computationally expensive in fitness evaluations
Β· PREMATURE CONVERGENCE if diversity is lost
Β· the encoding must be designed, and a poor encoding
defeats the method entirely
Β· results are STOCHASTIC β two runs give different answers,
so experiments must be repeated and averaged
A COMPARISON WITH THE SEARCH OF ACtE0902, to place it:
A* is COMPLETE and OPTIMAL with an admissible heuristic, and
needs a well-defined state space with actions and costs.
HILL CLIMBING is cheap and gets stuck in local optima.
SIMULATED ANNEALING escapes local optima by accepting worse
moves with a decreasing probability β a single-solution
method with a temperature schedule.
A GENETIC ALGORITHM keeps a POPULATION, so it explores
several basins at once and can RECOMBINE partial solutions
β which is the one thing none of the single-solution
methods can do.
THAT RECOMBINATION IS THE GA'S DISTINCTIVE CONTRIBUTION, and
whether it helps depends entirely on whether the problem's
good solutions are built from independently useful parts.
The expected-copies column is where selection pressure becomes concrete: the fittest individual gets 2.16 copies and the weakest 0.09, so the weak candidate is almost certainly gone next generation. That is what makes a GA work β and, without elitism or diversity maintenance, exactly what makes it converge prematurely on the first decent answer it finds.
π Go further: the multi-objective case is where GAs remain genuinely unmatched. NSGA-II maintains a population spread along the Pareto front β the set of solutions where improving one objective necessarily worsens another β so instead of one compromise answer you get the whole trade-off curve, and a human then chooses the point. That is exactly right for engineering decisions like cost versus weight versus reliability, where no scalar combination of the objectives is defensible in advance. A single-solution optimiser has to be told the weights first; a population-based one discovers the options. Search "NSGA-II Pareto front multi-objective optimisation".
π‘ Exam angle: give the GA vocabulary mapped from biology, and the algorithm as a loop of selection, crossover, mutation. The guaranteed numerical question is the f(x) = xΒ² example: build the fitness table, compute each individual's share and expected copies (fα΅’/fΜ), perform a single-point crossover at a stated position, and apply a bit-flip mutation, reporting the new fitnesses. Explain what each operator contributes β selection exploits, crossover recombines, mutation supplies new material. Know roulette-wheel, rank and tournament selection, why roulette wheel causes premature convergence, and why elitism is used. State that p_m β 1/L and p_c is 0.6β0.9. Be ready to say when a GA is appropriate β no gradient, rugged landscape, good-enough answer acceptable.
Syllabus points
Operators: selection, crossover, mutation
Encoding; selection algorithms
Fitness function; GA parameters
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.