Presentation is loading. Please wait.

Presentation is loading. Please wait.

Supplemental slides for CSE 327 Prof. Jeff Heflin

Similar presentations


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

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

2 8-puzzle Successor Function
7 2 4 5 6 8 3 1 blank-right blank-left blank-up blank-down 7 2 4 5 6 8 3 1 7 2 4 5 6 8 3 1 7 4 5 2 6 8 3 1 7 2 4 5 3 6 8 1

3 8-puzzle Search Tree initial state 7 2 4 5 8 6 3 1 7 2 4 8 6 5 3 1 7 2

4 Tree Search Algorithm 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) 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 Depth-first Search A not generated on fringe B C in memory deleted D E
1 A not generated on fringe 2 7 B C in memory deleted 3 6 8 9 D E F G blue = in memory, green = on frontier, red = out of memory, clear = not generated 4 5 H I

7 Breadth-first Search A not generated on fringe B C in memory deleted D
1 A not generated on fringe 2 3 B C in memory deleted 4 5 6 7 D E F G 8 9 H I

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

9 Uninformed Search Summary
depth-first breadth-first uniform cost queuing add to front (LIFO) add to back (FIFO) by path cost complete? no yes yes, if all step costs are greater than 0 optimal? yes, if identical step costs time expensive space modest

10 Water Jug Problem state: <J12, J8, J3>
initial state: <0, 0, 0> goal test: <1, x, y> x and y can be any value path cost: 1 per solution step? 1 per gallon of water moved? actions/successor function let C12=12, C8=8, C3=3 fill-jug-i if Ji < Ci then Ji=Ci empty-jug-i-into-jug-j if Ji <= Cj – Jj then Jj’ = Jj + Ji, Ji’=0 fill-jug-i-from-jug-j if Jj >= Ci – Ji then Jj’ = Jj – (Ci – Ji), Ji’=Ci


Download ppt "Supplemental slides for CSE 327 Prof. Jeff Heflin"

Similar presentations


Ads by Google