Download presentation
Presentation is loading. Please wait.
Published byNorma Stevenson Modified over 9 years ago
1
Heuristic State Space Seach Henry Kautz
2
Assignment
3
Kinds of State-Space Search Problems The goal is fully specified. Only the path to it needs to be found and returned. –Route planning Can test if a state is a goal, but we do not know what it will be in advance. The path to the goal is not needed. –Crossword puzzles Goal test only, path matters. –General STRIPS planning
4
Dijkstra’s Algorithm: One-to-All Shortest Paths in a Weighted Graph for each node do node.dist = ; end; start.dist := 0; insert(start, 0, heap); while (! empty(heap)) do node := deleteMin(heap); for each edge do if (node.dist + length < child.dist) then child.dist = node.dist + length; if (child is in the heap) then decreaseKey(child, child.dist, heap); else insert(child, child.dist, heap); end
5
Recording the Paths for each node do node.dist = ; end; start.dist := 0; insert(start, 0, heap); while (! empty(heap)) do node := deleteMin(heap); for each edge do if (node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist, heap); else insert(child, child.dist, heap); end
6
Shortest Paths to a Goal for each node do node.dist = ; end; start.dist := 0; insert(start, 0, heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist, heap); else insert(child, child.dist, heap); end return FAIL;
7
Generating Nodes on the Fly start.dist := 0; insert(start, 0, heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist, heap); else insert(child, child.dist, heap); end return FAIL;
8
Problem: Large Graphs It is expensive to find optimal paths in large graphs, using BFS, IDFS, or Dijkstra’s algorithm How can we search large graphs efficiently by using “commonsense” about which direction looks most promising?
9
Example 52 nd St 51 st St 50 th St 10 th Ave 9 th Ave 8 th Ave 7 th Ave6 th Ave5 th Ave4 th Ave 3 rd Ave 2 nd Ave S G 53 nd St Plan a route from 9 th & 50 th to 3 rd & 51 st
10
Example 52 nd St 51 st St 50 th St 10 th Ave 9 th Ave 8 th Ave 7 th Ave6 th Ave5 th Ave4 th Ave 3 rd Ave 2 nd Ave S G 53 nd St Plan a route from 9 th & 50 th to 3 rd & 51 st
11
Best-First Search The Manhattan distance ( x+ y) is an estimate of the distance to the goal –It is a heuristic h(state) Best-First Search –Order nodes in priority to minimize estimated distance to the goal Compare: BFS / Dijkstra –Order nodes in priority to minimize distance from the start
12
Best-First Search start.dist := 0; insert(start, h(start), heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, h(child), heap); else insert(child, h(child), heap); end return FAIL;
13
Non-Optimality of Best-First Search 52 nd St 51 st St 50 th St 10 th Ave 9 th Ave 8 th Ave 7 th Ave6 th Ave5 th Ave4 th Ave 3 rd Ave 2 nd Ave SG 53 nd St Path found by Best-first Shortest Path
14
Improving Best-First Best-first is usually much faster than BFS/Dijkstra, but might stop with a non-optimal solution How can it be modified to be guaranteed to find optimal solutions? A* (Hart, Nilsson, Raphael 1968) –One of the first significant algorithms developed in AI –Widely used in many applications
15
A* Criteria for the priority queue: minimize (distance from start) + (estimated distance to goal) priority f(n) = g(n) + h(n) f(n) = priority of a node g(n) = true distance from start h(n) = heuristic distance to goal
16
Optimality of A* Suppose the estimated distance is always less than or equal to the true distance to the goal –Heuristic is a lower bound –Heuristic is admissible Then: when the goal is removed from the priority queue, we are guaranteed to have found a shortest path –Note: same is true for Dijkstra
17
A* in Action 52 nd St 51 st St 50 th St 10 th Ave 9 th Ave 8 th Ave 7 th Ave6 th Ave5 th Ave4 th Ave 3 rd Ave 2 nd Ave SG 53 nd St f=6+2 f=1+7 f=7+3
18
A* Search start.dist := 0; insert(start, h(start), heap); while (! empty(heap)) do node := deleteMin(heap); if GoalTest(node) then return node; for each edge do if (child is new or node.dist + length < child.dist) then child.dist = node.dist + length; child.prev = node; if (child is in the heap) then decreaseKey(child, child.dist+h(child), heap); else insert(child, child.dist+h(child), heap); end return FAIL;
19
Maze Runner
20
Observations on A* Perfect heuristic: If h(n) = h*(n) (true distance) for all n, then only the nodes on the optimal solution path will be expanded. Null heuristic: If h(n) = 0 for all n, then this is an admissible heuristic and A* acts like BFS/Dijkstra. Comparing heuristics: If h1(n) < h2(n) h*(n) for all non-goal nodes, then h2 is a better heuristic than h1 –Every node expanded by A* using h2 is also expanded by A* using h1 –h2 is stronger than h1
21
Memory Use in A* A*’s main disadvantage is memory consumption –Once a node is generated, it is always kept in memory Memory-bounded A* –Limits amount of memory used –Tradeoff: sometimes will re-generate parts of the search tree –Tricky part: guaranteeing optimality
22
Search Heuristics “Optimistic guess” at distance to a solution Some heuristics are domain specific –Manhattan distance for grid-like graphs –Euclidean distance for general road maps –Rubik’s Cube Admissible, but weak: # cubits out of place / 8 Better: MAX( Sum( Manhattan distance edge cubits )/4, Sum( Manhattan distance corner cubits )/4 )
23
Planning Heuristics Good general heuristics for planning can be created by relaxing the operators –Eliminate preconditions –Eliminate negative preconditions & effects Use the length of the solution to the relaxed problem as a heuristic for the length of the solution to the original problem
24
Length of Precondition-free Solution?
25
Other General Techniques Plan for each goal separately (recursively), take MAX of sub-solution lengths –Admissible, but weak Plan for each goal separately (recursively), take SUM of sub-solution lengths –Non-admissible, but often useful Recursively compute set of facts which can be pairwise achieved –Admissible, polynomial time –FF (Hoffmann 2002), winner, 3 rd International Planning Competition (STRIPS Track)
26
Search and Reasoning State-space search can be viewed as a special kind of logical reasoning Explicitly representing problems logically, however, has many advantages: –Clarifies thinking –Increased expressivity –Tap into rich set of algorithms for logical inference
27
Reasoning and Search Logical reasoning can be viewed as a special kind of state space search –State = agent’s explicit beliefs –Operator = making a logical deduction Thinking in terms of state space search will help us understand how to create practical inference algorithms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.