Download presentation
Presentation is loading. Please wait.
Published byAmber Brooks Modified over 9 years ago
1
Informed Search I (Beginning of AIMA Chapter 4.1)
CIS 391 Fall 2008
2
Today!! Outline A* - Optimal Search using Knowledge
PART I Informed = use problem-specific knowledge Best-first search and its variants A* - Optimal Search using Knowledge Proof of Optimality of A* A* for maneuvering AI agents in games Heuristic functions? How to invent them PART II Local search and optimization Hill climbing, local beam search, genetic algorithms,… Local search in continuous spaces Online search agents Today!! CIS Intro to AI
3
Breadth First Search for Games, Robots, …
Pink: Starting Point Blue: Goal Teal: Scanned squares Darker: Closer to starting point… Graphics from (A great site for practical AI & game Programming CIS Intro to AI
4
An optimal informed search algorithm
We add a heuristic estimate of distance to the goal Yellow: examined nodes with high estimated distance Blue: examined nodes with low estimated distance CIS Intro to AI
5
Breadth first in a world with obstacles
CIS Intro to AI
6
Informed search in a world with obstacles
CIS Intro to AI
7
Is Uniform Cost Search the best we can do
Is Uniform Cost Search the best we can do? Consider finding a route from Bucharest to Arad.. Arad 118 CIS Intro to AI
8
A Better Idea… Node expansion based on some estimate of distance to the goal, extending current path General approach of informed search: Best-first search: node is selected for expansion based on an evaluation function f(n) Implementation: Sort fringe queue in decreasing order of desirability. Special cases: greedy search, A* search CIS Intro to AI
9
Romania with city-to-city distances & straight-line distances in km
Arad 118 Romania with city-to-city distances & straight-line distances in km CIS Intro to AI
10
A heuristic function Let evaluation function f(n) = h(n) (heuristic) h(n) = estimated cost of the cheapest path from node n to goal node. If n is goal then h(n)=0 Here: hSLD(n) = straight-line distance from n to Bucharest [dictionary]“A rule of thumb, simplification, or educated guess that reduces or limits the search for solutions in domains that are difficult and poorly understood.” Heuristic knowledge is useful, but not necessarily correct. Heuristic algorithms use heuristic knowledge to solve a problem. A heuristic function here takes a state and returns an estimate of the distance to the goal. Heureka! ---Archimedes CIS Intro to AI
11
Greedy best-first search (BFS)
Expands the node that appears to be closest to goal Expands nodes based on f(n) = h(n) (Again, h(n)): Some heuristic estimate of cost from n to goal) Ignores cost so far to get to that node (g(n)) Here, h(n) = hSLD(n) = straight-line distance from n to Bucharest CIS Intro to AI
12
Greedy best-first search example
Open queue: Arad Initial State = Arad Goal State = Bucharest CIS Intro to AI
13
Greedy best-first search example
Open queue: Sibiu Timisoara Zerind CIS Intro to AI
14
Greedy best-first search example
Open queue: Fararas Rimnicu Vilcea Timisoara Arad Zerind Oradea CIS Intro to AI
15
Greedy best-first search example
Open queue: Bucharest Rimnicu Vilcea Timisoara Sibiu Arad Zerind Oradea Goal reached !! CIS Intro to AI
16
Properties of greedy best-first search
Optimal? No! Found: Arad Sibiu Fagaras Bucharest (450km) Shorter: Arad Sibiu Rimnicu Vilcea Pitesti Bucharest (418km) Arad 118 CIS Intro to AI
17
Properties of greedy best-first search
Complete? No – can get stuck in loops, e.g., Iasi Neamt Iasi Neamt … Initial Goal CIS Intro to AI
18
Properties of greedy best-first search
Complete? No – can get stuck in loops, e.g., Iasi Neamt Iasi Neamt Time? O(bm) – worst case (like Depth First Search) But a good heuristic can give dramatic improvement Space? O(bm) – keeps all nodes in memory Optimal? No CIS Intro to AI
19
A* search Implementation: Expand the node n with minimum f(n)
Best-known form of best-first search. Key Idea: avoid expanding paths that are already expensive. Evaluation function f(n)=g(n) + h(n) g(n) the cost (so far) to reach the node h(n) estimated cost to get from the node to the goal f(n) estimated total cost of path through n to goal Implementation: Expand the node n with minimum f(n) CIS Intro to AI
20
Admissible heuristics
h(n) must be an admissible heuristic A heuristic is admissible if it never overestimates the cost to reach the goal; i.e. it is optimistic Formally: n, where n is a node: h(n) h*(n) where h*(n) is the true cost from n h(n) 0 so h(G)=0 for any goal G. Example: hSLD(n) never overestimates the actual road distance Theorem: If h(n) is admissible, A* using Tree Search is optimal CIS Intro to AI
21
A* search example Open queue: Arad We start with our initial state Arad. We make a node and add it to the open queue. Since it’s the only thing on the open queue, we expand the node. Implementation: The open queue is just a priority queue (or heap) that sorts the nodes inside of it according to their g()+h() score. CIS Intro to AI
22
A* search example We add the three nodes we found to the open queue.
Sibiu Timisoara Zerind We add the three nodes we found to the open queue. We sort them according to the g()+h() calculation. CIS Intro to AI
23
A* search example Open queue: Rimricu Vicea Fagaras Timisoara Zerind Arad Oradea When we expand Sibiu, we run into Arad again. Note that we’ve already expanded this node once; but we still add it to the open queue again. CIS Intro to AI
24
A* search example Open queue: Rimricu Vicea Fagaras Timisoara Zerind Arad Oradea We see that Rimricu Vicea is at the top of the open queue; so, it’s the next node we will expand. CIS Intro to AI
25
A* search example We expand Rimricu Vicea. Open queue: Fagaras Pitesti
Timisoara Zerind Craiova Sibiu Arad Oradea We expand Rimricu Vicea. CIS Intro to AI
26
A* search example Open queue: Fagaras Pitesti Timisoara Zerind Craiova Sibiu Arad Oradea Fagaras will be the next node we should expand – it’s at the top of the sorted open queue. CIS Intro to AI
27
A* search example Open queue: Pitesti Timisoara Zerind Bucharest Craiova Sibiu Arad Oradea When we expand Fagaras, we find Bucharest, but we’re not done. The algorithm doesn’t end until we “expand” the goal node – it has to be at the top of the open queue. CIS Intro to AI
28
A* search example Open queue: Pitesti Timisoara Zerind Bucharest Craiova Sibiu Arad Oradea It looks like Pitesti is the next node we should expand. CIS Intro to AI
29
A* search example Open queue: Bucharest Timisoara Zerind Craiova Rimricu Vicea Sibiu Arad Oradea Note that we just found a better value for Bucharest! We also found a worse value for Craiova. CIS Intro to AI
30
A* search example Open queue: Bucharest Timisoara Zerind Craiova Rimricu Vicea Sibiu Arad Oradea Now it looks like Bucharest is at the top of the open queue… CIS Intro to AI
31
A* search example Now we “expand” the node for Bucharest.
Open queue: Bucharest Timisoara Zerind Craiova Rimricu Vicea Sibiu Arad Oradea Now we “expand” the node for Bucharest. We’re done! (And we know the path that we’ve found is optimal.) CIS Intro to AI
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.