# Biologically Inspired Computing: Finishing off EC, and incorporating CW1 - PowerPoint PPT Presentation

Biologically Inspired Computing: Finishing off EC, and incorporating CW1

1 / 70
Biologically Inspired Computing: Finishing off EC, and incorporating CW1

## Biologically Inspired Computing: Finishing off EC, and incorporating CW1

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Biologically Inspired Computing: Finishing off EC, and incorporating CW1 This is lecture 5 of `Biologically Inspired Computing’ Contents: Steady state and generational EAs, basic ingredients, example run-throughs on the TSP, example encodings, hillclimbing, landscapes

2. Four topics • Hillclimbing and Local search (motivating EAs via problems with simpler methods, rather than via natural Evolution) • Landscapes • Neighbourhoods • Encodings

3. Simplest possible EA: Hillclimbing • 0. Initialise: Generate a random solution c; evaluate its • fitness, f(c). Call c the current solution. • 1. Mutate a copy of the current solution – call the mutant m • Evaluate fitness of m, f(m). • 2. If f(m) is no worsethan f(c), then replace c with m, • otherwise do nothing (effectively discarding m). • 3. If a termination condition has been reached, stop. • Otherwise, go to 1. Note. No population (well, population of 1). This is a very simple version of an EA, although it has been around for much longer.

4. Example on a 1D landscape FITNESS x - the ‘genotype’

5. Initial random point FITNESS x - the ‘genotype’

6. mutant FITNESS x - the ‘genotype’

7. Current solution (unchanged) FITNESS x - the ‘genotype’

8. Next mutant FITNESS x - the ‘genotype’

9. New current solution FITNESS x - the ‘genotype’

10. Next mutant FITNESS x - the ‘genotype’

11. New current solution FITNESS x - the ‘genotype’

12. ETC ………………………… FITNESS x - the ‘genotype’

13. How will HC do on this landscape?

14. Some other landscapes

15. Landscapes f(s) Recall S, the search space, and f(s), the fitness of a candidate in S members of S lined up along here The structure we get by imposing f(s) on S is called a landscape

16. Neighbourhoods f(s) Recall S, the search space, and f(s), the fitness of a candidate in S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Showing the neighbourhoods of two candidate solutions, assuming The mutation operator adds a random number between −1 and 1

17. Neighbourhoods f(s) Recall S, the search space, and f(s), the fitness of a candidate in S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Showing the neighbourhood of a candidate solutions, assuming The mutation operator adds a random integer between −2 and 2

18. Neighbourhoods f(s) Recall S, the search space, and f(s), the fitness of a candidate in S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Showing the neighbourhood of a candidate solutions, assuming the mutation operator simply changes the solution to a new random Number between 0 and 20

19. Neighbourhoods f(s) Recall S, the search space, and f(s), the fitness of a candidate in S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Showing the neighbourhood of a candidate solution, assuming the mutation operator adds a Gaussian (ish) with mean zero.

20. Neighbourhoods Let s be an individual in S, f(s) is our fitness function, and M is our mutation operator, so that M(s1)  s2, where s2 is a mutant of s1. Given M, we can usually work out the neighbourhood of an individual point s – the neighbourhood of s is the set of all possible mutants of s E.g. Encoding: permutations of k objects (e.g. for k-city TSP) Mutation: swap any adjacent pair of objects. Neighbourhood: Each individual has k neighbours. E.g. neighbours of EABDC are: {AEBDC, EBADC, EADBC, EABCD, CABDE} Encoding: binary strings of length L (e.g. for L-item bin-packing) Mutation: choose a bit randomly and flip it. Neighbourhood: Each individual has L neighbours. E.g. neighbours of 00110 are: {10110, 01110, 00010, 00100, 00111}

21. Landscape Topology Mutation operators lead to slight changes in the solution, which tend to lead to slight changes in fitness. Why are “big mutations” generally a bad idea to have in a search algorithm ??

22. Typical Landscapes f(s) members of S lined up along here Typically, with large (realistic) problems, the huge majority of the landscape has very poor fitness – there are tiny areas where the decent solutions lurk. So, big random changes are very likely to take us outside the nice areas.

23. Typical 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

24. Beyond 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’.

25. Local 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 solution;if 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.

26. Population-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 needn’t 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.

27. Encodings (aka representation) Direct vs Indirect

28. Encoding / 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.

29. E.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 <clashes> + <consecs> + etc … • Figure out an encoding, and a fitness function, and • you can try to evolve solutions.

30. Mutating a Timetable with Encoding 1 4, 5, 13, 1, 1, 7, 13, 2 Using straightforward single-gene mutation Choose a random gene

31. Mutating 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

32. Alternative 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?

33. E.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 (clashes with E4,E8) Use the 4th clash-free slot for exam1

34. 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 E2

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

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

37. 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,

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

39. First-fit Ascending

40. First-fit Ascending

41. First-fit Ascending

42. First-fit Ascending

43. First-fit Ascending

44. First-fit Ascending

45. Example using First-Fit Descending First-fit Descending

46. First-Fit Descending