sp14 cs188 lecture 3 -- informed search
TRANSCRIPT
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
1/69
CS 188: Artifcial Intelligence
Inormed Search
Instructors: Dan Klein and Pieter Abbeel
Universit o Caliornia! "er#ele$%hese slides &ere created b Dan Klein and Pieter Abbeel or CS188 Intro to AI at UC "er#ele' All CS188 m
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
2/69
%oda
Inormed Search +euristics
,reed Search
A- Search
,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
3/69
.eca(: Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
4/69
.eca(: Search
Search (roblem: States /confgurations o the &orld0 Actions and costs Successor unction /&orld dnamics0 Start state and goal test
Search tree: odes: re(resent (lans or reaching states Plans have costs /sum o action costs0
Search algorithm: Sstematicall builds a search tree Chooses an ordering o the ringe /une2(lored
nodes0
3(timal: fnds least4cost (lans
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
5/69
52am(le: Panca#e Problem
Cost: umber o (anca#es 6i((ed
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
6/69
52am(le: Panca#e Problem
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
7/69
52am(le: Panca#e Problem
7
9
7
7
9
State s(ace gra(h &ith costs as &eights
7
9
7
9
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
8/69
,eneral %ree Search
Action: 6i( to(t&o
Cost:
Action: 6i( allour
Cost: 9
Path to reachgoal:
li( our! 6i(three
%otal cost: ;
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
9/69
%he 3ne
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
10/69
Uninormed Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
11/69
Uniorm Cost Search
Strateg: e2(and lo&est (ath cost
%he good: UCS is com(lete ando(timal?
%he bad: 52(lores o(tions in ever @direction o inormation about goal location
Start
…
$Demo: contours UC$Demo: contours UC
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
12/69
ideo o Demo Contours UCS 5
ideo o Demo Contours UCS Pa
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
13/69
ideo o Demo Contours UCS PaSmall Eae
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
14/69
Inormed Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
15/69
Search +euristics
A heuristic is: A unction that estimates ho& close a state is
to a goal Designed or a (articular search (roblem
52am(les: Eanhattan distance! 5uclideandistance or (athing
10
5
11.2
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
16/69
52am(le: +euristic unction
h(x)
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
17/69
52am(le: +euristic unction
+euristic: the number o the largest (anca#e that is(lace
43
0
2
3
3
3
4
4
3
4
4
4
h(x)
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
18/69
,reed Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
19/69
52am(le: +euristic unction
h(x)
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
20/69
,reed Search
52(and the node that seems closestF
Ghat can go &rongH
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
21/69
,reed Search
Strateg: e2(and a node that ou
thin# is closest to a goal state +euristic: estimate o distance to
nearest goal or each state
A common case:
"est4frst ta#es ou straight to the/&rong0 goal
Gorst4case: li#e a badl4guided DS
…
…
$Demo: contours greed$Demo: contours greed
id d /
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
22/69
ideo o Demo Contours ,reed /
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
23/69
A- S h
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
24/69
A- Search
A- S h
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
25/69
A- Search
UCS ,reed
A-
C bi i UCS d , d
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
26/69
Combining UCS and ,reed
Uniorm4cost orders b (ath cost! or backward cg/n0
,reed orders b goal (ro2imit! or forward costh/n0
A- Search orders b the sum: /n0 /n0 J h/n0
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
1a
b
c
d
G
g =1
h=5
g =2
h=6g =3
h=7
Gh h ld A- t i t H
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
27/69
Ghen should A- terminateH
Should &e sto( &hen &e en=ueue
o: onl sto( &hen &e de=ueue a g
S
B
A
G
2
3
2
2
h = 1
h = 2
h = 0h = 3
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
28/69
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
29/69
Idea: Admissibilit
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
30/69
Idea: Admissibilit
Inadmissible /(essimistic0 heuristicsbrea# o(timalit b tra((ing good
(lans on the ringe
Admissible /o(timistic0do&n bad (lans but n
true cost
Admissible +euristics
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
31/69
Admissible +euristics
A heuristic h is admissible /o(timistic0 i:
&here is the true cost to a nearest
52am(les:
Coming u( &ith admissible heuristics is mo&hatLs involved in using A- in (ractice'
915
3(timalit o A- %ree Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
32/69
3(timalit o A- %ree Search
3(timalit o A- %ree Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
33/69
3(timalit o A- %ree Search
Assume:
A is an o(timal goal node
" is a subo(timal goal node
h is admissible
Claim:
A &ill e2it the ringe beore "
F
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
34/69
3(timalit o A- %ree Search: "lo
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
35/69
3(timalit o A- %ree Search: "lo
Proo:
Imagine " is on the ringe
Some ancestor n o A is onthe ringe! too /mabe A?0
Claim: n &ill be e2(andedbeore "
1' /n0 is less or e=ual to
/A0' /A0 is less than /"0 "
h
F
3(timalit o A- %ree Search: "lo
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
36/69
3(timalit o A- %ree Search: "lo
Proo:
Imagine " is on the ringe
Some ancestor n o A is onthe ringe! too /mabe A?0
Claim: n &ill be e2(andedbeore "
1' /n0 is less or e=ual to
/A0' /A0 is less than /"0
7' n e2(ands beore "
All ancestors o A e2(andbeore "
A e2(ands beore "
F
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
37/69
Pro(erties o A-
Pro(erties o A-
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
38/69
Pro(erties o A
Fb
Fb
Uniorm4
Cost
A-
UCS vs A- Contours
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
39/69
UCS vs A Contours
Uniorm4cost e2(ands e=uall
in all @directions
A- e2(ands mainl to&ard thegoal! but does hedge its betsto ensure o(timalit
Start
Start
$Demo: contours UCS )
em(t /B7D10*
ideo o Demo Contours /5m(t0
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
40/69
ideo o Demo Contours /5m(t0
ideo o Demo Contours /5m(t
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
41/69
/ (,reed
ideo o Demo Contours /5m(t
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
42/69
ideo o Demo Contours /5m(t
ideo o Demo Contours /PacmanE 0 A-
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
43/69
/Eae0 O A-
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
44/69
A- A((lications
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
45/69
A A((lications
A- A((lications
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
46/69
A A((lications
ideo games
Pathing ) routing (roblems .esource (lanning (roblems
.obot motion (lanning
Banguage analsis
Eachine translation S(eech recognition
F
$Demo: UCS ) A- (acman
/B7D!B7D;0*
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
47/69
ideo o Demo 5m(t Gater Shallo&)Dee(Algorithm
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
48/69
Algorithm
Creating +euristics
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
49/69
g
Creating Admissible +euristics
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
50/69
g
Eost o the &or# in solving hard search (roblems is in coming u( &ith admissible heuristics
3ten! admissible heuristics are solutions to relaxe problems &here ne& actions are available
Inadmissible heuristics are oten useul too
15366
52am(le: 8 Pule
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
51/69
(
Ghat are the statesH +o& man statesH Ghat are the actionsH +o& man successors rom the start
stateH
Ghat should the costs beH
Start State ,Actions
8 Pule I
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
52/69
+euristic: umber o tilesmis(laced
Gh is it admissibleH h/start0
%his is a relaxed!problem heuristic
8
Average nodese2(anded &heo(timal (ath h
F9ste(s
F8ste(s
UCS 11 !7MM
Start State
St
8 Pule II
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
53/69
Ghat i &e had an easier 84(ule&here an tile could slide andirection at an time! ignoringother tilesH
%otal "anhattan distance
Gh is it admissibleH
h/start0 7 J 1 J J F 18
Average nodee2(anded &ho(timal (ath
F9ste(s
F8ste(s
%IB5S 17 7Q
Start State
8 Pule III
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
54/69
+o& about using the act#al cost as a heuristicH Gould it be admissibleH
Gould &e save on nodes e2(andedH
GhatLs &rong &ith itH
Gith A-: a trade4oR bet&een =ualit o estimate a(er node As heuristics get closer to the true cost! ou &ill e2(and
nodes but usuall do more &or# (er node to com(ute thheuristic itsel
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
55/69
Semi4Battice o +euristics
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
56/69
,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
57/69
%ree Search: 52tra Gor#?
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
58/69
ailure to detect re(eated states can cause e2(onmore &or#'
Search %reeState ,ra(h
,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
59/69
In "S! or e2am(le! &e shouldnLt bother e2(anding thnodes /&hH0
S
a
b
d p
a
c
e
p
h
f
r
$
$ c ,
a
$e
p
h
f
r
$
$ c %
a
,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
60/69
Idea: never e2(and a state t&ice
+o& to im(lement: %ree search J set o e2(anded states /@closed set0
52(and the search tree node4b4node! butF
"eore e2(anding a node! chec# to ma#e sure its sthas never been e2(anded beore
I not ne&! s#i( it! i ne& add to closed set
Im(ortant: store the closed set as a set! not a
Can gra(h search &rec# com(letenessH
Gh)&h notH
+o& about o(timalitH
A- ,ra(h Search ,one GrongH
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
61/69
S
A
"
C
G
1
1
1
7
h=2
h=1
h=4
h=1
h=0
S /MJ0
A /1J90 " /1
C /J10
, /NJM0
C /7
, /
State s(ace gra(h Search tree
Consistenc o +euristics
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
62/69
Eain idea: estimated heuristi
actual costs
Admissibilit: heuristic cost T ac
goal
h/A0 T actual cost rom A to
Consistenc: heuristic @arc cos
or each arc
h/A0 O h/C0 T cost/A to C0
Conse=uences o consistenc
%he value along a (ath never d
h/A0 T cost/A to C0 J h/C0
7
A
C
G
h=4 h=1
1
h=2
3(timalit o A- ,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
63/69
3(timalit o A- ,ra(h Search
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
64/69
S#etch: consider &hat A- does
&ith a consistent heuristic: act 1: In tree search! A- e2(ands
nodes in increasing total value /4contours0
act : or ever state s! nodesthat reach s o(timall aree2(anded beore nodes that reachs subo(timall
.esult: A- gra(h search is o(timal
F
3(timalit
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
65/69
%ree search: A- is o(timal i heuristic is admissible UCS is a s(ecial case /h M0
,ra(h search: A- o(timal i heuristic is consistent UCS o(timal /h M is consistent0
Consistenc im(lies admissibilit
In general! most natural admissibleheuristics tend to be consistent!es(eciall i rom rela2ed (roblems
A-: Summar
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
66/69
A-: Summar
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
67/69
A- uses both bac#&ard costs and /estimatesor&ard costs
A- is o(timal &ith admissible ) consistent he
+euristic design is #e: oten use rela2ed (r
%ree Search Pseudo4Code
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
68/69
,ra(h Search Pseudo4Code
-
8/15/2019 SP14 CS188 Lecture 3 -- Informed Search
69/69