1 Kuliah 4 : Informed Search
2 Outline Best-First Search Greedy Search A* Search
3 Uninformed (Blind) Search Uninformed (blind) Searches are normally very inefficient. Adding domain knowledge can improve the search process.
4 A Start Goal Suppose we know that node A is very promising Why not expand it right away?
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 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 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 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 Romania with step costs in km
10 Greedy Best-First Search Example Queue: ((Arad 366))
11 Greedy Best-First Search Example Queue: ((Sibiu 253) (Timisoara 329) (Zerind 374)) Now expand Sibiu and add its successors to tree.
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 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 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
15 Example 1 : Road Map Define h(T) = the straight-line distance from T to G DE G S ABC F The estimate can be wrong!
16 Example 2 : 8-puzzle f1(T) = the number correctly placed tiles on the board: f1 =
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 = Most often, ‘distance to goal’ heuristics are more useful !
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 = =
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 What’s wrong with Greedy Search ? Arad Sibiu h = 253 Rimnicu h = 193 Pitesti h = 98 Bucharest h = 0 h = 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 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 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 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 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 8-Puzzle 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 8-Puzzle f(N) = h(N) = number of misplaced tiles Goal
27 8-Puzzle f(N) = g(N) + h(N) with h(N) = number of misplaced tiles
28 D E G S A B C F Exercise From S to G with : Uniform Cost Search Greedy Search A* Search DE G S ABC F Straight line distance
29 Answer : Search Tree S AD BDEA CEEBBF DFBFCEACG GCGF G
30 Uniform Cost SearchSA D B D A E E BBF B FC E A C G G G FC C E D F G At each step, select the node with the lowest accumulated cost. S-D-E-F-G
31 Greedy Search A A D E S BF G S-D-E-F-G
32 AD = = 12.9 S S AD A E = = 12.9 X S AD A E B F = = 13.0 X S AD A E B F G = 13.0 STOP! X A* example: road map Rute : S-D-E-F-G = 13