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

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

of 32

  • date post

    21-Jan-2016
  • Category

    Documents

  • view

    216
  • download

    0

Embed Size (px)

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

  • *Kuliah 4 : Informed Search

  • *OutlineBest-First SearchGreedy SearchA* Search

  • *Uninformed (Blind) SearchUninformed (blind) Searches are normally very inefficient.Adding domain knowledge can improve the search process.

  • *Suppose we know that node A is very promisingWhy not expand it right away?

  • *Informed (Heuristic) SearchExplore 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.

  • *Best-First SearchIdea: use an evaluation function f(n) for each nodeEstimate of desirabilityExpand most desirable unexpanded nodeImplementation: fringe is queue sorted by descreasing order of desirabilityGreedy searchA* search

  • *An Implementation of Best-First Searchfunction BEST-FIRST-SEARCH (problem, eval-fn) returns a solution sequence, or failurequeuing-fn = a function that sorts nodes by eval-fnreturn GENERAL-SEARCH (problem,queuing-fn)

  • *Greedy SearchEstimation function :h(n) = estimate of cost from n to goal (heuristic)For example :hSLD(n) = straight-line distance from n to BucharestGreedy search expands first the node that appears to be closest to the goal, according to h(n).f(n) = h(n)

  • *Romania with step costs in km374329253

  • *Greedy Best-First Search ExampleQueue:((Arad 366))

  • *Greedy Best-First Search ExampleQueue:((Sibiu 253) (Timisoara 329) (Zerind 374))Now expand Sibiu and add its successors to tree.

  • *Greedy Best-First Search ExampleQueue:((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.

  • *Greedy Best-First Search ExampleQueue:((Bucharest 0) (Rimnicu 193) (Sibiu 253) (Timisoara 329) (Arad 366) (Zerind 374) (Oradea 380))Goal generated!Path found isArad Sibiu Fagaras Bucharest

  • *Example 1 : Road MapImagine the problem of finding a route on a road map and that the NET below is the road map:

  • *Example 1 : Road MapDefine h(T) = the straight-line distance from T to G

  • *Example 2 : 8-puzzlef1(T) = the number correctly placed tiles on the board:

  • *Example 2 : 8-puzzlef2(T) = number or incorrectly placed tiles on board:gives (rough!) estimate of how far we are from goal

    Most often, distance to goal heuristics are more useful !

  • *Example 2 : 8-puzzle Manhattan Distancef3(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

    = 1 + 1 + 2 + 2 = 6

  • *Properties of Greedy SearchIt 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(bm), 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(bm). 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.

  • *Whats wrong with Greedy Search ?AradSibiuh = 253Rimnicuh = 193Pitestih = 98Bucharesth = 0h = 366140809921197101Fagaras looks betterto greedy searchthan Rimnicu becauseit doesnt take distance already covered into account!Path through Fagaras has cost 450. Path throughRimnicu has cost 418! Yet, greedy search chose the former.

  • *A* SearchIdea: 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) whereg(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.]

  • *A* in actionSibiu will be expanded next because it has the lowest f.

  • *A* in actionh = 366g = 0f=366

    Sibiuh = 253g = 140f =393Timisoarah = 329g = 118f = 447Zerindh = 374g = 75f = 449AradAradh=366g=380f=646Fagarash = 178g = 239f = 417Oradeah = 380g = 146f = 526Rimnicuh = 193g = 220f = 413Rimnicu willbe expanded next.Example to becontinued in class.Queue:((Rimnicu 413) (Fagaras 417) (Timisoara 447) (Zerind 449) (Oradea 526) (Arad 646))

  • *Properties of A* SearchComplete ? 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 memoryOptimal ? Yes cannot expand fi+1 until fi is finished

  • *8-Puzzle

  • *8-Puzzlef(N) = h(N) = number of misplaced tilesGoal

  • *8-Puzzlef(N) = g(N) + h(N) with h(N) = number of misplaced tiles

  • *ExerciseFrom S to G with : Uniform Cost Search Greedy Search A* SearchStraight line distance

  • *Answer : Search Tree

  • *Uniform Cost SearchAt each step, select the node with the lowest accumulated cost.S-D-E-F-G

  • *Greedy SearchS-D-E-F-G

  • *A* example: road mapRute : S-D-E-F-G = 13

    **