Beruflich Dokumente
Kultur Dokumente
Evolutionary Algorithms:
Details, Encoding, Operators
This is lecture 3 of
`Biologically Inspired Computing’
Contents:
Steady state and generational EAs, basic ingredients,
example encodings / operators, and CW1
Recall that:
If we have a hard optimization problem, we can try using an Evolutionary
Algorithm (EA) to solve it. To start with we need:
a. An ‘encoding’, which is a way to represent any solution to
the problem in a computational form (e.g. it could be a string of
integers, a 2D array of real numbers, basically any datastructure …)
b. A fitness function f(s), which works out a ‘fitness’ value for
the solution encoded as ‘s’.
Once we have figured out a suitable encoding and fitness
function, we can run an EA, which generally looks like this:
0. Initialise: generate a fixed-size population P of random solutions, and evaluate
the fitness of each one.
1. Using a suitable selection method, select one or more from P to be the ‘parents’
2. Using suitable ‘genetic operators’, generate one or more children from the
parents, and evaluate each of them
3. Using a suitable ‘population update’ or ‘reproduction’ method, replace one or
more of the parents in P with some of the newly generated children.
4. If we are out of time, or have evolved a good enough solution, stop; otherwise
go to step 1.
note: one trip through steps 1,2,3 is called a generation
Some variations within this theme
Initialisation: Indeed we could generate ‘random’ solutions – however,
depending on the problem, there is often a simple way to generate ‘good’
solutions right from the start. Another approach, where your population size is
set to 100 (say) is to generate 10,000 (say) random solutions at the start, and
your first population is the best 100 of those.
Selection: lots of approaches (see mandatory additional material) – however it
turns out that a rather simple selection method called ‘binary tournament
selection’ tends to be as good as any other – see later slides.
Genetic Operators: Obviously, the details of these depends on the encoding. But
in general there is always a choice between ‘mutation’ (generate one or more
children from a single parent) and ‘recombination’ (generate one or more
children from two or more parents). Often both types are used in the same EA.
Population update: the extremes are called: ‘steady state’ (in every generation,
at most one new solution is added to the population, and one is removed) and
‘generational’ (in every generation, the entire population is replaced by
children). Steady state is commonly used, but generational is better for parallel
implementations.
Specific evolutionary algorithms
The algorithm whose pseudocode is on the
next slide is a steady state, replace-worst
EA with tournament selection, using
mutation, but no crossover.
Parameters are popsize, tournament size,
mutation-rate.
It can be applied to any problem; the details
glossed over are all problem-specific.
A steady state, mutation-only, replace-
worst EA with tournament selection
0. Initialise: generate a population of popsize random
solutions, evaluate their fitnesses.
0. Initialise population
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
1. Select
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
5 ?
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
4
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
4
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 1 3 2
14 5 5 6
4
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 4 3 2
14 5 5 6
Illustrating the ‘Steady-state etc …’ algorithm …
7 5 12 4
2 4 3 2
14 5 5 6
A generational, elitist,
crossover+mutation EA
with Rank-Based selection
0. Initialise: generate a population G of popsize
random solutions, evaluate their fitnesses.
Continued …
A generational, elitist, crossover+mutation EA
with Rank-Based selection, continued …
Vary:
1. With probability cross_rate, do a crossover:
I.e produce a child by applying a crossover
operator to the two parents. Otherwise, let the
child be a randomly chosen one of the parents.
2. Apply mutation to the child.
3. Return the mutated child.
Illustrating the ‘Generational etc …’ algorithm …\
0. Initialise population
Illustrating the ‘Generational etc …’ algorithm …\
7 5 12 4
2 1 3 2
14 5 5 6
Illustrating the ‘Generational etc …’ algorithm …
5 2
12 14
1. Select
14 14
7 5 12 4 7 1
6 14
5 12
2 1 3 2
7 3
14 12
14 5 5 6 7 14
12 12
6 14
Illustrating the ‘Generational etc …’ algorithm …
5 2 ?
2. Vary … 12 14 ?
14 14 ?
7 5 12 4 7 1 ?
6 14 ?
5 12 ?
2 1 3 2
7 3 ?
14 12 ?
14 5 5 6 7 14 ?
12 12 ?
6 14 ?
Illustrating the ‘Generational etc …’ algorithm …
5 2 6
3. Evaluate children … 12 14 15
14 14 11
7 5 12 4 7 1 6
6 14 16
5 12 8
2 1 3 2
7 3 9
14 12 8
14 5 5 6 7 14 16
12 12 12
6 14 13
Illustrating the ‘Generational etc …’ algorithm …
5 2 6
6 14 13
Illustrating the ‘Generational etc …’ algorithm …
6 15 11 6
16 8 9 8
14 16 12 13
Illustrating the ‘Generational etc …’ algorithm …
6. if not finished, go to …
6 15 11 6
16 8 9 8
14 16 12 13
Illustrating the ‘Generational etc …’ algorithm …
6 16
1. Select…and so on… 11 14
15 16
9 8
6 15 11 6
6 14
15 13
16 8 9 8
9 6
14 12
14 16 12 13
11 16
9 15
6 11
Steady State / Generational / Elitist
We have seen these two extremes:
Steady state: population only changes slightly in each generation. (e.g. select 1
parent, produce 1 child, add that child to pop and remove the worst)
1 2 4
3 5
And you have several `bins’ with a max capacity, say 50kg.
1 2 4
3 5
And you have several `bins’ with a max capacity, say 50kg.
5 4
1 2
3
bin1 bin2 bin3 bin4 etc …
bin1 and bin2 have 45kg -- so the 10kg item 3 needs a new bin
Example of an encoding (and associated operators)
Bin-Packing
Another packing
1 (30kg) 2 (25kg) 3 (10kg) 4 (20kg) 5 (15kg)
1 2 4
3 5
And you have several `bins’ with a max capacity, say 50kg.
4 5
3
1 2
The TSP
The Travelling Salesperson Problem
You have N ‘cities’, and an associated distance matrix. Find the shortest tour
through the cities. I.e., starting from one of the cities (‘A’, for example), what is the
quickest way to visit all of the other cities, and end up back at ‘A’ ?
Many many real problems are based on this (vehicle routing probs, bus or train
scheduling), or exactly this (drilling thousands
of holes in a metal plate, or … an actual traveling A B C D E
Salesperson problem!).
A 5 7 4 15
Map B B 5 3 4 10
C C 7 3 2 7
D 4 4 2 9
D E
A E 15 10 7 9
Example of an encoding (and associated operators)
B
C
D E
A
Example of an encoding (and associated operators)
One valid mutation operator would be random pair swap. E.g. choose two different
gene positions at random, and swap their contents.
B
C
Suppose we have solution CEABD
D E
A
Let’s randomly choose the 2nd and 4th genes
and swap them. B
C
We get CBAED, which is this solution:
D E
A
Example of an encoding (and associated operators)
These have much in common with EAs, but with no population – they just
use a single solution and keep trying to improve it.
EACH SLIDE MUST: (i) contain a URL to a paper, thesis or other source that describes this
application (ii) contain at least one graphic/figure (iii) simply and briefly explain key details of
the problem, the encoding, the fitness function, and the findings in the paper.
HOW MUCH I EXPECT FROM YOU: Use google scholar, or maybe just google, and use
sensible and creative search keywords. Don’t go overboard in the time you spend on this – e.g.
I did not read in detail the papers summarised in the previous 3 slides. I just tried to grab the
key ideas, and make up a slide that simply conveys the gist of them.
MSc and Meng 5th yr students: The first slide (or slide set) will get 0, 1, 2, 3 or
4 marks. The second slide (or slide set) will get 0, 1, 2, 3, 4, 5 or 6 marks.
When marking the second slide (or slide set) I will also take into account the
difference between the two applications
Marking will consider how well your slide text and graphics conveys the things I
am asking for, considering clarity, succinctness and correctness. When marking
the second slide (or slide set) I will also take into account the difference between
the two applications – e.g. you will lose up to two marks if both slidesets are about
the same optimization problem.
To hand in, please email each individual slide in a separate message, as follows:
– send it to dwcorne@gmail.com
– include the slide (either ppt or pdf) as an attachment
–put your (real) name and degree programme (e.g. BSc CS, MSc AI, whatevs) in the body of the email
–Make the subject line: “BIC CW1 Slides N”, where N is either 1, 2, or ‘2 and 3’