 # 1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*

## Presentation on theme: "1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*"— Presentation transcript:

1 Heuristic Search Chapter 4

2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*

3 Heuristic Search Heuristic: A rule of thumb generally based on expert experience, common sense to guide problem-solving process In search, use a heuristic function that estimates how far we are from a goal. How do we use heuristics?

4 Romania with step costs in km

5 Greedy best-first search example

6

7

8

10 Robot Navigation 0211 587 7 3 4 7 6 7 632 8 6 45 233 36524435 546 5 6 4 5 f(N) = h(N), with h(N) = Manhattan distance to the goal

11 Properties of greedy best-first search Complete? No – can get stuck in loops; Yes, if we can avoid repeated states Time? O(b m ), but a good heuristic can give dramatic improvement Space? O(b m ) -- keeps all nodes in memory Optimal? No

12 A* Search A* search combines Uniform-cost and Greedy Best-first Search Evaluation function: f(N) = g(N) + h(N) where: g(N) is the cost of the best path found so far to N h(N) is an admissible heuristic f(N) is the estimated cost of cheapest solution through N 0 <   c(N,N’) (no negative cost steps). Order the nodes in the fringe in increasing values of f(N)

13 A * search example

14 A * search example

15 A * search example

16 A * search example

17 A * search example

18 A * search example

19 Admissible heuristic Let h*(N) be the cost of the optimal path from N to a goal node Heuristic h(N) is admissible if: 0  h(N)  h*(N) An admissible heuristic is always optimistic

20 8-Puzzle 123 456 78 12 3 4 5 67 8 Ngoal h 1 (N) = number of misplaced tiles = 6 is admissible h 2 (N) = sum of distances of each tile to goal = 13 is admissible What heuristics are overestimates?

21 Completeness & Optimality of A* Claim: If there is a path from the initial to a goal node, A* using TREE-SEARCH terminates by finding the best path, hence is: complete optimal

22 Optimality of A * (proof) Suppose some suboptimal goal G 2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G. We can show f(n) < f(G 2 ), so A* would not have selected G 2.

23 Optimality of A * (proof) Cont’d: f(G 2 ) = g(G 2 )since h(G 2 ) = 0 g(G 2 ) > g(G) since G 2 is suboptimal f(G) = g(G) since h(G) = 0 f(G 2 ) > f(G) from above

24 Optimality of A * (proof) Cont’d: f(G 2 )> f(G) from above h(n)≤ h*(n) since h is admissible g(n) + h(n)≤ g(n) + h * (n) f(n) ≤ f(G) Hence f(G 2 ) > f(n), and A * will never select G 2 for expansion

25 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible

26 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible

27 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible

28 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible

29 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible

30 Consistent Heuristic The admissible heuristic h is consistent (or satisfies the monotone restriction) if for every node N and every successor N’ of N: h(N)  c(N,N’) + h(N’) (triangular inequality) A consisteny heuristic is admissible. N N’ h(N) h(N’) c(N,N’)

31 Exampel: Graph Search returns a suboptimal solution h=7 21 5 4 h=6 h=1h=0 S A B G h is admissible but not consistent; e.g. h(S)=7  c(S,A) + h(A) = 5 ? No.

32 8-Puzzle 123 456 78 12 3 4 5 67 8 Ngoal h 1 (N) = number of misplaced tiles h 2 (N) = sum of distances of each tile to goal are both consistent. But do you see why?

33 Claims If h is consistent, then the function f along any path is non-decreasing: f(N) = g(N) + h(N) f(N’) = g(N) +c(N,N’) + h(N’) h(N)  c(N,N’) + h(N’) f(N)  f(N’) If h is consistent, then whenever A* expands a node it has already found an optimal path to the state associated with this node N N’ h(N) h(N’) c(N,N’)

34 Optimality of A * A * expands nodes in order of increasing f value Gradually adds "f-contours" of nodes Contour i has all nodes with f=f i, where f i < f i+1

35 Avoiding Repeated States in A* If the heuristic h is consistent, then: Let CLOSED be the list of states associated with expanded nodes When a new node N is generated: If its state is in CLOSED, then discard N If it has the same state as another node in the fringe, then discard the node with the largest f

36 Heuristic Accuracy h(N) = 0 for all nodes is admissible and consistent. Hence, breadth-first and uniform- cost are particular A* !!! Let h 1 and h 2 be two admissible and consistent heuristics such that for all nodes N: h 1 (N)  h 2 (N). Then, every node expanded by A* using h 2 is also expanded by A* using h 1. h 2 is more informed than h 1 h2 dominates h1 Which heuristic for 8-puzzle is better?

37 Complexity of A* Time: exponential Space: can keep all nodes in memory If we want save space, use IDA*

38 Iterative Deepening A* (IDA*) Use f(N) = g(N) + h(N) with admissible and consistent h Each iteration is depth-first with cutoff on the value of f of expanded nodes

39 8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4

40 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6

41 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6 5

42 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6 5 5

43 4 8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=4 6 5 56

44 8-Puzzle 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5

45 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6

46 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 5

47 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 57

48 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 5 7 5

49 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 5 7 55

50 8-Puzzle 4 4 6 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles Cutoff=5 6 5 7 55

51 About Heuristics Heuristics are intended to orient the search along promising paths The time spent computing heuristics must be recovered by a better search After all, a heuristic function could consist of solving the problem; then it would perfectly guide the search Deciding which node to expand is sometimes called meta-reasoning Heuristics may not always look like numbers and may involve large amount of knowledge

52 When to Use Search Techniques? The search space is small, and There are no other available techniques, or It is not worth the effort to develop a more efficient technique The search space is large, and There is no other available techniques, and There exist “good” heuristics

53 Summary Heuristic function Greedy Best-first search Admissible heuristic and A* A* is complete and optimal Consistent heuristic and repeated states Heuristic accuracy IDA*

Download ppt "1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*"

Similar presentations