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 Successor Function 724 56 831 724 56 831 724 56 831 74 526 831 724 536 81 blank-rightblank-downblank-leftblank-up

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 TREE-SEARCH(problem,fringe) returns a solution, or failure fringe  INSERT(MAKE-NODE(INITIAL-STATE[problem],fringe) loop do if EMPTY?(fringe) then return failure node  REMOVE-FIRST(fringe) if GOAL-TEST[problem] applied to STATE[node] succeeds then return SOLUTION(node) fringe  INSERT-ALL(EXPAND(node,problem),fringe) Tree Search Algorithm Notes: 1. fringe argument should be an empty queue. The type of the queue (e.g., LIFO, FIFO, etc.) will affect the order of the search 2. INITIAL-STATE[problem] is just syntax for accessing an object’s data (think problem.initialState in Java or C++) From Figure 3.9, p. 72

5 Problem Solving Agent Algorithm function SIMPLE-PROBLEM-SOLVING-AGENT(percept) returns an action static: seq, an action sequence, initially empty state, some description of the current world state goal, a goal, initially null problem, a problem formulation state  UPDATE-STATE(state,percept) if seq is empty then do goal  FORMULATE-GOAL(state) problem  FORMULATE-PROBLEM(state,goal) seq  SEARCH(problem) action  FIRST(seq) seq  REST(seq) return action From Figure 3.1, p. 61

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 fringe in memory deleted

8 Breadth-first Search A CB DEF H G I 1 2 7 3 6 4 5 89 not generated on fringe 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 fringe in memory deleted

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

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


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

Similar presentations


Ads by Google