Intuitions behind Heuristic Search TDDC17 Separation property of graph search Systematic Search through the state space Seminar 3 Search II: Informed Search Algorithms (Ch 3) Find a heuristic measure h(n) which estimates how close Search in Complex Environments (Ch 4) a node n in the frontier is to the nearest goal state and then order the frontier queue accordingly relative to closeness. The evaluation function f(n) , previously discussed will include h(n): Patrick Doherty Dept of Computer and Information Science f(n) = .... + h(n) Artificial Intelligence and Integrated Computer Systems Division h(n) is intended to provide domain specific hints about location of goals 1 2 Greedy Best-First Search Recall Best-First Search Evaluation function: f(n) Evaluation function: f(n) GREEDY-BEST-FIRST-SEARCH Minimum of f(n) first Minimum of f(n) first Different evaluation functions f(n), will generate different algorithms Greedy Best-First Search: f(n) = h(n) f(n) = .... + h(n) Heuristic SearchAlgorithms: Don’t care about anything except how close a node is to a goal! 3 4
Romania Travel Problem Greedy Best-First Search: Romania Arad[366] 1 Let’s find a heuristic! goto(Sibiu) Straight line distance from city n to goal city n’ Zerind[374] Timisoara[329] Sibiu[253] 2 goto(Fagaras) Assume the cost to get somewhere is a function of the distance traveled Riminicu Oradea[380] Fagaras[176] Vilcea[193] 3 h SLD() Straight line distance to h SLD() Straight line distance to goto(Bucharest) Bucharest from any city Bucharest from any city Bucharest[0] Heuristic: f(n) = h SLD (n) Notice the SLD under estimates the actual cost! 5 6 Is Greedy Best-First Search Cost-Optimal? Is Greedy Best-First Search Complete? Arad[366] 1 • GBF (Graph search) is goto(Sibiu) complete in finite spaces but 140 not in infinite spaces Zerind[374] Timisoara[329] Sibiu[253] • GBF (Tree-like search) is not 2 even complete in finite spaces. goto(Fagaras) 99 Consider going from Iasi to Fagaras? Oradea[380] Riminicu Fagaras[176] Vilcea[193] 3 Neamt is chosen 1st because h(Neamt) is closer than h(Vaslui) , but Neamt is a goto(Bucharest) 211 dead-end. Expanding Neamt still puts Iasi 1st on the frontier again since h(Iasi) is closer than h(Vaslui) ...which puts Neamt 1st again! Bucharest[0] No, the actual costs: Path Chosen: Arad-Sibiu-Fagaras-Bucharest = 450 GBF (Graph Search): Time/Space Complexity: O (|V|) • Optimal Path: Arad-Sibiu-Rimnicu Vilcea-Pitesti-Bucharest = 418 GBF (Tree-Like Search): Time/Space Complexity: O (b m ) • With good heuristics, complexity can be reduced substantially • The search cost is minimal but * m -maximum length of any path in not optimal! What’s missing? the search space (possibly infinite) 7 8
A* (Graph)Search Improving Greedy Best-First Search Evaluation function: f(n) Greedy Best-First Search chooses A*-SEARCH Greedy Best-First Search finds a goal any goal node without concerning as fast as possible by using the h(n) Minimum of f(n) first itself with the shallowness of the goal function to estimate n ’s closeness to node or the cost of getting to n in the the goal. 1st place. Rather than choosing a node based just on distance to the goal we could include a quality notion such as expected depth of the nearest goal g(n) - the actual cost of getting to node n h(n) - the estimated cost of getting from n to a goal state f(n) = g(n) + h(n) f(n) is the estimated cost of the cheapest solution through n Note: This algorithm only works as is, if f(n) = g(n) + h(n) the heuristic function h(n) is consistent. More on this soon. 9 10 A*-1 A*-2 g(Arad)+h(Arad) Heuristic (with Bucharest as goal): f(n) = g(n) + h(n) g(n) - Actual distance from root node to n h(n) - h SLD (n) straight line distance from n to Bucharest h(n) = h SLD (n) h(n) = h SLD (n) g(n) Straight line distance to g(n) Straight line distance to Bucharest from any city Bucharest from any city 11 12
A*-3 A*-4 h(n) = h SLD (n) h(n) = h SLD (n) g(n) Straight line distance to g(n) Straight line distance to Bucharest from any city Bucharest from any city 13 14 A*-4 A*-6 Place in frontier Expand Late Testing Goal h(n) = h SLD (n) h(n) = h SLD (n) g(n) Straight line distance to g(n) Straight line distance to Bucharest from any city Bucharest from any city 15 16
Admissibility Consistency An admissible heuristic is one that never overestimates the h ( n ) n A consistent heuristic is a non-negative function on a node cost to reach a goal (It is optimistic) h ( n ) ≤ cost ( n , n ′ ) + h ( n ′ ) that satisfies the constraint: n n ′ cost ( n , n ′ ) for any two nodes and , where is the cost of the h(n) takes a node n and returns a non-negative real number that is an estimate of the cost of the least-cost path from node n to a goal node n n ′ least-cost path from to . h(n) is an admissible heuristic, if h(n) is always less than or equal to n The estimated cost of going from to a goal should not be the actual cost of a least-cost path from node n to a goal. n ′ more than the estimated cost of first going to and then to a goal Admissibility does not ensure that every intermediate node selected from the frontier is on an optimal path from the start node to the goal node. It h ( n ) may change its mind about which partial path is best while searching and g n the frontier may include multiple paths to the same state. This implies that the A* (graph) search algorithm cost ( n , n ′ ) h ( n ′ ) n ′ f ( n ) = g ( n ) + h ( n ) may not be cost-optimal for A* with , h ( n ) where is admissible. Additional bookkeeping is required. A*(tree-like) search is cost-optimal, but is less efficient. Admissibility with A*(tree-like) search does ensure that Triangle inequality first solution found will be cost-optimal 17 18 Consistency/ Monotonicity A* Proof of Optimality (Tree-like Search) Consistency is guaranteed if the heuristic function satisfies A* using (Tree-Like) SEARCH is cost Start the monotone restriction : h ( n ) ≤ c ( n , a , n ′ ) + h ( n ′ ), ∀ a , n , n ′ optimal if h(n) is admissible n Easier to check than consistency: Just check arcs in state space Proof: graph rather than all pairs of states. G G 2 Assume the cost of the optimal solution is C*. h ( n ) If is a consistent heuristic then it is Suppose a suboptimal goal node appears on the fringe. G 2 also an admissible heuristic See example: Since is suboptimal and h( )=0 ( is a goal node), G 2 G 2 G 2 n = Pitesti (417) f ( G 2 ) = g ( G 2 ) + h ( G 2 ) = g ( G 2 ) > C * Consistency/Monotonicity guarantees: G 2 = Bucharest (450) f -paths selected from the frontier are monotonically non-decreasing Now consider the fringe node n that is on an optimal solution • path. If h(n) does not over-estimate the cost of completing the ( f -values do not get smaller) solution path then f ( n ) = g ( n ) + h ( n ) ≤ C * First time we reach a state on the frontier it will be on an optimal path, so • We never need to re-add a state to the frontier • Then f ( n ) ≤ C * ≤ f ( G 2 ) We never need to change an entry in reached • So, G 2 will not be expanded and A* is optimal! This implies that the A* (graph) search algorithm f ( n ) = g ( n ) + h ( n ) h ( n ) can be used for A* with , where is consistent. 19 20
Optimality of A* (Graph Search) A* Proof of Optimality (Graph Search) A* using GRAPH-SEARCH is cost- optimal Steps to show in the proof: if h ( n ) is consistent (monotonic) • If h(n) is consistent, then the values f(n) along any path are non-decreasing Step Cost • Whenever A* selects a node n for expansion from the frontier, the optimal path to that node has been found h ( n ) is consistent h ( n ) ≤ c ( n , a , n ′ ) + h ( n ′ ), ∀ a , n , n ′ n As one extends a path from to n n ′ If this is the case, the values along any path are non-decreasing f ( n ) ≤ f ( n ′ ) this assures that : and A* fans out in concentric bands of increasing f-cost Step cost: c ( n , a , n ′ ) g ( n ) + h ( n ) ≤ g ( n ) + c ( n , an ′ ) + h ( n ′ ) h ( n ) … n k n n ′ … successors( ): Map of Romania showing contours at h ( n ′ ) f=380, f=400, and f=420 with Arad as Triangle inequality G n :Goal node closest to n start state. Nodes inside a given contour argument: have f-costs < or = to the contour value. Length of a side of a triangle is always less than the sum of the G n n f ( n ) Estimated cost of getting to from : , can not be more than other two. n G n f ( n ′ ) going through a successor of to : , otherwise it would violate the property that h ( n ) is a lower bound on the cost to reach G n 21 22 Some properties of A* Finding Admissible Heuristics • Cost-Optimal - for a given admissible heuristic (every h(n) is an admissible heuristic if it never over- consistent heuristic is also an admissible heuristic) estimates the cost to reach the goal from n . • Complete - Eventually reach a contour equal to the path of the least-cost to the goal state. Admissible Heuristics are optimistic because they always • Optimally efficient - No other algorithm, that extends think the cost of solving a problem is less than it actually is. search paths from a root is guaranteed to expand fewer nodes than A* for a given heuristic function. The 8 Puzzle • The exponential growth for most practical heuristics will eventually overtake the computer (run out of memory) • The number of states within the goal contour is still exponential in the length of the solution. • There are variations of A* that bound memory.... How would we choose an admissible heuristic for this problem? 23 24
Recommend
More recommend