Presentation is loading. Please wait.

Presentation is loading. Please wait.

Brian Williams, Spring 041 Problem Solving as State Space Search Brian C.Williams 16.410-13 Sep 14 th, 2004 Slides adapted from: 6.034 Tomas Lozano Perez,

Similar presentations


Presentation on theme: "Brian Williams, Spring 041 Problem Solving as State Space Search Brian C.Williams 16.410-13 Sep 14 th, 2004 Slides adapted from: 6.034 Tomas Lozano Perez,"— Presentation transcript:

1 Brian Williams, Spring 041 Problem Solving as State Space Search Brian C.Williams 16.410-13 Sep 14 th, 2004 Slides adapted from: 6.034 Tomas Lozano Perez, Russell and Norvig AIMA

2 Brian Williams, Spring 042 Assignments Remember: Problem Set #1: Simple Scheme and Search due Monday, September 20th, 2003. Reading: –Solving problems by searching: AIMA Ch. 3

3 Brian Williams, Spring 043 Complex missions must carefully: Plan complex sequences of actions Schedule actions Allocate tight resources Monitor and diagnose behavior Repair or reconfigure hardware.  Most AI problems, like these, may be formulated as state space search.

4 Brian Williams, Spring 044 Outline Problem Formulation –Problem solving as state space search Mathematical Model –Graphs and search trees Reasoning Algorithms –Depth and breadth-first search

5 Brian Williams, Spring 045 Early AI: What are the universal problem solving methods? Astronaut Goose Grain Fox Rover Can the astronaut get its supplies safely across the Martian canal? Astronaut + 1 item allowed in the rover. Goose alone eats Grain Fox alone eats Goose SimpleTrivial

6 Brian Williams, Spring 046 Problem Solving as State Space Search Formulate Goal –State Astronaut, Fox, Goose & Grain across river Formulate Problem –States Location of Astronaut, Fox, Goose & Grain at top or bottom river bank –Operators Astronaut drives rover and 1 or 0 items to other bank. Generate Solution –Sequence of Operators (or States) Move(goose,astronaut), Move(astronaut),...

7 Brian Williams, Spring 047 Astronaut Goose Grain Fox Astronaut Goose Grain Fox Grain Fox Astronaut Goose Grain Astronaut Fox Goose Fox Astronaut Grain Goose Grain Fox Astronaut

8 Brian Williams, Spring 048 Astronaut Goose Grain Fox Grain Fox Astronaut Goose Astronaut Goose Grain Fox Goose Fox Astronaut Grain Astronaut Grain Fox Goose Astronaut Goose Grain Fox Goose Grain Astronaut Fox Astronaut Goose Fox Grain Astronaut Goose Fox Astronaut Goose Grain Goose Astronaut Fox Grain Goose Grain Fox Astronaut Grain Goose Fox Astronaut Fox Goose Grain Astronaut Goose Grain Fox Astronaut Goose Grain Fox

9 Brian Williams, Spring 049 Astronaut Goose Grain Fox Grain Fox Astronaut Goose Astronaut Grain Fox Goose Astronaut Fox Grain Astronaut Goose Grain Fox Astronaut Goose Grain Fox Grain Astronaut Goose Fox Astronaut Goose Grain Goose Fox Astronaut Grain Goose Grain Astronaut Fox Astronaut Goose Fox Grain Astronaut Grain Goose Fox Astronaut Fox Goose Grain Goose Grain Fox Astronaut Goose Grain Fox Astronaut Goose Grain Fox

10 Brian Williams, Spring 0410 Example: 8-Puzzle States: Operators: Goal Test: 54 61 73 8 2 12 8 3 76 4 5 StartGoal integer location for each tile AND … move empty square up, down, left, right goal state as given

11 Brian Williams, Spring 0411 courtesy of NASA Swaggert & Lovell work on Apollo 13 emergency rig lithium hydroxide unit. –Assembly Mattingly works in ground simulator to identify new sequence handling severe power limitations. –Planning & Resource Allocation Mattingly identifies novel reconfiguration, exploiting LEM batteries for power. –Reconfiguration and Repair Example: Planning Discrete Actions

12 Brian Williams, Spring 0412 Planning as State Space Search: STRIPS Operator Representation  Effects specify how to change the set of assertions. Initial state: (and (hose a) (clamp b) (hydroxide-unit c) (on-table a) (on-table b) (clear a) (clear b) (clear c) (arm-empty)) goal (partial state): (and (connected a b) (attached b a))) precondition: (and (clear hose) (on-table hose) (empty arm)) effect: (and (not (clear hose)) (not (on-table hose)) (not (empty arm)) (holding arm hose))) pickup hose Note: strips doesn’t allow derived effects; you must be complete! } Available actions Strips operators

13 Brian Williams, Spring 0413 STRIPS Action Assumptions Atomic time. Agent is omniscient (no sensing necessary). Agent is sole cause of change. Actions have deterministic effects. No indirect effects. precondition: (and (clear hose) (on-table hose) (empty arm)) effect: (and (not (clear hose)) (not (on-table hose)) (not (empty arm)) (holding arm hose))) pickup hose

14 Brian Williams, Spring 0414 STRIPS Action Schemata (:operator pick-up :parameters ((hose ?ob1)) :precondition (and (clear ?ob1) (on-table ?ob1) (empty arm)) :effect (and (not (clear ?ob1)) (not (on-table ?ob1)) (not (empty arm)) (holding arm ?ob1))) Instead of defining: pickup-hose and pickup-clamp and … Define a schema (with variables ?v):

15 Brian Williams, Spring 0415 Outline Problem Formulation –Problem solving as state space search Mathematical Model –Graphs and search trees Reasoning Algorithms –Depth and breadth-first search

16 Brian Williams, Spring 0416 Problem Formulation: A Graph Operator Link (edge) State Node (vertex) Directed Graph (one-way streets) d e Undirected Graph (two-way streets) neighbors (adjacent) Incident to edge Start Vertex of Edge End Vertex of Edge

17 Brian Williams, Spring 0417 Problem Formulation: A Graph In Degree (2) Out Degree (1) Directed Graph (one-way streets) b Undirected Graph (two-way streets) b Degree (1)

18 Brian Williams, Spring 0418 Problem Formulation: A Graph Directed Graph (one-way streets) a c d e b Undirected Graph (two-way streets) a c e d b Connected graph Path between all vertices. Complete graph All vertices are adjacent. Sub graph Subset of vertices edges between vertices in Subset Clique A complete subgraph All vertices are adjacent. Strongly connected graph Directed path between all vertices.

19 Brian Williams, Spring 0419 Examples of Graphs San Fran Boston LA Dallas Wash DC Roadmap ABC AB C AB C A B C Put C on B Put C on A Put B on C Put C on A A B C Put A on C Planning Actions (graph of possible states of the world)

20 Brian Williams, Spring 0420 A Graph SFO Bos LA Dallas Wash DC Airline Routes A Graph G is represented as a pair, where: V is a set of vertices {v1 …} E is a set of (directed) edges {e1, …} An edge is a pair of vertices, where v2 is the head of the edge, and v1 is the tail of the edge < {Bos, SFO, LA, Dallas, Wash DC} {,...} >

21 Brian Williams, Spring 0421 A Solution is a State Sequence: Problem Solving Searches Paths C S B G A D S D A C Simple path has no repeated vertices. For a cycle, start = end. A path is a sequence of edges (or vertices) start end

22 Brian Williams, Spring 0422 A Solution is a State Sequence: Problem Solving Searches Paths C S B G A D S D A C G Represent searched paths using a tree.

23 Brian Williams, Spring 0423 A Solution is a State Sequence: Problem Solving Searches Paths C S B G A D S D BA CG CG D CG Represent searched paths using a tree.

24 Brian Williams, Spring 0424 Search Trees Root Branch (Edge) Node (vertex)

25 Brian Williams, Spring 0425 Search Trees Parent (Ancestor) Child (Descendant) Siblings

26 Brian Williams, Spring 0426 Search Trees Ancestors Descendants

27 Brian Williams, Spring 0427 Outline Problem Formulation –Problem solving as state space search Mathematical Model –Graphs and search trees Reasoning Algorithms –Depth and breadth-first search

28 Brian Williams, Spring 0428 Classes of Search BlindDepth-First Systematic exploration of whole tree (uninformed)Breadth-First until the goal is found. Iterative-Deepening HeuristicHill-Climbing Uses heuristic measure of goodness (informed)Best-First of a node,e.g. estimated distance to. Beam goal. OptimalBranch&Bound Uses path “length” measure. Finds (informed)A* “shortest” path. A* also uses heuristic

29 Brian Williams, Spring 0429 Classes of Search BlindDepth-First Systematic exploration of whole tree (uninformed)Breadth-First until the goal is found. Iterative-Deepening

30 Brian Williams, Spring 0430 Depth First Search (DFS) S D BA CG CG D CG Idea: After visiting node Visit children, then siblings Visit siblings left to right 1 2 3 4 5 6 7 8 9 10 11 S A D CG C B D CG G

31 Brian Williams, Spring 0431 Breadth First Search (BFS) S D BA CG CG D CG Idea: After visiting node Visit siblings, then children Visit relatives left to right (top to bottom) 1 2 4 8 9 5 3 6 10 11 7 S A D CG C B D CG G

32 Brian Williams, Spring 0432 Elements of Algorithm Design Description: (today) –stylized pseudo code, sufficient to analyze and implement the algorithm (next Monday). Analysis: (next Wednesday) Soundness: –when a solution is returned, is it guaranteed to be correct? Completeness: –is the algorithm guaranteed to find a solution when there is one? Time complexity: –how long does it take to find a solution? Space complexity: –how much memory does it need to perform search?

33 Brian Williams, Spring 0433 Outline Problem Formulation: State space search Model: Graphs and search trees Reasoning Algorithms: DFS and BFS –A generic search algorithm –Depth-first search example –Handling cycles –Breadth-first search example

34 Brian Williams, Spring 0434 Simple Search Algorithm How do we maintain the search state? A set of partial paths explored thus far. An ordering on which partial path to expand next called a queue Q. How do we perform search? Repeatedly: Select next partial path from Q. Expand it. Add expansions to Q. Terminate when goal found. S D BA CG CG D CG Going Meta: Search as State Space Search State Space Operator Goal-Test

35 Brian Williams, Spring 0435 Simple Search Algorithm S denotes the start node G denotes the goal node. A partial path is a path from S to some node D, e.g., (D A S) The head of a partial path is the most recent node of the path, e.g., D. The Q is a list of partial paths, e.g. ((D A S) (C A S) …). S D BA CG CG D CG

36 Brian Williams, Spring 0436 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) 2.If Q is empty, fail. Else, pick a partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else: a)Remove N from Q b)Find all children of head(N) and create all one-step extensions of N to each child. c)Add all extended paths to Q d)Go to step 2.

37 Brian Williams, Spring 0437 Outline Problem Formulation: State space search Model: Graphs and search trees Reasoning Algorithms: DFS and BFS –A generic search algorithm –Depth-first search example –Handling cycles –Breadth-first search example

38 Brian Williams, Spring 0438 Depth First Search (DFS) S D BA CG CG D CG Idea: Visit children, then siblings Visit siblings left to right, (top to bottom). 1 2 3 4 5 6 7 8 9 10 11 S A D CG C B D CG G Assuming that we pick the first element of Q, Then where do we add path extensions to the Q?

39 Brian Williams, Spring 0439 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) 2.If Q is empty, fail. Else, pick a partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else: a)Remove N from Q b)Find all children of head(N) and create all the one-step extensions of N to each child. c)Add all extended paths to Q d)Go to step 2.

40 Brian Williams, Spring 0440 Depth-First Pick first element of Q; Add path extensions to front of Q C S B G A D Q 1(S) 2 3 4 5 1

41 Brian Williams, Spring 0441 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) 2.If Q is empty, fail. Else, pick a partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else: a)Remove N from Q b)Find all children of head(N) and create all the one-step extensions of N to each child. c)Add all extended paths to Q d)Go to step 2.

42 Brian Williams, Spring 0442 C S B G A D Q 1(S) 2 3 4 5 1 Depth-First Pick first element of Q; Add path extensions to front of Q

43 Brian Williams, Spring 0443 C S B G A D Q 1(S) 2(A S) 3 4 5 1 Added paths in blue Depth-First Pick first element of Q; Add path extensions to front of Q

44 Brian Williams, Spring 0444 C S B G A D Q 1(S) 2(A S) (B S) 3 4 5 1 Added paths in blue Depth-First Pick first element of Q; Add path extensions to front of Q

45 Brian Williams, Spring 0445 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) 2.If Q is empty, fail. Else, pick a partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else: a)Remove N from Q b)Find all children of head(N) and create all the one-step extensions of N to each child. c)Add all extended paths to Q d)Go to step 2.

46 Brian Williams, Spring 0446 C S B G A D Q 1(S) 2(A S) (B S) 3 4 5 1 Added paths in blue 2 Depth-First Pick first element of Q; Add path extensions to front of Q

47 Brian Williams, Spring 0447 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4 5 1 2 Depth-First Pick first element of Q; Add path extensions to front of Q Added paths in blue

48 Brian Williams, Spring 0448 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4 5 1 2 Depth-First Pick first element of Q; Add path extensions to front of Q Added paths in blue

49 Brian Williams, Spring 0449 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4 5 1 2 3 Depth-First Pick first element of Q; Add path extensions to front of Q Added paths in blue

50 Brian Williams, Spring 0450 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 1 2 3 Depth-First Pick first element of Q; Add path extensions to front of Q Added paths in blue

51 Brian Williams, Spring 0451 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 1 2 3 4 Depth-First Pick first element of Q; Add path extensions to front of Q Added paths in blue

52 Brian Williams, Spring 0452 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 (C D A S)(G D A S) (B S) 1 2 3 4 Depth-First Pick first element of Q; Add path extensions to front of Q

53 Brian Williams, Spring 0453 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) 2.If Q is empty, fail. Else, pick a partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else: a)Remove N from Q b)Find all children of head(N) and create all the one-step extensions of N to each child. c)Add all extended paths to Q d)Go to step 2.

54 Brian Williams, Spring 0454 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 (C D A S)(G D A S) (B S) 1 2 3 4 Depth-First Pick first element of Q; Add path extensions to front of Q

55 Brian Williams, Spring 0455 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 (C D A S)(G D A S) (B S) 6(G D A S)(B S) 1 2 3 4 Depth-First Pick first element of Q; Add path extensions to front of Q

56 Brian Williams, Spring 0456 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 (C D A S)(G D A S) (B S) 6(G D A S)(B S) 1 2 3 4 Depth-First Pick first element of Q; Add path extensions to front of Q

57 Brian Williams, Spring 0457 Outline Problem Formulation: State space search Model: Graphs and search trees Reasoning Algorithms: DFS and BFS –A generic search algorithm –Depth-first search example –Handling cycles –Breadth-first search example

58 Brian Williams, Spring 0458 C S B G A D Issue: Starting at S and moving top to bottom, will depth-first search ever reach G?

59 Brian Williams, Spring 0459 C S B G A D Q 1(S) 2(A S) (B S) 3(C A S) (D A S) (B S) 4(D A S) (B S) 5 (C D A S)(G D A S) (B S) 6(G D A S)(B S) 1 2 3 4 Depth-First C visited multiple times Multiple paths to C, D & G How much wasted effort can be incurred in the worst case? Effort can be wasted in more mild cases

60 Brian Williams, Spring 0460 How Do We Avoid Repeat Visits? Idea: Keep track of nodes already visited. Do not place visited nodes on Q. Does this maintain correctness? Any goal reachable from a node that was visited a second time would be reachable from that node the first time. Does it always improve efficiency? Visits only a subset of the original paths, suc that each node appears at most once at the head of a path in Q.

61 Brian Williams, Spring 0461 How Do We Modify Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) as only entry; 2.If Q is empty, fail. Else, pick some partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else a)Remove N from Q b)Find all children of head(N) and create all the one-step extensions of N to each child. c)Add to Q all the extended paths; d)Go to step 2.

62 Brian Williams, Spring 0462 Simple Search Algorithm Let Q be a list of partial paths, Let S be the start node and Let G be the Goal node. 1.Initialize Q with partial path (S) as only entry; set Visited = ( ) 2.If Q is empty, fail. Else, pick some partial path N from Q 3.If head(N) = G, return N (goal reached!) 4.Else a)Remove N from Q b)Find all children of head(N) not in Visited and create all the one-step extensions of N to each child. c)Add to Q all the extended paths; d)Add children of head(N) to Visited e)Go to step 2.

63 Brian Williams, Spring 0463 Testing for the Goal This algorithm stops (in step 3) when head(N) = G. We could have performed this test in step 6 as each extended path is added to Q. This would catch termination earlier and be perfectly correct for all the searches we have covered so far. However, performing the test in step 6 will be incorrect for the optimal searches we look at later. We have chosen to leave the test in step 3 to maintain uniformity with these future searches.

64 Brian Williams, Spring 0464 Outline Problem Formulation: State space search Model: Graphs and search trees Reasoning Algorithms: DFS and BFS –A generic search algorithm –Depth-first search example –Handling cycles –Breadth-first search example

65 Brian Williams, Spring 0465 Breadth First Search (BFS) S D BA CG CG D CG Idea: Visit siblings before their children Visit relatives left to right 1 2 4 8 9 5 3 6 10 11 7 S A D CG C B D CG G Assuming that we pick the first element of Q, Then where do we add path extensions to the Q?

66 Brian Williams, Spring 0466 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2 3 4 5 6 1

67 Brian Williams, Spring 0467 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2 3 4 5 6 1

68 Brian Williams, Spring 0468 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3 4 5 6 1

69 Brian Williams, Spring 0469 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3 4 5 6 1 2

70 Brian Williams, Spring 0470 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4 5 6 1 2

71 Brian Williams, Spring 0471 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4 5 6 1 2 3

72 Brian Williams, Spring 0472 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4(C A S) (D A S) (G B S)*G,C,D,B,A,S 5 6 1 2 3 * We could stop here, when the first path to the goal is generated.

73 Brian Williams, Spring 0473 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4(C A S) (D A S) (G B S)*G,C,D,B,A,S 5 6 1 2 3 4 * We could stop here, when the first path to the goal is generated.

74 Brian Williams, Spring 0474 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4(C A S) (D A S) (G B S)*G,C,D,B,A,S 5(D A S) (G B S)G,C,D,B,A,S 6 1 2 3 4 5

75 Brian Williams, Spring 0475 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4(C A S) (D A S) (G B S)*G,C,D,B,A,S 5(D A S) (G B S)G,C,D,B,A,S 6(G B S)G,C,D,B,A,S 1 2 3 4 5 6

76 Brian Williams, Spring 0476 Breadth-First Pick first element of Q; Add path extensions to end of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A,B,S 3(B S) (C A S) (D A S)C,D,B,A,S 4(C A S) (D A S) (G B S)*G,C,D,B,A,S 5(D A S) (G B S)G,C,D,B,A,S 6(G B S)G,C,D,B,A,S 1 2 3 4 5 6

77 Brian Williams, Spring 0477 Depth-first with visited list Pick first element of Q; Add path extensions to front of Q C S B G A D QVisited 1(S)S 2(A S) (B S)A, B, S 3(C A S) (D A S) (B S)C,D,B,A,S 4(D A S) (B S)C,D,B,A,S 5(G D A S) (B S)G,C,D,B,A,S 1 2 3 4 5

78 Brian Williams, Spring 0478 Depth First Search (DFS) S D BA CG CG D CG S D BA CG CG D CG Breadth First Search (BFS) For each search type, where do we place the children on the queue? Depth-first: Add path extensions to front of Q Pick first element of Q Breadth-first: Add path extensions to back of Q Pick first element of Q

79 Brian Williams, Spring 0479 What You Should Know Most problem solving tasks may be formulated as state space search. Mathematical representations for search are graphs and search trees. Depth-first and breadth-first search may be framed, among others, as instances of a generic search strategy. Cycle detection is required to achieve efficiency and completeness.

80 Brian Williams, Spring 0480 Appendix

81 Brian Williams, Spring 0481 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2 3 4 5 6 7 1

82 Brian Williams, Spring 0482 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3 4 5 6 7 1 2 Added paths in blue

83 Brian Williams, Spring 0483 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3(B S) (C A S) (D A S) 4 5 6 7 1 2 3 Added paths in blue

84 Brian Williams, Spring 0484 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3(B S) (C A S) (D A S) 4(C A S) (D A S) (D B S) (G B S)* 5 6 7 1 2 3 4 Added paths in blue Revisited nodes in pink * We could have stopped here, when the first path to the goal was generated.

85 Brian Williams, Spring 0485 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3(B S) (C A S) (D A S) 4(C A S) (D A S) (D B S) (G B S)* 5(D A S) (D B S) (G B S) 6 7 1 2 3 4 5

86 Brian Williams, Spring 0486 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3(B S) (C A S) (D A S) 4(C A S) (D A S) (D B S) (G B S)* 5(D A S) (D B S) (G B S) 6(D B S) (G B S) (C D A S) (G D A S) 7 1 2 3 4 5 6

87 Brian Williams, Spring 0487 Breadth-First (without Visited list) Pick first element of Q; Add path extensions to end of Q C S B G A D Q 1(S) 2(A S) (B S) 3(B S) (C A S) (D A S) 4(C A S) (D A S) (D B S) (G B S)* 5(D A S) (D B S) (G B S) 6(D B S) (G B S) (C D A S) (G D A S) 7(G B S) (C D A S) (G D A S) 1 2 3 4 5 6 7


Download ppt "Brian Williams, Spring 041 Problem Solving as State Space Search Brian C.Williams 16.410-13 Sep 14 th, 2004 Slides adapted from: 6.034 Tomas Lozano Perez,"

Similar presentations


Ads by Google