Presentation is loading. Please wait.

Presentation is loading. Please wait.

© J. Christopher Beck 20081 Lecture 16: Local Search.

Similar presentations


Presentation on theme: "© J. Christopher Beck 20081 Lecture 16: Local Search."— Presentation transcript:

1 © J. Christopher Beck 20081 Lecture 16: Local Search

2 © J. Christopher Beck 2008 2 Outline Local Search on Crystal Maze Core Ideas Local Search for Scheduling

3 © J. Christopher Beck 2008 3 Readings P Ch C.5

4 © J. Christopher Beck 2008 4 And now for something completely different … Local search is quite a different set of ideas from tree search Be prepared to “think different(ly)”

5 © J. Christopher Beck 2008 5 Crystal Maze Place the numbers 1 through 8 in the nodes such that: Each number appears exactly once ? ? ? ? ? ? ?? –No connected nodes have consecutive numbers

6 © J. Christopher Beck 2008 6 Local Search Idea Randomly assign values (even if the constraints are “broken”) Initial state will probably be infeasible Make “moves” to try to move toward a solution

7 © J. Christopher Beck 2008 7 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

8 © J. Christopher Beck 2008 8 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8 “Broken” constraint Cost = # of broken constraints

9 © J. Christopher Beck 2008 9 What Should We Do Now? Move: Swap two numbers Which two numbers? Randomly pick a pair The pair that will lead to the biggest decrease in cost Cost: number of broken constraints

10 © J. Christopher Beck 2008 10 What Should We Do Now? Move: Swap two numbers Which two numbers? Randomly pick a pair The pair that will lead to the biggest decrease in cost Cost: number of broken constraints

11 © J. Christopher Beck 2008 11 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

12 © J. Christopher Beck 2008 12 Cost Difference Table 12345678 10 20 30 40 50 60 70 80

13 © J. Christopher Beck 2008 13 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

14 © J. Christopher Beck 2008 14 Swap 1 & 2 ? ? ? ? ? ? ?? 2 4 3 15 6 7 8

15 © J. Christopher Beck 2008 15 Cost Difference Table 12345678 100 20 30 40 50 60 70 80

16 © J. Christopher Beck 2008 16 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

17 © J. Christopher Beck 2008 17 Swap 1 & 3 ? ? ? ? ? ? ?? 3 4 1 25 6 7 8

18 © J. Christopher Beck 2008 18 Cost Difference Table 12345678 1000 20 30 40 50 60 70 80

19 © J. Christopher Beck 2008 19 Random Initial Solution ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

20 © J. Christopher Beck 2008 20 Swap 1 & 4 ? ? ? ? ? ? ?? 4 1 3 25 6 7 8

21 © J. Christopher Beck 2008 21 Cost Difference Table 12345678 1000 20 30 40 50 60 70 80

22 © J. Christopher Beck 2008 22 Cost Difference Table 12345678 10000-2-3-2 201 -2-3 300000 4000 0 5001 60 0 700 80

23 © J. Christopher Beck 2008 23 Cost Difference Table 12345678 10000-2-3-2 201 -2-3 300000 4000 0 5001 60 0 700 80

24 © J. Christopher Beck 2008 24 Current State ? ? ? ? ? ? ?? 1 4 3 25 6 7 8

25 © J. Christopher Beck 2008 25 Swap 1 & 7: Cost 3 ? ? ? ? ? ? ?? 7 4 3 25 6 1 8 Only made 1 move (so far)!

26 © J. Christopher Beck 2008 26 New Cost Difference Table 12345678 100002030 20020111 30001 1 400111 50120 6000 701 80

27 © J. Christopher Beck 2008 27 Current State ? ? ? ? ? ? ?? 7 4 3 25 6 1 8

28 © J. Christopher Beck 2008 28 Swap 3 & 8: Cost 2 ? ? ? ? ? ? ?? 7 4 8 25 6 1 3

29 © J. Christopher Beck 2008 29 Swap 6 & 7: Cost 1 ? ? ? ? ? ? ?? 6 4 8 25 7 1 3

30 © J. Christopher Beck 2008 30 Moves Initial State: Cost 6 calculate cost difference table Swap 1 & 7: Cost 3 calculate cost difference table Swap 3 & 8: Cost 2 calculate cost difference table Swap 6 & 7: Cost 1 calculate cost difference table

31 © J. Christopher Beck 2008 31 Cost Difference Table 12345678 101112211 20122131 30114 12 402131 50212 6011 701 80

32 © J. Christopher Beck 2008 32 Now what? There are no improving moves to make! So far, we have been “hill- climbing” moves cost

33 © J. Christopher Beck 2008 33 Now what? Options: Restart from a new random state Take the least worse move (increase cost by minimal amount) Try a new style of local search

34 © J. Christopher Beck 2008 34 Now what? For now, let’s just stop In the next lecture, we will see one way to deal with this But if we stop, we haven’t solved the problem No guarantee that a local search will find the best (or even any) solution!!

35 © J. Christopher Beck 2008 35 Core Ideas of Local Search Start with some (random?) assignment of variables Look in “neighborhood” formed by making a small change to the assignment Choose best neighbor Repeat

36 © J. Christopher Beck 2008 36 To Define a Local Search … Define a way to find a starting solution a neighborhood a rule for choosing a neighbor a cost function (if you don’t already have one) (This is a bit of a simplification – more detail in the next lecture)

37 © J. Christopher Beck 2008 37 A Simple Scheduling Problem JobsProcessing times 0 J0R0[15]  J0R1[50] 1 J1R1[50]  J1R0[50] 2 J2R0[30]  J2R1[15] Solve with local search


Download ppt "© J. Christopher Beck 20081 Lecture 16: Local Search."

Similar presentations


Ads by Google