CS 106: Artificial Intelligence: Informed Search
CS 106: Artificial Intelligence: Informed Search
Informed Search
▪ Informed Search
▪ Heuristics
▪ Greedy Search
▪ A* Search
▪ Search problem:
▪ States (configurations of the world)
▪ Actions and costs
▪ Successor function (world dynamics)
▪ Start state and goal test
▪ Search tree:
▪ Nodes: represent plans for reaching states
▪ Plans have costs (sum of action costs)
▪ Search algorithm:
▪ Systematically builds a search tree
▪ Chooses an ordering of the fringe (unexplored nodes)
▪ Optimal: finds least-cost plans
Graph Search Pseudo-Code
Uninformed Search
Uniform Cost Search
▪ The bad:
▪ Explores options in every “direction” Start Goal
▪ No information about goal location
10
5
11.2
Example: Heuristic Function
{h(x)} = straight line distance to Ho Chi Minh city.
Greedy Search
▪ A common case:
b
▪ Best-first takes you straight to the (wrong) goal …
Strategy: expand the node with the lowest sum of path cost and estimated cost.
A* Search
UCS Greedy
A*
A* Search
Optimality of A* Tree Search
When should A* terminate?
2 A 2
S h=3 h=0 G
2 B 3
h=1
1 A 3
S h=7
G h=0
▪ Example:
15
A S (0+2)
1
1
S h=4
C
h=1 A (1+4) B (1+1)
h=2 1
2
3 C (2+1) C (3+1)
B
h=1
G G (5+0) G (6+0)
h=0
Tree Search versus Graph Search
Tree Search: Extra Work!
▪ Failure to detect repeated states can cause exponentially more work.
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Tree Search Pseudo-Code
Graph Search Pseudo-Code
Graph Search
▪ Idea: never expand a state twice
▪ How to implement:
▪ Tree search + set of expanded states (“closed set”)
▪ Expand the search tree node-by-node, but…
▪ Before expanding a node, check to make sure its state has never been
expanded before
▪ If not new, skip it, if new add to closed set
A S (0+2)
1
1
S h=4
C
h=1 A (1+4) B (1+1)
h=2 1
2
3 C (2+1) C (3+1)
B
h=1
G G (5+0) G (6+0)
h=0
Consistency of Heuristics
▪ Main idea: estimated heuristic costs ≤ actual costs
▪ Graph search:
▪ A* optimal if heuristic is consistent
▪ UCS optimal (h = 0 is consistent)
Uniform-Cost A*
b b
… …
UCS vs A* Contours