CS 4100: Artificial Intelligence
Informed Search
Instructor: Jan-Willem van de Meent
[Adapted from slides by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley (ai.berkeley.edu).]
CS 4100: Artificial Intelligence Informed Search Instructor: - - PowerPoint PPT Presentation
CS 4100: Artificial Intelligence Informed Search Instructor: Jan-Willem van de Meent [Adapted from slides by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley (ai.berkeley.edu).] Announcements Homework k 1: Search (lead TA:
Instructor: Jan-Willem van de Meent
[Adapted from slides by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley (ai.berkeley.edu).]
k 1: Search (lead TA: Iris)
xtended)
Project 1 t 1: Search (lead TA: Iris)
k 2: Constraint Satisfaction Problems (lead TA: Eli)
Office H Hours
s: Mon 10.00am-noon, RI 237
JW: Tue 1.40pm-2.40pm, DG 111
Eli: Wed 3.00pm-5pm, RY 143
Zhaoqi qing: : Thu 9.00am-11.00am, HS 202
States (configurations of the world)
Actions and cost sts
ssor function (world dynamics)
state and goal test st
Nodes represent plans s for reaching states
Plans have cost sts s (sum of action costs)
frin inge (unexplored nodes)
Comple lete te: : finds solution if it exists
Optim timal: l: finds least-cost plan
Cost: Number of pancakes flipped
3 2 4 3 3 2 2 2 4
State space graph with costs as weights
3 4 3 4 2
Action: flip top two Cost: 2 Action: flip all four Cost: 4 Path to reach goal: Flip four, flip three Total cost: 7
same except for fringe strategies
queues (i.e. collections of nodes with attached priorities)
avoid the log(n) overhead from an actual priority queue, by using stacks and queues
that takes a variable queuing object
y: expand lowest path cost
The good
The bad ad:
Start Goal … c £ 3 c £ 2 c £ 1
Exampl ples: Manhattan distance, Euclidean distance
10 5 11.2
h(x)
4 2 3 2 3 3 3 3 4 3 3
h(x)
He Heurist stic: the number of pancakes that is still out of place
2
Ne New He Heurist stic: the index of the largest pancake that is still out of place
4 2 3 2 3 3 3 3 4 3 3
h1(x)
2 4 3 2 3 3 3 4 4 3 4 4 4
h2(x)
4 2 3 2 3 3 3 3 4 3 3
h(x)
y: expand the node that you think is closest to a goal state
stic: estimate of distance to nearest goal for each state
se:
(but finds suboptimal path)
st-case se: like a badly-guided DFS
… b … b
UCS UCS (slow and steady) Gr Greedy Search (fast but unreliable) A* A* Se Search (best of both worlds)
Unif iform rm-co cost st orders by path cost, or ba backward cost g( g(n)
Greedy orders by goal proximity, or fo forward heuristic h( h(n) n)
f(n) = g(n) + h(n)
S a d b G h=5 h=6 h=2 1 8 1 1 2 h=6 h=0 c h=7 3 e h=1 1 Ex Exampl ple: Teg Grenager S a b c e d d G G g = 0 h=6 g = 1 h=5 g = 2 h=6 g = 3 h=7 g = 4 h=2 g = 6 h=0 g = 9 h=1 g = 10 h=2 g = 12 h=0
S B A G 2 3 2 2
h = 1 h = 2 h = 0 h = 3
A G S 1 3
h = 6 h = 0
5
h = 7
Inadmissible (pessimistic) heuristics break
Admissible (optimistic) heuristics slow down bad plans but never outweigh true costs
4 15
As Assume me:
Cl Claim:
…
Pr Proof:
fringe, too (maybe A A itself!)
Claim: n will be expanded before B 1.
f(n) is less or equal to f( f(A)
Definition of f-cost Admissibility of h
…
h = 0 at a goal
Pr Proof:
fringe, too (maybe A A itself!)
Claim: n will be expanded before B 1.
f(n) is less or equal to f( f(A) 2.
f(A) is less than f( f(B)
B is suboptimal h= h=0 0 at a goal
…
Pr Proof:
too (maybe A A itself!)
Claim: n will be expanded before B 1.
f(n) is less or equal to f( f(A) 2.
f(A) is less than f( f(B) 3.
A* search is op
timal
…
… b … b
Uniform-Cost A*
Start Goal Start Goal
Greedy Uniform Cost A*
is in coming up with admissible heuristics
xed problems, where new actions are available
15 366
Start State Goal State Actions
Average nodes expanded when the optimal path has… …4 steps …8 steps …12 steps UCS 112 6,300 3.6 x 106 TILES 13 39 227
Start State Goal State
stic: Number of tiles misplaced
Statistics from Andrew Moore
sier 8-puzzle where any y tile could slide in any y direction at any y time (ignoring other tiles)?
Manhattan distance of tiles
Average nodes expanded when the optimal path has… …4 steps …8 steps …12 steps TILES 13 39 227 MANHATTAN 12 25 73
Start State Goal State
st as a heuristic?
With A*: *: a trade-off between quality y of est stimate and work k per node
but usually do more work per node to compute the heuristic
(what does this give us?)
Search Tree State Graph
S
a b d p a c e p h f r q q c
G
a q e p h f r q q c
G
a
Idea: never expand a state twice
How w to im imple lement:
its state has never been expanded before
Impo porta tant: t: store the closed set as a set, not a list
S A B C G
1 1 1 2 3 h=2 h=1 h=4 h=1 h=0
S (0+2) A (1+4) B (1+1) C (2+1) G (5+0) C (3+1) G (6+0)
St State space graph Se Search tree
Main idea: ea: heuristic costs ≤ actual costs
Admissibi bility: heuristic cost ≤ actual cost to goal h(A) ≤ actual cost from A to G
Consis istency: heuristic ≤ actual cost for each “arc” h(A) – h(C) ≤ cost(A to C)
Cons nseque quenc nces of cons nsistenc ncy:
decreases h(A) ≤ cost(A to C) + h(C)
3
A C G
h=4 h=1 1 h=2
ketch: consider what A* does with a consistent heuristic:
Fact 1: In tree search, A* expands nodes in increasing total f value (f-contours)
Fact 2: For every state s, nodes that reach s optimally are expanded before nodes that reach s suboptimally
Resul ult: A* graph search is optimal
… f £ 3 f £ 2 f £ 1
search:
ssible
search:
sist stent
sist stency y implies s admissi ssibility
tend to be consistent, especially if derived from relaxed problems
Reminder: f(n) = g(n) + h(n) = cost to n + heuristic
Proof i f ide dea: the optimal goal(s) have the lowest f f value, so it must get expanded first
… f £ 3 f £ 2 f £ 1 There’s a problem with this
is true?
Pr Proof:
ssible problem: some n on path to G* G* isn’t in queue when we need it, because some worse n’ n’ for the same state dequeued and expanded first (disaster!)
n that was on the queue when n’ n’ was popped
f(p) < < f( f(n) because of consistency
f(n) < < f( f(n’) ’) because n’ n’ is suboptimal
n’