Presentation is loading. Please wait.

Presentation is loading. Please wait.

2015-5-9 EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.

Similar presentations


Presentation on theme: "2015-5-9 EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt."— Presentation transcript:

1

2 EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt

3 EIE426-AICV 2 Contents:  Problem types  Problem formulation  Example problems  Basic search algorithms: - breadth-first search - depth-first search  Best-first search - greedy search - A* search

4 EIE426-AICV 3 Example: Romania On holiday in Romania; currently in Arad. Flight leaves tomorrow for Bucharest. Formulate goal: be in Bucharest Formulate problem: states: various cities actions: flight between cities Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest

5 EIE426-AICV 4 Example: Romania (cont.)

6 EIE426-AICV 5 Selecting a state space Real world is absurdly complex = 〉 state space must be abstracted for problem solving (Abstract) state = set of real states (Abstract) action = complex combination of real actions e.g., “ Arad => Zerind'' represents a complex set of possible routes, detours, rest stops, etc. For guaranteed realizability, any real state “ in Arad ” must get to some real state “ in Zerind ” (Abstract) solution = set of real paths that are solutions in the real world Each abstract action should be “ easier ” than the original problem!

7 EIE426-AICV 6 State Space Representation of Problems Nodes (N): partial solution states Arcs (A): the steps in a problem-solving process. Initial States (one or more) (S): the given information in a problem instance, form the root of the graph Goal States (GD): the solutions to a problem instance State Space Search: finding a solution path from the start state to a goal A state space is represented by a four-tuple [N, A, S, GD].

8 EIE426-AICV 7 Example: The 8-puzzle states: integer locations of tiles (ignore intermediate positions) actions: move blank left, right, up, down goal test: = goal state (given) path cost: 1 per move

9 EIE426-AICV 8 Example: The Traveling Salesperson Suppose a salesperson has N cities to visit and must return home. The goal of the problem is to find the shortest path for the salesperson to travel, visiting each city, and then returning to the starting city. Nodes: cities Arcs: labeled with a weight indicating the cost of traveling Complexity: (N-1)!

10 EIE426-AICV 9 Example: The Traveling Salesperson (cont.)

11 EIE426-AICV 10 The start state: an empty board The goal description: three Xs or three Os in a row, column, or diagonal A directed acyclic graph (DAG) Arc: a legal move (placing an X or O in an unused location The complexity: 9!=362,880 paths Example: Tic-Tac-Toe

12 EIE426-AICV 11 Tree search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (also known as expanding states)

13 EIE426-AICV 12 Tree search example

14 EIE426-AICV 13 Implementation: states vs. nodes A state is a (representation of) a physical configuration A node is a data structure constituting part of a search tree includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost! The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

15 EIE426-AICV 14 Implementation: general tree search

16 EIE426-AICV 15 Search strategies A strategy is defined by picking the order of node expansion Strategies are evaluated along the following dimensions: Completeness -- does it always find a solution if one exists? Time complexity -- number of nodes generated/expanded Space complexity -- maximum number of nodes in memory Optimality -- does it always find a least-cost solution? Time and space complexity are measured in terms of b --- maximum branching factor of the search tree d --- depth of the least-cost solution m --- maximum depth of the state space (may be  )

17 EIE426-AICV 16 Uninformed search strategies Uninformed strategies use only the information available in the problem definition Breadth-first search Depth-first search etc.

18 EIE426-AICV 17 S DE F G CB A Two costs: finding a path and traversing the path. A Search Tree S  G

19 EIE426-AICV 18 Search Trees (cont.) S DE F G CB A b = 2 d = 0, 1, …,6 m = 6 From the left to the right: alphabetical order

20 EIE426-AICV 19 Breadth-First Search Expand shallowest unexpanded node Implementation: fringe is an FIFO queue, i.e., new successors go at end

21 EIE426-AICV 20 Breadth-First Search (cont.) S D A B E C F G Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

22 EIE426-AICV 21 Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b^2+b^3+ … +b^d + b(b^d-1)= O(b^(d+1)), i.e., exponential in d Space? O(b^(d+1)) (keeps every node in memory) Optimal? Yes (if cost = 1 per step); not optimal in general Space is the big problem; can easily generate nodes at 10 MB/sec so 24 hrs = 860 GB.

23 EIE426-AICV 22 Depth-First Search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

24 EIE426-AICV 23 Depth-First Search (cont.) S D A B E C F G

25 EIE426-AICV 24 Properties of depth-first search Complete? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path => complete in finite spaces Time? O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space? O(b m ), i.e., linear space! Optimal? No

26 EIE426-AICV 25 A comparison between depth-first search and breadth-first search Advantages of Depth-First Search  It requires less memory.  By chance, it may find a solution without examining much of the search space at all. Advantages of Breadth-First Search  It will not get trapped exploring a blind alley.  If there are multiple solutions, then a minimal solution will be found.

27 EIE426-AICV 26 Summary Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored Variety of uninformed search strategies

28 EIE426-AICV 27 Best-first search Idea: use an evaluation function for each node -- estimation of “ desirability ” = 〉 Expand most desirable unexpanded node Implementation: fringe is a queue sorted in decreasing order of desirability Special cases: greedy search A* search

29 EIE426-AICV 28 Romania with step costs in km

30 EIE426-AICV 29 Greedy search Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal E.g., h SLD (n) = straight-line distance from n to Bucharest Greedy search expands the node that appears to be closest to goal

31 EIE426-AICV 30 Greedy search example

32 EIE426-AICV 31 Properties of greedy search Complete? No -- can get stuck in loops, e.g., Iasi  Neamt  Complete in finite space with repeated-state checking Time? O(b^m), but a good heuristic can give dramatic improvement Space? O(b^m)---keeps all nodes in memory Optimal? No

33 EIE426-AICV 32 A* search Idea: avoid expanding paths that are already expensive Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost to goal from n f(n) = estimated total cost of path through n to goal A* search uses an admissible heuristic i.e., h(n)  h*(n) where h*(n) is the true cost from n. (Also require h(n)  0, so h(G)=0 for any goal G.) E.g., h SLD (n) never overestimates the actual road distance Theorem: A* search is optimal.

34 EIE426-AICV 33 A* search example

35 EIE426-AICV 34 Optimality of A* (standard proof) Suppose some suboptimal goal G 2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G 1. f(G 2 ) = g(G 2 ) since h(G 2 ) = 0 > g(G 1 ) since G 2 is suboptimal  f(n) since h is admissible Since f(G 2 ) > f(n), A* will never select G 2 for expansion

36 EIE426-AICV 35 Properties of A* Complete? Yes, unless there are infinitely many nodes with f  f(G) Time? Depends on the heuristic. In the worse case, exponential in the length of the solution. Space? Keeps all nodes in memory Optimal? Yes

37 EIE426-AICV 36 h Overestimates h* Step cost = 1 The search may miss the optimal solution if there is any overestimate h. Miss this solution!

38 EIE426-AICV 37 Admissible Heuristics E.g., for the 8-puzzle: h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) h 1 (S) = 7 h 2 (S) = = 14

39 EIE426-AICV 38 Dominance If h 2 (n)  h 1 (n) for all n (both admissible) then h 2 dominates h 1 and is better for search Typical search costs: d=14 A*(h 1 ) = 539 nodes A*(h 2 ) = 113 nodes d=24 A*(h 1 ) = 39,135 nodes A*(h 2 ) = 1,641 nodes

40 EIE426-AICV 39 Example: n-queens Put n queens on an n times n board with no two queens on the same row, column, or diagonal. Move a queen to reduce number of conflicts.

41 EIE426-AICV 40 Example: Heuristics and A* Search for Solving the 8- Puzzle problem

42 EIE426-AICV x 2 = 4

43 EIE426-AICV 42 Heuristic: Sum of distances out of place

44 EIE426-AICV 43

45 EIE426-AICV 44 Part of the Search Family of Procedures

46 EIE426-AICV 45 Search Alternatives from a Procedure Family  Depth-first search is good when unproductive partial paths are never too long.  Breadth-first search is good when the branching factor is never too large.  A* search is good when a good heuristic is available. Search Animations


Download ppt "2015-5-9 EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt."

Similar presentations


Ads by Google