Title: Biologically Inspired Computing: Introduction to Evolutionary Algorithms
1Biologically Inspired Computing Introduction
to Evolutionary Algorithms
- This is lecture four of
- Biologically Inspired Computing
- Contents
- Local Search
- Encodings
2Typical Landscapes
Plateau
Unimodal
Multimodal
Deceptive
As we home in on the good areas, we can identify
broad types of Landscape feature. Most
landscapes of interest are predominantly
multimodal. Despite being locally smooth, they
are globally rugged
3Beyond Hillclimbing
-
- HC clearly has problems with typical landscapes
- There are two broad ways to improve HC, from the
algorithm viewpoint - Allow downhill moves a family of methods called
Local Search does this in various ways. - Have a population so that different regions can
be explored inherently in parallel I.e. we keep
poor solutions around and give them a chance to
develop.
4Local Search
- Initialise Generate a random solution c
evaluate its - fitness, f(s) b call c the
current solution, - and call b the best so far.
- Repeat until termination conditon reached
- Search the neighbourhood of c, and choose one, m
- Evaluate fitness of m, call that x.
- 2. According to some policy, maybe replace c with
x, and - update c and b as appropriate.
E.g. Monte Carlo search 1. same as
hillclimbing 2. If x is better, accept it as
new current solutionif x is worse, accept it
with some probabilty (e.g. 0.1).
E.g. tabu search 1. evaluate all immediate
neighbours of c 2. choose the best from (1)
to be the next current solution, unless it
is tabu (recently visited), in which choose the
next best, etc.
5Population-Based Search
- Local search is fine, but tends to get stuck in
local optima, less so than HC, but it still gets
stuck. - In PBS, we no longer have a single current
solution, we now have a population of them. This
leads directly to the two main algorithmic
differences between PBS and LS - Which of the set of current solutions do we
mutate? We need a selection method - With more than one solution available, we
neednt just mutate, we can mate, recombine,
crossover, etc two or more current solutions. - So this is an alternative route towards
motivating our nature-inspired EAs and also
starts to explain why they turn out to be so
good.
6 7Encoding / Representation
- Maybe the main issue in (applying) EC
- Note that
- Given an optimisation problem to solve, we need
to find a way of encoding candidate solutions - There can be many very different encodings for
the same problem - Each way affects the shape of the landscape and
the choice of best strategy for climbing that
landscape.
8E.g. encoding a timetable I
4, 5, 13, 1, 1, 7, 13, 2
Exam2 in 5th slot
Exam1 in 4th slot
Etc
- Generate any string of 8 numbers between 1 and
16, - and we have a timetable!
- Fitness may be ltclashesgt ltconsecsgt etc
- Figure out an encoding, and a fitness function,
and - you can try to evolve solutions.
9Mutating a Timetable with Encoding 1
4, 5, 13, 1, 1, 7, 13, 2
Using straightforward single-gene mutation
Choose a random gene
10Mutating a Timetable with Encoding 1
4, 5, 6 , 1, 1, 7, 13, 2
Using straightforward single-gene mutation
One mutation changes position of one exam
11Alternative ways to do it
- This is called a direct encoding. Note that
- A random timetable is likely to have lots of
clashes. - The EA is likely (?) to spend most of its time
crawling through clash-ridden areas of the search
space. - Is there a better way?
12E.g. encoding a timetable II
4, 5, 13, 1, 1, 7, 13, 2
Etc
Use the 13th clash-free slot for exam3
Use the 5th clash-free slot for exam2
Use the 4th clash-free slot for exam1
13E.g. encoding a timetable III
H1, H3, H2, H2, H1, H1
Etc
Use heuristic H2 to schedule exam3 (reduce future
conflicts)
Use heuristic H3 to schedule exam2 (best fit
based on consecs)
Use heuristic H1 to schedule exam1 (first fit)
14One of the very first applications. Determine
the internal shape of a two-phase jet nozzle that
can achieve the maximum possible thrust under
given starting conditions
Ingo Rechenberg was the very first, with
pipe-bend design This is slightly later work in
the same lab, by Schwefel
Starting point
EA (ES) running
Result
A recurring theme design freedom ? entirely new
and better designs based on principles we dont
yet understand.
15A Real Encoding (and How EAs can innovate,
rather than just optimize)
D1, D2, D3, D4 D5 D6
D1 gt D2 gt D3, D4 lt D5 lt D6 Fixed at six
diameters, five sections
16E.g. How EAs can innovate, rather than just
optimize
2, 1.8, 1.1, 1.3 1.3 1.5
D1 gt D2 gt D3, D4 lt D5 lt D6 Fixed at six
diameters, five sections
17E.g. How EAs can innovate, rather than just
optimize
Num sections before smallest
Section diameters
Z1, Z2, D1, D2, D3 Dsmall, Dn, Dn1,
Num sections after smallest
Middle section constrained to be smallest, Thats
all Mutations can change diameters, add
sections, and delete sections
18Constructive Methods
- Problems like timetabling, scheduling, and other
logistics activities are often solved in
practice via constructive heuristics, These are
also called greedy heuristics. A constructive
method is a technique that builds a single
solution step by step, trying to be clever
(often) about each step.
19Examples
- Prims algorithm for building the minimal
spanning tree (see an earlier lecture) is an
example. - Djikstras shortest path algorithm is also an
example. - In both of these cases, the optimal solution is
guaranteed to be found, since MST and SP are easy
problems. - But usually we see constructive methods used to
give very fast OK solutions to hard problems.
20A constructive method for the TSP
- Start with a random current city c mark c as
visited - Initialise Tour (empty)
- Repeat ncities-1 times
- choose, BTR, the closest unvisited city to c
- (call it d)
- add the edge c?d to Tour
- mark d as visited
- Let d be the current city
-
- Try it yourself a few times. Can you construct
examples where this will give a very poor result?
-
21A constructive method for exam timetabling
- Repeat nexams times
- choose an exam, e, randomly.
- let V be the set of valid timeslots for e
I.e. - slots it can go in without introducing a
clash. - If V is empty, mark e as unplaced
- Else choose random slot t from V, and assign
e to t. -
- Is this how people do timetabling, or is there an
even better way? -
22A (usually) better constructive method for exam
timetabling
- Assign a difficulty score to each exam e.g.
this could be the number of other exams with
which it clashes. - Repeat nexams times
- choose an unscheduled exam e with highest
difficulty,BTR. - Find V, the set of slots it can go in without
introducing a clash. - If V is empty, mark e as unplaced
- Else for each slot in V, find its usability
score e.g. the number of unplaced exams that
could go in that slot without introducing a clash - Choose a slot t with minimal usability score.
- Assign e to t.
-
23Back to encoding
- We can use constructive methods as encodings in
the following sort of way this is sometimes
called a hybrid approach. - The EA searches through the space of orderings of
items (e.g. exams to schedule, edges to put in a
graph, etc). - When evaluating fitness, a constructive method
builds a solution using the ordering provided in
the chromosome, and then evaluates fitness in the
normal way.
24Think about these things
- How could you design a smart mutation operator
for the direct timetable encoding? - (hint when youve randomly chosen a gene to
mutate, can you do better than give it a random
new slot?) - How could you design a smart mutation operator
for the indirect timetable encoding? - (hint hard)
25Direct vs Indirect Encodings
- Direct
- straightforward genotype (encoding) ? phenotype
(individual) mapping - Easy to estimate effects of mutation
- Fast interpretation of chromosome (hence speedier
fitness evlaluation) - Indirect/Hybrid
- Easier to exploit domain knowledge (e.g. use
this in the constructive heuristic) - Hence, possible to encode away undesirable
features - Hence, can seriously cut down the size of the
search space - But, slow interpretation
- Neighbourhoods are highly rugged.
26Back to Bin-Packing
- The bin-packing encoding that you will use in
your assignment is a direct one. - But there are some well-known constructive
heuristics for bin-packing the following ones
are used when the bins have fixed capaities, and
the problem is to pack the items into the
smallest number of bins - First-fit-random (FFR)
- Repeat nitems times
- Choose an item i randomly and place it in
the - first bin in which it will fit.
- First-fit-descending (FFD)
- Order the items from heaviest to lightest
(BTR) - For each item in order place it into the
first - bin in which it will fit.
- How might you invent an indirect encoding for
bin-packing?
27An important aside about constructive methods
- Some Constructive Heuristics are deterministic.
I.e. they give the same answer each time. - Some are stochastic I.e. they may give a
different solution in different runs. - Usually, if we have a deterministic constructive
method such as FFD, we can engineer a stochastic
version of it. E.g. instead of choosing the
next-lightest item in each step, we might choose
randomly between the lightest three unplaced
items. - When applying EAs, it is often found that a
stochastic constructive heuristic is very useful
for building an initial population. But care has
to be taken with such an approach why?
28This weeks additional material
- Further encodings
- Grouping problems, Rules, Trees.