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 Problem Solving Agent Algorithm function S IMPLE -P ROBLEM -S OLVING -A GENT (percept) returns an action persistent: seq, an action sequence, initially empty state, some description of the current world state goal, a goal, initially null problem, a problem formulation state  U PDATE -S TATE (state,percept) if seq is empty then goal  F ORMULATE -G OAL (state) problem  F ORMULATE -P ROBLEM (state,goal) seq  S EARCH (problem) if seq = failure then return a null action action  F IRST (seq) seq  R EST (seq) return action From Figure 3.1, p. 67

6 Water Jug Problem state: initial state: goal test: –x and y can be any value path cost: –1 per solution step? –1 per gallon of water moved? actions/successor function –let C 12 =12, C 8 =8, C 3 =3 fill-jug-i –if J i < C i then J i =C i empty-jug-i-into-jug-j –if J i <= C j – J j then J j ’ = J j + J i, J i ’=0 fill-jug-i-from-jug-j –if J j >= C i – J i then J j ’ = J j – (C i – J i ), J i ’=C i

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 Repeated States A CB C A State space Search tree B GC A BGCBA GBA initial state goal state

11 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

12 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

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

14 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

15 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