Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch. 3 – Search Supplemental slides for CSE 327 Prof. Jeff Heflin.

Similar presentations


Presentation on theme: "Ch. 3 – Search Supplemental slides for CSE 327 Prof. Jeff Heflin."— Presentation transcript:

1 Ch. 3 – Search Supplemental slides for CSE 327 Prof. Jeff Heflin

2 8-Puzzle Transition Model 724 56 831 724 56 831 724 56 831 74 526 831 724 536 81 blank-rightblank-downblank-leftblank-up state s actions a RESULT(s,a)

3 8-puzzle Search Tree 724 586 31 24 786 531 724 86 531 724 586 31 724 56 381 724 586 31 724 586 31 724 86 531 724 586 31 initial state

4 function T REE -S EARCH (problem) returns a solution, or failure initialize the frontier using the initial state of problem loop do if the frontier is empty then return failure choose a leaf node and remove it from the frontier if the node contains a goal state then return the corresponding solution expand the chosen node, adding the resulting nodes to the frontier Tree Search Algorithm From Figure 3.7, p. 77

5 Repeated States A CB C A State space Search tree B GC A BGCBA GBA initial state goal state

6 function G RAPH -S EARCH (problem) returns a solution, or failure initialize the frontier using the initial state of problem initialize the explored set to be empty loop do if the frontier is empty then return failure choose a leaf node and remove it from the frontier if the node contains a goal state then return the corresponding solution add the node to the explored set expand the chosen node, adding the resulting nodes to the frontier, but only if not in the frontier or explored set Graph Search Algorithm From Figure 3.7, p. 77

7 Depth-first Search A CB DEF H G I 1 27 3 6 4 5 8 9 not generated on frontier in memory deleted

8 Breadth-first Search A CB DEF H G I 1 2 7 3 6 4 5 89 not generated on frontier in memory deleted

9 Uniform Cost Search I GB G 1 2 4 I B G 10 4 5 State space Search tree g(n)=0 g(n)=4 g(n)=10 g(n)=9 C 3 C g(n)=7 3 not generated on frontier in memory deleted

10 Uninformed Search Summary depth-firstbreadth-firstuniform cost queuingadd to front (LIFO) add to back (FIFO)by path cost complete?noyesyes, if all step costs are greater than 0 optimal?noyes, if identical step costs yes, if all step costs are greater than 0 timeexpensive spacemodestexpensive

11 A* Example Use A* to solve the 8-puzzle: 123 468 75 123 456 78 initial state: goal state: Consider these heuristics –H 1 : The number of tiles out of place –H 2 : Sum of distances of tiles from goal positions Ignore moves that return you to the previous state path cost is the total number of moves made

12 A* on 8-puzzle 123 468 75 123 46 758 123 468 75 12 463 758 123 4 6 758 123 4 8 765 123 468 75 13 426 758 123 46 758 123 456 7 8 123 456 78 123 456 78 f=0+3=3 f=1+3=4 f=2+4=6 f=2+2=4 f=2+3=5f=2+4=6 f=3+3=6 f=3+1=4 f=4+2=6f=4+0=4 1 32 4 5 6 Heuristic = H 1 Whether or not this node is expanded depends on how you break ties. It could be expanded at any time or not at all.

13 A* on 8-puzzle 123 468 75 123 46 758 123 468 75 12 463 758 123 4 6 758 13 426 758 123 46 758 123 456 7 8 123 456 78 123 456 78 f=0+4=4 f=1+3=4 f=1+5=6 f=2+4=6f=2+2=4 f=3+3=6 f=3+1=4 f=4+2=6f=4+0=4 1 2 3 4 5 Heuristic = H 2

14 Summary of Search Algorithms typeorderingoptimal?complete?efficient? depth-firstuninformedLIFOno if lucky breadth-firstuninformedFIFOyes a yesno uniform costuninformedg(n)yes b no greedyinformedh(n)no usually A*informedg(n)+h(n)yes c yes b yes a – if step costs are identical b – if step costs > 0 c – if heuristic is admissible and consistent


Download ppt "Ch. 3 – Search Supplemental slides for CSE 327 Prof. Jeff Heflin."

Similar presentations


Ads by Google