biologically inspired computation

54
Biologically Inspired Computation Really finishing off EC

Upload: fay

Post on 12-Jan-2016

25 views

Category:

Documents


1 download

DESCRIPTION

Biologically Inspired Computation. Really finishing off EC. But first:. Finishing off encodings Information about mandatory reading Information about CW2. E.g. encoding a timetable I. 4, 5, 13, 1, 1, 7, 13, 2. Exam2 in 5 th slot. Exam1 in 4 th slot. Etc …. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Biologically Inspired Computation

Biologically Inspired Computation

Really finishing off EC

Page 2: Biologically Inspired Computation

But first:

• Finishing off encodings

• Information about mandatory reading

• Information about CW2

Page 3: Biologically Inspired Computation

E.g. encoding a timetable I

4, 5, 13, 1, 1, 7, 13, 2

• Generate any string of 8 numbers between 1 and 16, and we have a timetable! • Fitness may be <clashes> + <consecs> + etc …• Figure out an encoding, and a fitness function, and you can try to evolve solutions.

mon tue wed thur

9:00 E4, E5

E2 E3, E7

11:00

E8

2:00 E6

4:00 E1

Exam1 in 4th slotExam2 in 5th slot

Etc …

Page 4: Biologically Inspired Computation

E.g. encoding a timetable II

4, 5, 13, 1, 1, 7, 13, 2

mon tue wed thur

9:00 E4, E5

E3, E7

11:00

E8

2:00 E6, E2

4:00 E1

Use the 4th clash-free slot for exam1Use the 5th clash-free slot for exam2 (clashes with E4,E8)

Use the 13th clash-free slot for exam3

Etc …

Page 5: Biologically Inspired Computation

So, a common approach is to build an encoding around an

algorithm that builds a solution

• Don’t encode a candidate solution directly

• … instead encode parameters/features for a constructive algorithm that builds a candidate solution

Page 6: Biologically Inspired Computation

e.g.: bin-packing – given collection of items, pack them into the fewest possible number of bins

Page 7: Biologically Inspired Computation

e.g.: bin-packing – given collection of items, pack them into the fewest possible number of bins

Page 8: Biologically Inspired Computation

Engineering Constructive Algorithms

A typical constructive algorithm for bin-packing:

Put the items in a specific sequence (e.g. smallest to largest)

Initialise solution

Repeat nitems times

choose next item, place it in first bin it fits (create a new empty bin if necessary)

Indirect Encodings often involve using a constructive algorithm,

Page 9: Biologically Inspired Computation

Example using ‘First-Fit Ascending’ (FFA) constructive algorithm for bin-packing

FFA

Page 10: Biologically Inspired Computation

First-fit Ascending

Page 11: Biologically Inspired Computation

First-fit Ascending

Page 12: Biologically Inspired Computation

First-fit Ascending

Page 13: Biologically Inspired Computation

First-fit Ascending

Page 14: Biologically Inspired Computation

First-fit Ascending

Page 15: Biologically Inspired Computation

First-fit Ascending

Page 16: Biologically Inspired Computation

Example using First-Fit Descending

First-fit Descending

Page 17: Biologically Inspired Computation

First-Fit Descending

Page 18: Biologically Inspired Computation

First-Fit Descending

Page 19: Biologically Inspired Computation

First-Fit Descending

Page 20: Biologically Inspired Computation

First-Fit Descending

Page 21: Biologically Inspired Computation

First-Fit Descending

Page 22: Biologically Inspired Computation

Notes:

• In other problems, FFA gets better results than FFD

• There are many other constructive heuristics for bin packing, e.g. Using formulae that choose next item based on distribution of unplaced item sizes and empty spaces ...

• There are constructive algorithms for most problems (e.g. Timetabling, scheduling, etc ....)

• Often, ‘indirect encodings’ for EAs use constructive algorithms.

• Common approach: the encoding is permutation, and the solution is built using the items in that order

• READ THE FALKENAUER PAPER TO SEE GOOD EA ENCODING FOR BIN-PACKING

Page 23: Biologically Inspired Computation

Encodings that use constructive algorithms

The indirect encoding for timetabling, a few slides ago, is an example.

The ‘underlying’ constructive algorithm is:

Line up the exams in order e1, e2, … eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the first place it can go without clashes

This provides only a single solution, the same every time we run it. This may be very bad in terms of other factors, such as consecutive exams, time allowed for marking, etc.

How did we modify it so that it could generate a big space of different solutions?

Page 24: Biologically Inspired Computation

Encodings that use constructive algorithms

Line up the exams in order e1, e2, … eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the first place it can go without clashes

Page 25: Biologically Inspired Computation

Encodings that use constructive algorithms

Line up the exams in order e1, e2, … eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the first place it can go without clashes

Page 26: Biologically Inspired Computation

Encodings that use constructive algorithms

Line up the exams in order e1, e2, … eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the Nth place it can go without clashes

The chromosome encodes each of the Ns. The original constructive algorithm corresponds to running the above on the chromosome “111111111….”.

We could also engineer the original constructive algorithm into an encoding in a quite different way. How?

Page 27: Biologically Inspired Computation

Encodings that use constructive algorithms

Line up the exams in order e1, e2, … eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the first place it can go without clashes

Page 28: Biologically Inspired Computation

Encodings that use constructive algorithms

Randomly permute the exams e1, …, eN

Repeat until all exams are scheduled:

take the next exam in the list, and put it in the first place it can go without clashes

This is a fine constructive algorithm, which will provide a different solution depending on the permutation.

It is easily used as an encoding: the chromosome provides the permutation.

Page 29: Biologically Inspired Computation

• Prim’s algorithm for building the minimal spanning tree (see an earlier lecture) is an example.

• Djikstra’s 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.

Other well known constructive algorithms

Page 30: Biologically Inspired Computation

On engineering 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.

Page 31: Biologically Inspired Computation

Bin packing example direct encoding:

2, 3, 2, 3, 1 .... item 1 is in bin 2, item 2 is in bin 3, item 3 is in bin 2, etc...

(often a bin will be over capacity, so fitness function will have to include penalties)

Bin packing example indirect encoding:

candidate solution is a perm of the items, e.g. 4, 2, 1, 3, 5 ...meaning:

First place item 4 in the first available bin it fits in, then place item 2 in the first available ... etc.

Page 32: Biologically Inspired Computation

Direct vs Indirect EncodingsDirect: • straightforward genotype (encoding) phenotype (actual solution)

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.

Page 33: Biologically Inspired Computation

Example real-number Encoding (and: How EAs can innovate, rather than

just optimize)D1, D2, D3, D4 D5 D6

D1 >= D2 >= D3, D4 <= D5 <= D6Fixed at six diameters, five sections

Design shape for a two-phase jet nozzle

Page 34: Biologically Inspired Computation

2, 1.8, 1.1, 1.3 1.3 1.5

The encoding enforces these constraints: D1 >= D2 >= D3, D4 <= D5 <= D6 Fixed at six diameters, five sections

A simple encoding

Page 35: Biologically Inspired Computation

Z1, Z2, D1, D2, D3 Dsmall…, Dn, Dn+1, …

Middle section constrained to be smallest,That’s all Mutations can change diameters, add sections,and delete sections

Num sections before smallest

Num sections after smallest

Section diameters

A more complex encoding– bigger search space, slower, but potential for innovative solutions

Page 36: Biologically Inspired Computation

Mandatory reading

slides for

- Operators (typical mutation and crossover operators for different types of encoding)

- Selection (various standard selection methods)

- More encodings

Page 37: Biologically Inspired Computation

About CW2

Page 38: Biologically Inspired Computation

About CW2

Page 39: Biologically Inspired Computation

About CW2Pamela Hardaker, Benjamin N. Passow and David Elizondo. Walking State

Detection from Electromyographic Signals towards the Control of Prosthetic Limbs UKCI 2013

got signals like this, but on her

thigh just above the knee:

standing walkingrunning

Page 40: Biologically Inspired Computation

Current knee-joint prospects need manual intervention to change between standing/walking/running modes (the wearer presses a button)

Can we train a Neural Network to automatically detect when to change, on the basis of nerve signals from the last 30ms ?

Page 41: Biologically Inspired Computation

About CW2Snapshot of Pamela’s data

Time signal state0:04.206 6.064453124 standing0:04.207 5.693359374 standing0:04.208 4.946289061 standing0:04.209 4.609374999 standing0:04.210 4.589843749 standing0:04.211 4.482421874 standing0:04.212 4.809570311 standing0:04.213 5.102539061 standing0:04.214 5.507812499 standing0:04.215 5.922851562 standing0:04.216 5.561523436 standing0:04.217 5.610351561 standing0:04.218 5.605468749 standing0:04.219 5.551757811 walking0:04.220 5.952148437 walking0:04.221 6.542968749 walking0:04.222 6.923828124 walking0:04.223 6.845703124 walking0:04.224 6.958007812 walking0:04.225 6.484374999 walking0:04.226 6.118164062 walking0:04.227 5.424804686 walking0:04.228 4.023437499 walking0:04.229 3.696289061 walking0:04.230 3.798828124 walking0:04.231 3.579101561 walking

Page 42: Biologically Inspired Computation

About CW2Snapshot of Pamela’s data

Time signal state0:04.206 6.064453124 standing0:04.207 5.693359374 standing0:04.208 4.946289061 standing0:04.209 4.609374999 standing0:04.210 4.589843749 standing0:04.211 4.482421874 standing0:04.212 4.809570311 standing0:04.213 5.102539061 standing0:04.214 5.507812499 standing0:04.215 5.922851562 standing0:04.216 5.561523436 standing0:04.217 5.610351561 standing0:04.218 5.605468749 standing0:04.219 5.551757811 walking0:04.220 5.952148437 walking0:04.221 6.542968749 walking0:04.222 6.923828124 walking0:04.223 6.845703124 walking0:04.224 6.958007812 walking0:04.225 6.484374999 walking0:04.226 6.118164062 walking0:04.227 5.424804686 walking0:04.228 4.023437499 walking0:04.229 3.696289061 walking0:04.230 3.798828124 walking0:04.231 3.579101561 walking

1.37207031 1.37207031 1.25488281 2.39746 2.39746 1.7041 0.44873 0.338135 0.674805 0 0 11.37207031 1.25488281 0.971679685 2.39746 1.7041 1.37207 0.355469 0.532471 0.390137 0 0 1

2.294921873 2.294921873 2.294921873 2.75391 2.75391 2.75391 0.51709 0.438232 0.486328 0 0 12.324218748 2.324218748 2.324218748 3.17383 3.17383 3.17383 0.482422 0.528564 0.570801 0 0 12.324218748 2.324218748 2.084960936 3.17383 3.17383 2.69043 0.507975 0.518799 0.466797 0 1 02.324218748 2.084960936 1.860351561 3.17383 2.69043 2.37793 0.484701 0.44165 0.416504 0 1 02.084960936 1.860351561 1.674804686 2.72949 2.50488 2.31934 0.328939 0.26001 0.103516 0 1 0

Max signal strength in last 30ms Max signal strength in last 20ms Max signal strength in last 10ms range of sig in last 30ms range … last 20ms range … last 10ms mean … last 30ms mean … last 20ms mean … last 10ms

Outputs: 1 0 0, 0 1 0 or 0 0 1 (standing) (waking) (running)

Page 43: Biologically Inspired Computation

About CW2Snapshot of Pamela’s data

Time signal state0:04.206 6.064453124 standing0:04.207 5.693359374 standing0:04.208 4.946289061 standing0:04.209 4.609374999 standing0:04.210 4.589843749 standing0:04.211 4.482421874 standing0:04.212 4.809570311 standing0:04.213 5.102539061 standing0:04.214 5.507812499 standing0:04.215 5.922851562 standing0:04.216 5.561523436 standing0:04.217 5.610351561 standing0:04.218 5.605468749 standing0:04.219 5.551757811 walking0:04.220 5.952148437 walking0:04.221 6.542968749 walking0:04.222 6.923828124 walking0:04.223 6.845703124 walking0:04.224 6.958007812 walking0:04.225 6.484374999 walking0:04.226 6.118164062 walking0:04.227 5.424804686 walking0:04.228 4.023437499 walking0:04.229 3.696289061 walking0:04.230 3.798828124 walking0:04.231 3.579101561 walking

Max signal strength in last 30ms Max signal strength in last 20ms Max signal strength in last 10ms range of sig in last 30ms range … last 20ms range … last 10ms mean … last 30ms mean … last 20ms mean … last 10ms

CW2: evolve a neural networkthat predicts the state.

1.37207031 1.37207031 1.25488281 2.39746 2.39746 1.7041 0.44873 0.338135 0.674805 0 0 11.37207031 1.25488281 0.971679685 2.39746 1.7041 1.37207 0.355469 0.532471 0.390137 0 0 1

2.294921873 2.294921873 2.294921873 2.75391 2.75391 2.75391 0.51709 0.438232 0.486328 0 0 12.324218748 2.324218748 2.324218748 3.17383 3.17383 3.17383 0.482422 0.528564 0.570801 0 0 12.324218748 2.324218748 2.084960936 3.17383 3.17383 2.69043 0.507975 0.518799 0.466797 0 1 02.324218748 2.084960936 1.860351561 3.17383 2.69043 2.37793 0.484701 0.44165 0.416504 0 1 02.084960936 1.860351561 1.674804686 2.72949 2.50488 2.31934 0.328939 0.26001 0.103516 0 1 0

Page 44: Biologically Inspired Computation

What you will do

From me, you get:

Working NN code that does the job already

What you will do:

Implement new mutation and crossover operators within my code, and test them on Pamela’s data

Write a report comparing the performance of the different operators

Page 45: Biologically Inspired Computation

If time, a look at the key bits of those operator slides …

Page 46: Biologically Inspired Computation

Operators for real-valued k-ary encodings

Here the chromosome is a string of k real numbers, which each may or may not have a fixed range (e.g. between −5 and 5).

e.g. 0.7, 2.8, −1.9, 1.1, 3.4, −4.0, −0.1, −5.0, …

All of the mutation operators for k-ary encodings, as previously described in these slides, can be used. But we need to be clear about what it means to randomly change a value. In the previous slides for k-ary mutation operators we assumed that a change to a gene mean to produce a random (new) value anywhere in the range of possible values …

Page 47: Biologically Inspired Computation

Operators for real-valued k-ary encodings

that’s fine … we can do that with a real encoding, but this means we are choosing the new value for a gene uniformly at random.

Page 48: Biologically Inspired Computation

Mutating a real-valued gene using a uniform distrution

Range of allowed values for gene: 0—10

New value can be anywhere in the range, with any number equally likely.

Page 49: Biologically Inspired Computation

But, in real-valued encodings, we usually use Gaussian (‘Normal’) distributions

… so that the new value is more likely than not to be close to the old value.

typically we generate a perturbation

from a Gaussian distribution, like this

one, and add that perturbation to the old

value.

0.3

0

0.2

Prob

abili

ty o

f ch

oosi

ng

this

per

turb

atio

n

−1 −0.5 0 0.5 1perturbation

0.1

Page 50: Biologically Inspired Computation

Mutation in real-valued encodings

Most common is to use the previously indicated mutation operators (e.g. single-gene, genewise) but with Gaussian perturbations rather than uniformly chosen new values.

Page 51: Biologically Inspired Computation

Crossover in real-valued encodings

All of the k-ary crossover operators previously described can be used.

But there are other common ones that are only feasible for real-valued encodings:

Page 52: Biologically Inspired Computation

Box and Line crossover operators for real-valued chromosomes – figure is from this paper:

Treat the parents like vectors

Fig assumes you are crossing over two 2-gene parents, x (x1,x2) and y (y1,y2)

Box: child is

(x1 + u1 (y1 – x1), x2 + u2(y2 – x2) )

Where u1 and u2 are uniform random numbers between 0 and 1

Line: child is: x + u (y – x)

or (x1+ u(y1 – x1) , x2 + u (y2 – x2) )

Where u is a random number between 0 and 1

http://cdn.intechopen.com/pdfs/30229/InTech-The_roles_of_crossover_and_mutation_in_real_coded_genetic_algorithms.pdf

Page 53: Biologically Inspired Computation

Box and Line crossover: general formParent1: x1, x2, x3, …., xN

Parent2: y1, y2, y3, …, yN

given parameter α (typically values are 0, 0.1 or 0.25)

General form:

Child is ((x1 – α) + u (y1 – x1), ((x2 – α) + u (y2 – x2), … etc)

Where: u is a uniform random number between 0 and 1+2α

Line crossover: α = 0 ; u is generated once for each crossover, and is the same for every gene.

Extended line crossover: α > 0, u is generated once for each crossover, and is the same for every gene.

Box crossover: α = 0 ; u is different for every gene

Extended box crossover: α > 0 ; u is different for every gene

Page 54: Biologically Inspired Computation