Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.

Similar presentations


Presentation on theme: "1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search."— Presentation transcript:

1 1 Kuliah 4 : Informed Search

2 2 Outline Best-First Search Greedy Search A* Search

3 3 Uninformed (Blind) Search Uninformed (blind) Searches are normally very inefficient. Adding domain knowledge can improve the search process.

4 4 A 3 2 1 Start Goal Suppose we know that node A is very promising Why not expand it right away?

5 5 Informed (Heuristic) Search Explore the node that is most “likely” to be the nearest to a goal state. Informed search algorithms choose the next node to expand using an evaluation function that estimates the merit of expanding the node. To focus search, the evaluation function must incorporate some heuristic that estimates the cost of the path from a state to the closest goal state.

6 6 Best-First Search Idea: use an evaluation function f(n) for each node Estimate of desirability Expand most desirable unexpanded node Implementation: fringe is queue sorted by descreasing order of desirability Greedy search A* search

7 7 An Implementation of Best-First Search function BEST-FIRST-SEARCH (problem, eval-fn) returns a solution sequence, or failure queuing-fn = a function that sorts nodes by eval-fn return GENERAL-SEARCH (problem,queuing-fn)

8 8 Greedy Search Estimation function : h(n) = estimate of cost from n to goal (heuristic) For example : h SLD (n) = straight-line distance from n to Bucharest Greedy search expands first the node that appears to be closest to the goal, according to h(n). f(n) = h(n)

9 9 Romania with step costs in km 374 329 253

10 10 Greedy Best-First Search Example Queue: ((Arad 366))

11 11 Greedy Best-First Search Example Queue: ((Sibiu 253) (Timisoara 329) (Zerind 374)) Now expand Sibiu and add its successors to tree.

12 12 Greedy Best-First Search Example Queue: ((Fagaras 178) (Rimnicu 193) (Timisoara 329) (Arad 366) (Zerind 374) (Oradea 380)) Fagaras has the lowest h, so it is the next node to be expanded.

13 13 Greedy Best-First Search Example Queue: ((Bucharest 0) (Rimnicu 193) (Sibiu 253) (Timisoara 329) (Arad 366) (Zerind 374) (Oradea 380)) Goal generated! Path found is Arad  Sibiu  Fagaras  Bucharest

14 14 Example 1 : Road Map Imagine the problem of finding a route on a road map and that the NET below is the road map: D E G S A B C F 4 4 4 4 3 3 2 5 5

15 15 Example 1 : Road Map Define h(T) = the straight-line distance from T to G DE G S ABC F 4 6.7 10.4 11 8.4 6.9 3 The estimate can be wrong!

16 16 Example 2 : 8-puzzle f1(T) = the number correctly placed tiles on the board:1324 765 8 f1 = 4 1234 567 8

17 17 Example 2 : 8-puzzle f2(T) = number or incorrectly placed tiles on board: gives (rough!) estimate of how far we are from goal f2 = 4 132 4 765 8 Most often, ‘distance to goal’ heuristics are more useful ! 1234 567 8

18 18 Example 2 : 8-puzzle Manhattan Distance f3(T) = the sum of ( the horizontal + vertical distance that each tile is away from its final destination): gives a better estimate of distance from the goal node f3 = 1 + 1 + 2 + 2 = 6 1324 765 8 1234 567 8

19 19 Properties of Greedy Search It is not complete. Can get stuck in loops. Complete if search space is finite and there are checks for repeated states. It is not optimal. Time complexity: O(b m ), where b is the branching factor and m is the max depth of the search space. Same worst-case time complexity as depth-first. Space complexity: O(b m ). Keeps all nodes in memory. Worse than O(bm) for depth- first. Actual performance of greedy search is a function of the accuracy of h.

20 20 What’s wrong with Greedy Search ? Arad Sibiu h = 253 Rimnicu h = 193 Pitesti h = 98 Bucharest h = 0 h = 366 140 80 99 211 97 101 Fagaras looks better to greedy search than Rimnicu because it doesn’t take distance already covered into account! Path through Fagaras has cost 450. Path through Rimnicu has cost 418! Yet, greedy search chose the former.

21 21 A* Search Idea: Avoid expanding paths that are already expensive. Uses estimated total cost, f(n), of the cheapest solution path through node n, as a measure of the merit of node n. Thus, f(n) is the evaluation function for A*. f(n) = g(n) + h(n) where g(n) = path cost from start node to node n. h(n) = estimated cost of path from n to closest goal node. This must NEVER overestimate the actual cost. [Note, if h(n) = 0 this is uniform-cost search.]

22 22 A* in action h = 366 g = 0 f=366 Sibiu h = 253 g = 140 f = 393 Timisoara h = 329 g = 118 f = 447 Zerind h = 374 g = 75 f = 449 Arad Queue: ((Sibiu 393) (Timisoara 447) (Zerind 449)) Queue: ((Arad 366)) Sibiu will be expanded next because it has the lowest f.

23 23 A* in action h = 366 g = 0 f=366 Sibiu h = 253 g = 140 f =393 Timisoara h = 329 g = 118 f = 447 Zerind h = 374 g = 75 f = 449 Arad h=366 g=380 f=646 Fagaras h = 178 g = 239 f = 417 Oradea h = 380 g = 146 f = 526 Rimnicu h = 193 g = 220 f = 413 Rimnicu will be expanded next. Example to be continued in class. Queue: ((Rimnicu 413) (Fagaras 417) (Timisoara 447) (Zerind 449) (Oradea 526) (Arad 646))

24 24 Properties of A* Search Complete ? Yes, unless infinitely many nodes with f  f(G) Time ?Exponential in [(relative error in h) x (length of solution)] Space ?Keeps all nodes in memory Optimal ? Yes – cannot expand f i+1 until f i is finished

25 25 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

26 26 8-Puzzle 4 5 5 3 3 4 34 4 21 2 0 3 4 3 f(N) = h(N) = number of misplaced tiles Goal

27 27 8-Puzzle 0+4 1+5 1+3 3+3 3+4 3+24+1 5+2 5+0 2+3 2+4 2+3 f(N) = g(N) + h(N) with h(N) = number of misplaced tiles

28 28 D E G S A B C F 4 4 4 4 3 3 2 5 5 Exercise From S to G with : Uniform Cost Search Greedy Search A* Search DE G S ABC F 4 6.7 10.4 11 8.9 6.9 3 Straight line distance

29 29 Answer : Search Tree S AD BDEA CEEBBF DFBFCEACG GCGF G 3 33 3 3 2 2 2 4 4 44 4 4 4 4 4 4 4 4 55 55 5 5

30 30 Uniform Cost SearchSA D B D A E E BBF B FC E A C G G G FC 3 4 4 5 5 5 2 5 4 3 3 4 7 8 9 6 1011 C E D F G 4 5 111213 13 13 4 At each step, select the node with the lowest accumulated cost. S-D-E-F-G

31 31 Greedy Search A A D E S BF G 10.4 8.4 10.4 6.9 3.0 6.7 S-D-E-F-G

32 32 AD 3 + 10.4 = 13.4 4 + 8.9 = 12.9 S S AD A E 13.4 9 + 10.4 = 19.4 6 + 6.9 = 12.9 X S AD A E B F 13.4 11 + 6.7 = 17.7 10 + 3.0 = 13.0 X S AD A E B F 13.4 17.7 G 13 + 0.0 = 13.0 STOP! X A* example: road map Rute : S-D-E-F-G = 13


Download ppt "1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search."

Similar presentations


Ads by Google