2. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
GA Quick Overview
ïŹ
ïŹ
ïŹ
Developed: USA in the 1970âs
Early names: J. Holland, K. DeJong, D. Goldberg
Typically applied to:
â
ïŹ
Attributed features:
â
â
ïŹ
discrete optimization
not too fast
good heuristic for combinatorial problems
Special Features:
â
â
Traditionally emphasizes combining information from good
parents (crossover)
many variants, e.g., reproduction models, operators
3. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Genetic algorithms
ïŹ Hollandâs
original GA is now known as the
simple genetic algorithm (SGA)
ïŹ Other GAs use different:
â
â
â
â
Representations
Mutations
Crossovers
Selection mechanisms
4. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
SGA technical summary tableau
Representation
Binary strings
Recombination
N-point or uniform
Mutation
Bitwise bit-flipping with fixed
probability
Parent selection
Fitness-Proportionate
Survivor selection
All children replace parents
Speciality
Emphasis on crossover
5. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Representation
Phenotype space
Genotype space =
{0,1}L
Encoding
(representation)
10010001
10010010
010001001
011101001
Decoding
(inverse representation)
6. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
SGA reproduction cycle
1. Select parents for the mating pool
(size of mating pool = population size)
2. Shuffle the mating pool
3. For each consecutive pair apply crossover with
probability pc , otherwise copy parents
4. For each offspring apply mutation (bit-flip with
probability pm independently for each bit)
5. Replace the whole population with the resulting
offspring
7. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
SGA operators: 1-point crossover
ïŹ
ïŹ
ïŹ
ïŹ
Choose a random point on the two parents
Split parents at this crossover point
Create children by exchanging tails
Pc typically in range (0.6, 0.9)
8. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
SGA operators: mutation
ïŹ
ïŹ
Alter each gene independently with a probability pm
pm is called the mutation rate
â
Typically between 1/pop_size and 1/ chromosome_length
9. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
SGA operators: Selection
ïŹ
Main idea: better individuals get higher chance
â Chances proportional to fitness
â Implementation: roulette wheel technique
ïŹ Assign to each individual a part of the
roulette wheel
ïŹ Spin the wheel n times to select n
individuals
1/6 = 17%
A
3/6 = 50%
B
C
2/6 = 33%
fitness(A) = 3
fitness(B) = 1
fitness(C) = 2
10. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
An example after Goldberg â89 (1)
ïŹ Simple
problem: max x2 over {0,1,âŠ,31}
ïŹ GA approach:
â
â
â
â
â
Representation: binary code, e.g. 01101 â 13
Population size: 4
1-point xover, bitwise mutation
Roulette wheel selection
Random initialisation
ïŹ We
show one generational cycle done by hand
11. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
x2 example: selection
12. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
X2 example: crossover
13. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
X2 example: mutation
14. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
The simple GA
ïŹ Has
â
been subject of many (early) studies
still often used as benchmark for novel GAs
ïŹ Shows
â
â
â
â
many shortcomings, e.g.
Representation is too restrictive
Mutation & crossovers only applicable for bit-string &
integer representations
Selection mechanism sensitive for converging
populations with close fitness values
Generational population model (step 5 in SGA repr.
cycle) can be improved with explicit survivor selection
15. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Alternative Crossover Operators
ïŹ
Performance with 1 Point Crossover depends on the
order that variables occur in the representation
â
more likely to keep together genes that are near
each other
â
Can never keep together genes from opposite ends
of string
â
This is known as Positional Bias
â
Can be exploited if we know about the structure of
our problem, but this is not usually the case
16. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
n-point crossover
ïŹ
ïŹ
ïŹ
ïŹ
Choose n random crossover points
Split along those points
Glue parts, alternating between parents
Generalisation of 1 point (still some positional bias)
17. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Uniform crossover
ïŹ
ïŹ
ïŹ
ïŹ
Assign 'heads' to one parent, 'tails' to the other
Flip a coin for each gene of the first child
Make an inverse copy of the gene for the second child
Inheritance is independent of position
18. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Crossover OR mutation?
ïŹ
Decade long debate: which one is better / necessary /
main-background
ïŹ
Answer (at least, rather wide agreement):
â
â
â
â
it depends on the problem, but
in general, it is good to have both
both have another role
mutation-only-EA is possible, xover-only-EA would not work
19. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Crossover OR mutation? (contâd)
Exploration: Discovering promising areas in the search
space, i.e. gaining information on the problem
Exploitation: Optimising within a promising area, i.e. using
information
There is co-operation AND competition between them
ïŹ
Crossover is explorative, it makes a big jump to an area
somewhere âin betweenâ two (parent) areas
ïŹ
Mutation is exploitative, it creates random small
diversions, thereby staying near (in the area of ) the parent
20. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Crossover OR mutation? (contâd)
ïŹ
Only crossover can combine information from two
parents
ïŹ
Only mutation can introduce new information (alleles)
ïŹ
Crossover does not change the allele frequencies of
the population (thought experiment: 50% 0âs on first
bit in the population, ?% after performing n
crossovers)
ïŹ
To hit the optimum you often need a âluckyâ mutation
21. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Other representations
ïŹ
Gray coding of integers (still binary chromosomes)
â
Gray coding is a mapping that means that small changes in
the genotype cause small changes in the phenotype (unlike
binary coding). âSmootherâ genotype-phenotype mapping
makes life easier for the GA
Nowadays it is generally accepted that it is better to
encode numerical variables directly as
ïŹ
Integers
ïŹ
Floating point variables
22. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Integer representations
ïŹ
ïŹ
ïŹ
ïŹ
Some problems naturally have integer variables, e.g.
image processing parameters
Others take categorical values from a fixed set e.g.
{blue, green, yellow, pink}
N-point / uniform crossover operators work
Extend bit-flipping mutation to make
â
â
â
âcreepâ i.e. more likely to move to similar value
Random choice (esp. categorical variables)
For ordinal problems, it is hard to know correct range for
creep, so often use two mutation operators in tandem
23. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Real valued problems
ïŹ
ïŹ
Many problems occur as real valued problems, e.g.
continuous parameter optimisation f : â n ï â
Illustration: Ackleyâs function (often used in EC)
24. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Mapping real values on bit strings
z â [x,y] â â represented by {a1,âŠ,aL} â {0,1}L
âą
â
ïŹ
ïŹ
ïŹ
[x,y] â {0,1}L must be invertible (one phenotype per
genotype)
Î: {0,1}L â [x,y] defines the representation
y â x Lâ1
Î( a1 ,..., aL ) = x + L
â ( â aLâ j â 2 j ) â [ x, y ]
2 â 1 j =0
Only 2L values out of infinite are represented
L determines possible maximum precision of solution
High precision ï long chromosomes (slow evolution)
25. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Floating point mutations 1
General scheme of floating point mutations
âČ
x = x1 , ..., xl â x âČ = x1 , ..., xlâČ
xi , xiâČ â [ LBi ,UBi ]
ïŹ Uniform
mutation:
xiâČ drawn randomly (uniform) from [ LBi ,UBi ]
ïŹ
Analogous to bit-flipping (binary) or random resetting
(integers)
26. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Floating point mutations 2
ïŹ Non-uniform
â
â
â
â
mutations:
Many methods proposed,such as time-varying
range of change etc.
Most schemes are probabilistic but usually only
make a small change to value
Most common method is to add random deviate to
each variable separately, taken from N(0, Ï)
Gaussian distribution and then curtail to range
Standard deviation Ï controls amount of change
(2/3 of deviations will lie in range (- Ï to + Ï)
27. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Crossover operators for real valued GAs
ïŹ Discrete:
â
â
each allele value in offspring z comes from one of its
parents (x,y) with equal probability: zi = xi or yi
Could use n-point or uniform
ïŹ Intermediate
â
exploits idea of creating children âbetweenâ parents
(hence a.k.a. arithmetic recombination)
â
zi = α xi + (1 - α) yi where α : 0 †α †1.
The parameter α can be:
â
âą
âą
âą
constant: uniform arithmetical crossover
variable (e.g. depend on the age of the population)
picked at random every time
31. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Permutation Representations
ïŹ
ïŹ
Ordering/sequencing problems form a special type
Task is (or can be solved by) arranging some objects in
a certain order
â
â
ïŹ
Example: sort algorithm: important thing is which elements
occur before others (order)
Example: Travelling Salesman Problem (TSP) : important thing
is which elements occur next to each other (adjacency)
These problems are generally expressed as a
permutation:
â
if there are n variables then the representation is as a list of n
integers, each of which occurs exactly once
32. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Permutation representation: TSP example
ïŹ
ïŹ
ïŹ
Problem:
âą Given n cities
âą Find a complete tour with
minimal length
Encoding:
⹠Label the cities 1, 2, ⊠, n
âą One complete tour is one
permutation (e.g. for n =4
[1,2,3,4], [3,4,2,1] are OK)
Search space is BIG:
for 30 cities there are 30! â 1032
possible tours
33. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Mutation operators for permutations
ïŹ Normal
mutation operators lead to inadmissible
solutions
â
â
e.g. bit-wise mutation : let gene i have value j
changing to some other value k would mean that k
occurred twice and j no longer occurred
ïŹ Therefore
must change at least two values
ïŹ Mutation parameter now reflects the probability
that some operator is applied once to the
whole string, rather than individually in each
position
34. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Insert Mutation for permutations
ïŹ Pick
two allele values at random
ïŹ Move the second to follow the first, shifting the
rest along to accommodate
ïŹ Note that this preserves most of the order and
the adjacency information
35. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Swap mutation for permutations
ïŹ Pick
two alleles at random and swap their
positions
ïŹ Preserves most of adjacency information (4
links broken), disrupts order more
36. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Inversion mutation for permutations
ïŹ Pick
two alleles at random and then invert the
substring between them.
ïŹ Preserves most adjacency information (only
breaks two links) but disruptive of order
information
37. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Scramble mutation for permutations
ïŹ Pick
a subset of genes at random
ïŹ Randomly rearrange the alleles in those
positions
(note subset does not have to be contiguous)
38. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Crossover operators for permutations
ïŹ
âNormalâ crossover operators will often lead to
inadmissible solutions
12345
54321
ïŹ Many
12321
54345
specialised operators have been devised
which focus on combining order or adjacency
information from the two parents
39. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Order 1 crossover
ïŹ
ïŹ
Idea is to preserve relative order that elements occur
Informal procedure:
1. Choose an arbitrary part from the first parent
2. Copy this part to the first child
3. Copy the numbers that are not in the first part, to
the first child:
ïŹstarting right from cut point of the copied part,
ïŹusing the order of the second parent
ïŹand wrapping around at the end
4. Analogous for the second child, with parent roles
reversed
40. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Order 1 crossover example
ïŹ
Copy randomly selected set from first parent
ïŹ
Copy rest from second parent in order 1,9,3,8,2
41. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Partially Mapped Crossover (PMX)
Informal procedure for parents P1 and P2:
1.
Choose random segment and copy it from P1
2.
Starting from the first crossover point look for elements in that
segment of P2 that have not been copied
3.
For each of these i look in the offspring to see what element j has
been copied in its place from P1
4.
Place i into the position occupied j in P2, since we know that we will
not be putting j there (as is already in offspring)
5.
If the place occupied by j in P2 has already been filled in the
offspring k, put i in the position occupied by k in P2
6.
Having dealt with the elements from the crossover segment, the
rest of the offspring can be filled from P2.
Second child is created analogously
42. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
PMX example
ïŹ
Step 1
ïŹ
Step 2
ïŹ
Step 3
43. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Cycle crossover
Basic idea:
Each allele comes from one parent together with its position.
Informal procedure:
1. Make a cycle of alleles from P1 in the following way.
(a) Start with the first allele of P1.
(b) Look at the allele at the same position in P2.
(c) Go to the position with the same allele in P1.
(d) Add this allele to the cycle.
(e) Repeat step b through d until you arrive at the first allele of P1.
2. Put the alleles of the cycle in the first child on the positions
they have in the first parent.
3. Take next cycle from second parent
44. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Cycle crossover example
ïŹ
Step 1: identify cycles
ïŹ
Step 2: copy alternate cycles into offspring
45. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Edge Recombination
ïŹ Works
by constructing a table listing which
edges are present in the two parents, if an
edge is common to both, mark with a +
ïŹ e.g. [1 2 3 4 5 6 7 8 9] and [9 3 7 8 2 6 5 1 4]
46. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Edge Recombination 2
Informal procedure once edge table is constructed
1. Pick an initial element at random and put it in the offspring
2. Set the variable current element = entry
3. Remove all references to current element from the table
4. Examine list for current element:
â
â
â
If there is a common edge, pick that to be next element
Otherwise pick the entry in the list which itself has the shortest list
Ties are split at random
5. In the case of reaching an empty list:
â
â
Examine the other end of the offspring is for extension
Otherwise a new element is chosen at random
47. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Edge Recombination example
48. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Multiparent recombination
ïŹ
ïŹ
ïŹ
ïŹ
Recall that we are not constricted by the practicalities
of nature
Noting that mutation uses 1 parent, and âtraditionalâ
crossover 2, the extension to a>2 is natural to examine
Been around since 1960s, still rare but studies indicate
useful
Three main types:
â
â
â
Based on allele frequencies, e.g., p-sexual voting generalising
uniform crossover
Based on segmentation and recombination of the parents, e.g.,
diagonal crossover generalising n-point crossover
Based on numerical operations on real-valued alleles, e.g.,
center of mass crossover, generalising arithmetic
recombination operators
49. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Population Models
ïŹ SGA
â
â
uses a Generational model:
each individual survives for exactly one generation
the entire set of parents is replaced by the offspring
ïŹ At
the other end of the scale are Steady-State
models:
â
â
one offspring is generated per generation,
one member of population replaced,
ïŹ Generation
â
â
Gap
the proportion of the population replaced
1.0 for GGA, 1/pop_size for SSGA
50. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Fitness Based Competition
ïŹ Selection
â
â
Selection from current generation to take part in
mating (parent selection)
Selection from parents + offspring to go into next
generation (survivor selection)
ïŹ Selection
â
can occur in two places:
operators work on whole individual
i.e. they are representation-independent
ïŹ Distinction
â
â
between selection
operators: define selection probabilities
algorithms: define how probabilities are implemented
53. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Function transposition for FPS
54. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Rank â Based Selection
ïŹ Attempt
to remove problems of FPS by basing
selection probabilities on relative rather than
absolute fitness
ïŹ Rank population according to fitness and then
base selection probabilities on rank where
fittest has rank ” and worst rank 1
ïŹ This imposes a sorting overhead on the
algorithm, but this is usually negligible
compared to the fitness evaluation time
55. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Linear Ranking
ïŹ
ïŹ
Parameterised by factor s: 1.0 < s †2.0
â measures advantage of best individual
â in GGA this is the number of children allotted to it
Simple 3 member example
56. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Exponential Ranking
ïŹ Linear
Ranking is limited to selection pressure
ïŹ Exponential Ranking can allocate more than 2
copies to fittest individual
ïŹ Normalise constant factor c according to
population size
57. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Tournament Selection
ïŹ All
methods above rely on global population
statistics
â
â
ïŹ
Could be a bottleneck esp. on parallel machines
Relies on presence of external fitness function
which might not exist: e.g. evolving game players
Informal Procedure:
â
â
Pick k members at random then select the best of
these
Repeat to select more individuals
58. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Tournament Selection 2
ïŹ Probability
â
â
Rank of i
Size of sample k
ïŹ
â
higher k increases selection pressure
Whether contestants are picked with replacement
ïŹ Picking
â
ïŹ
of selecting i will depend on:
without replacement increases selection pressure
Whether fittest contestant always wins
(deterministic) or this happens with probability p
For k = 2, time for fittest individual to take over
population is the same as linear ranking with s = 2 âą p
59. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Survivor Selection
ïŹ Most
of methods above used for parent
selection
ïŹ Survivor selection can be divided into two
approaches:
â
Age-Based Selection
ïŹ e.g.
SGA
ïŹ In SSGA can implement as âdelete-randomâ (not
recommended) or as first-in-first-out (a.k.a. delete-oldest)
â
Fitness-Based Selection
ïŹ Using
one of the methods above or
60. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Two Special Cases
ïŹ Elitism
â
â
Widely used in both population models (GGA,
SSGA)
Always keep at least one copy of the fittest solution
so far
ïŹ GENITOR:
â
â
a.k.a. âdelete-worstâ
From Whitleyâs original Steady-State algorithm (he
also used linear ranking for parent selection)
Rapid takeover : use with large populations or âno
duplicatesâ policy
61. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Example application of order based GAs: JSSP
Precedence constrained job shop scheduling problem
ïŹ
ïŹ
ïŹ
ïŹ
ïŹ
ïŹ
J is a set of jobs.
O is a set of operations
M is a set of machines
Able â O Ă M defines which machines can perform which
operations
Pre â O Ă O defines which operation should precede which
Dur : â O Ă M â IR defines the duration of o â O on m â M
The goal is now to find a schedule that is:
ïŹ Complete: all jobs are scheduled
ïŹ Correct: all conditions defined by Able and Pre are satisfied
ïŹ Optimal: the total duration of the schedule is minimal
62. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
Precedence constrained job shop scheduling GA
ïŹ
ïŹ
Representation: individuals are permutations of operations
Permutations are decoded to schedules by a decoding procedure
â
â
â
take the first (next) operation from the individual
look up its machine (here we assume there is only one)
assign the earliest possible starting time on this machine, subject to
ïŹ
ïŹ
ïŹ
ïŹ
ïŹ
ïŹ
ïŹ
machine occupation
precedence relations holding for this operation in the schedule created so far
fitness of a permutation is the duration of the corresponding
schedule (to be minimized)
use any suitable mutation and crossover
use roulette wheel parent selection on inverse fitness
Generational GA model for survivor selection
use random initialisation
63. A.E. Eiben and J.E. Smith, Introduction to Evolutionary Computing
Genetic Algorithms
JSSP example: operator comparison