Presentation is loading. Please wait.

Presentation is loading. Please wait.

Biologically Inspired Computing: Introduction to Evolutionary Algorithms This is lecture four of `Biologically Inspired Computing’ Contents: Local Search.

Similar presentations


Presentation on theme: "Biologically Inspired Computing: Introduction to Evolutionary Algorithms This is lecture four of `Biologically Inspired Computing’ Contents: Local Search."— Presentation transcript:

1 Biologically Inspired Computing: Introduction to Evolutionary Algorithms This is lecture four of `Biologically Inspired Computing’ Contents: Local Search Encodings

2 Typical Landscapes 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 Unimodal Plateau Multimodal Deceptive

3 Beyond Hillclimbing HC clearly has problems with typical landscapes: There are two broad ways to improve HC, from the algorithm viewpoint: 1.Allow downhill moves – a family of methods called Local Search does this in various ways. 2.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’.

4 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: 1.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.

5 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.

6 Basics of Encodings

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

8 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 + + etc … Figure out an encoding, and a fitness function, and you can try to evolve solutions. montuewedthur 9:00E4, E5 E2E3, E7 11:00E8 2:00E6 4:00E1 Exam1 in 4 th slot Exam2 in 5 th slot Etc …

9 Mutating a Timetable with Encoding 1 4, 5, 13, 1, 1, 7, 13, 2 montuewedthur 9:00E4, E5 E2E3, E7 11:00E8 2:00E6 4:00E1 Using straightforward single-gene mutation Choose a random gene

10 Mutating a Timetable with Encoding 1 4, 5, 6, 1, 1, 7, 13, 2 montuewedthur 9:00E4, E5 E2E7 11:00E8E3 2:00E6 4:00E1 Using straightforward single-gene mutation One mutation changes position of one exam

11 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?

12 E.g. encoding a timetable II 4, 5, 13, 1, 1, 7, 13, 2 montuewedthur 9:00E4, E5 E2E3, E7 11:00E8 2:00E6 4:00E1 Use the 4 th clash-free slot for exam1 Use the 5 th clash-free slot for exam2 Use the 13 th clash-free slot for exam3 Etc …

13 E.g. encoding a timetable III H1, H3, H2, H2, H1, H1 … montuewedthur 9:00E4, E5 E2E3, E7 11:00E8 2:00E6 4:00E1 Use heuristic H1 to schedule exam1 (first fit) Use heuristic H3 to schedule exam2 (best fit based on consecs) Use heuristic H2 to schedule exam3 (reduce future conflicts) Etc …

14 One 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 don’t yet understand.

15 A Real Encoding (and: How EAs can innovate, rather than just optimize) D1, D2, D3, D4 D5 D6 D1 >= D2 >= D3, D4 <= D5 <= D6 Fixed at six diameters, five sections

16 E.g. How EAs can innovate, rather than just optimize 2, 1.8, 1.1, 1.3 1.3 1.5 D1 >= D2 >= D3, D4 <= D5 <= D6 Fixed at six diameters, five sections

17 E.g. How EAs can innovate, rather than just optimize 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

18 Constructive 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.

19 Examples 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.

20 A 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?

21 A 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?

22 A (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.

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

24 Think about these things How could you design a `smart’ mutation operator for the direct timetable encoding? (hint – when you’ve 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)

25 Direct 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.

26 Back 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?

27 An 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?

28 This week’s additional material Further encodings: Grouping problems, Rules, Trees.


Download ppt "Biologically Inspired Computing: Introduction to Evolutionary Algorithms This is lecture four of `Biologically Inspired Computing’ Contents: Local Search."

Similar presentations


Ads by Google