Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Informed search Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html
Shakey (1966-1972) Shakey is a robot which navigates using? a) Dijkstra’s algorithm b) A1 c) A2 d) A* 2
Recap: Search Search problem: States (configurations of the world) Actions and costs Successor function Start state and goal test Search tree: Nodes represent how to reach states Cost of reaching state = sum of action costs Search algorithm: Systematically builds a search tree Chooses an ordering of the fringe Optimal: find least‐cost plans 3
Search Heuristics A heuristic is: a function that estimates how close a state is to a goal non‐trivial (trivial == no real further search required) designed for a particular search problem Examples: Manhatten distance Euclidean distance 4
Search Heuristics A heuristic is: easy to compute, ‘on the fly’: otherwise overhead of computing the heuristic could outweigh time saved by reducing search! Why not pre‐compute and store? huge state space dynamic goal state 5
Heuristic search (outline) Best‐first search – G REEDY SEARCH – A * search Heuristic functions Local search algorithms – Hill‐climbing search – Simulated annealing search – Local beam search – Genetic algorithms 6
Best-first search T REE /G RAPH ‐ SEARCH with an evaluation function f(n) for each node n – estimate of "desirability" Expand most desirable unexpanded node Should direct search toward goal Implementation: Order the nodes in fringe in decreasing order of desirability f(n) Finds best solution, according to evaluation function Special cases: Both also use heuristic h(n) with – G REEDY SEARCH • h(n) ≥ 0 for all n – A * search • h(n) = 0 for state[ n ] = goal 7
Romania with step costs in km and straight‐line distances between city map‐coordinates 8
G REEDY SEARCH Evaluation function f(n) = h(n) where – heuristic h(n) = estimated cost from n to goal e.g., h SLD (n) = straight‐line distance from n to Bucharest Note: h SLD (n) ≥ 0 for all n; h SLD (Bucharest) = 0 G REEDY SEARCH expands the node that appears to be closest to goal Goal‐test: upon generation == upon expansion 9
G REEDY SEARCH example f(Arad) = h sld (Arad) = 366 Expand Arad 10
G REEDY SEARCH example 11
G REEDY SEARCH example 12
G REEDY SEARCH example Done, or continue? Resembles DFS? 13
Properties of G REEDY SEARCH Complete? TREE‐SEARCH : No; 1 GRAPH‐SEARCH : Yes (in finite state spaces) Optimal? No Time? O(b m ) (but a good heuristic can give dramatic improvement) Space? O(b m ) (keeps all nodes in memory) Properties similar to DFS without space benefit; behaviour not necessarily 1 consider e.g. finding a path from Neamt to Fagaras with SLD heuristic, then Iasi Neamt Iasi Neamt … since from Iasi neighbour Neamt is closer to Fagaras than neighbour Vaslui 14
G REEDY SEARCH Note(!) G REEDY SEARCH is a variant of best‐first search; it is indeed a very greedy search algorithm, but not every greedy approach to searching is the same as G REEDY SEARCH . 15
A * search Combines benefits of greedy best‐first search and uniform‐cost search Evaluation function f(n) = g(n) + h(n) where – g(n) = cost so far to reach n (= path cost; dynamic) – h(n) = estimated cost from n to goal (= static heuristic ) f(n) = estimated total cost of path through n to goal A * search avoids expanding paths that are already expensive Goal‐test upon expansion ! 16
A * search example f(Arad) = g(Arad) + h sld (Arad) = 0 + 366 Expand Arad 17
A * search example min g(n) Expand n with minimal f(n) 18
A * search example min g(n) Expand n with minimal f(n) 19
A * search example min g(n) Expand n with minimal f(n) 20
A * search example min g(n) Done, or continue? For Bucharest: f(n) <> min f(n) g(n) <> min g(n) h(n) = 0 21
A * search example min g(n) Done, or continue? For Bucharest: f(n) = min f(n) g(n) <> min g(n) h(n) = 0 A * vs Dijkstra: https://www.youtube.com/watch?v=g024lzsknDo 22
Admissible heuristics Definition: a heuristic h(n) is admissible if h(n) ≤ h * (n) for every node n where h * (n) is the optimal heuristic, i.e. gives true cost to reach the goal state from n . An admissible heuristic never overestimates the actual cost to reach the goal, i.e., it is optimistic (property transfers to f(n) ) Example: h SLD (n) (never overestimates the actual road distance) Theorem: If h(n) is admissible then A * using TREE‐SEARCH is optimal 23
Optimality of A * (proof tree) Consider: Optimal goal G A fringe with (generated, but not yet expanded ): – suboptimal goal G 2 – node n, on a shortest path to G To prove: G 2 will never be expanded before n . First we show that f(G 2 ) > f(G): 1) f(G) = g(G) since h(G) = 0 2) f(G 2 ) = g(G 2 ) since h(G 2 ) = 0 3) g(G 2 ) > g(G) G 2 suboptimal, so higher (path) costs f(G 2 ) > f(G) from 1—3) 24
Optimality of A * (proof-cntd) Recall: G optimal; fringe with suboptimal G 2 and n on shortest path to G To prove: G 2 will never be expanded before n . Established: f(G 2 ) > f(G) Next we show that f(G 2 ) > f(n): 1) h(n) ≤ h*(n) assumption h is admissible ↔ h(n) + g(n) ≤ h * (n) + g(n) add g(n) to both sides ↔ f(n) ≤ g(G) n on shortest path to G; def f 2) f(G) = g(G) + 0 h(G) = 0; def f f(G) ≥ f(n) 1,2 Hence f(G 2 ) > f(n) , and A * will never select G 2 for expansion 25
Consistent heuristics A heuristic is consistent (or monotonic) if for every node n and every successor n' of n, generated by any action a : h(n) ≤ c(n,a,n') + h(n') where c(n,a,n') is the step cost If h is consistent, we have f(n') = g(n') + h(n') (def) = g(n) + c(n,a,n') + h(n') ≥ g(n) + h(n) (consistent) = f(n) (def) i.e., f(n) is non‐decreasing along any path. Intuition: h should be optimistic, but not to the extent that total costs f can drop by taking a next step 26
Optimality of A * (again) Theorem: If h(n) is consistent, A * using GRAPH‐SEARCH is optimal A * expands nodes in order of increasing f value Gradually adds " f ‐contours" of nodes Contour f c has all nodes n with f(n) ≤ c Contours f 380 f 400 f 420 27
Properties of A* Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) = f * ) Optimal? Yes (if heuristic is consistent (GRAPH) /admissible (TREE) ) Time? Exponential in d Space? Keeps all nodes in memory 28
Admissible heuristics Recall the properties of (admissible) heuristic h : h(goal node) = 0 0 ≤ h(n) ≤ h*(n) for every node n (admissible: should never overestimate!) E.g., two common heuristics for the 8‐puzzle: h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile (only horizontal and vertical moves!!))) h 1 (Start) = ? h 2 (Start) = ? 29
Admissible heuristics E.g., two common heuristics for the 8‐puzzle: h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance h 1 (Start) = 8 h 2 (Start) = 3+1+2+2+2+3+3+2 = 18 30
Which is better? - Dominance If h 2 (n) ≥ h 1 (n) for all n (and both admissible) then h 2 dominates h 1 h 2 is better for search Typical search costs (average number of nodes expanded over 100 instances of 8‐puzzle per solution length d ): d=12 IDS = 3,644,035 nodes A * ( h 1 ) = 227 nodes A * ( h 2 ) = 73 nodes d=24 IDS = too many nodes A * ( h 1 ) = 39,135 nodes A * ( h 2 ) = 1,641 nodes 31
Good heuristics h*(n) ≥ h(n) ≥ 0 for all n ( h is admissible) The closer h is to h*, the less nodes are kept open for search (more efficient) If h(n)=h(n)* for all n then A* leads direct to optimal solution without search If h(n)=0 for all n then A* is uniform cost search (= Dijkstra’s algorithm + goal test) However, if h is not admissible then optimal solution can be missed! 32
Relaxed problems Relaxed problem: a problem with fewer restrictions on the actions E.g. allow moves to occupied slots in 8‐puzzle The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem If the rules of the 8‐puzzle are further relaxed so that a tile can move anywhere in one step h 1 (n) gives the best (shortest) solution a tile can move to any adjacent square h 2 (n) gives the shortest solution 33
Variations on A* Hierarchical A* IDA* (Iterative Deepening A*) SMA* (Simplified Memory‐bounded A*) Specific for dynamic environments: LPA* (Lifelong Planning A*) D* (A* for dynamic goals) 34
Summary best-first search Similar to uninformed search: T REE /G RAPH ‐ SEARCH goal‐test step & path costs solution = (least‐cost) path through state‐ space more problem specific ingredients (beyond definition of problem): Heuristic function h(n) Evaluation function f(n) 35
Recommend
More recommend