1 Hl Dumé III (me@hl3.nme) Uninformed Serch Hl Dumé III Comuter Science University of Mrylnd me@hl3.nme CS 421: Introduction to Artificil Intelligence 31 Jn 2012 Mny slides courtesy of Dn Klein, Sturt Russell, or Andrew Moore
2 Hl Dumé III (me@hl3.nme) Announcements Forgot to tell you login informtion for we ge: User nme = cs421 (ut no uotes) Pssword = (still no uotes) (this will e used for osting solutions) Junkfood mchines: You my develo t home, ut must run on Junkfood Homework 1 hs een osted Project 1 will e osted soon
3 Hl Dumé III (me@hl3.nme) Tody Agents tht Pln Ahed Serch Prolems Uniformed Serch Methods Deth-First Serch Bredth-First Serch Uniform-Cost Serch
4 Hl Dumé III (me@hl3.nme) Serch Prolems A serch rolem consists of: A stte sce A successor function N, 1.0 A strt stte nd gol test E, 1.0 A solution is seuence of ctions ( ln) which trnsforms the strt stte to gol stte
5 Hl Dumé III (me@hl3.nme) Reflex Agents Reflex gents: Choose ction sed on current ercet nd memory My hve memory or model of the world s current stte Do not consider the future conseuences of their ctions Cn reflex gent e rtionl? [demo: reflex ]
6 Hl Dumé III (me@hl3.nme) Gol Bsed Agents Gol-sed gents: Pln hed Decisions sed on (hyothesized) conseuences of ctions Must hve model of how the world evolves in resonse to ctions [demo: ln fst / slow ]
7 Hl Dumé III (me@hl3.nme) Serch Trees N, 1.0 E, 1.0 A serch tree: This is wht if tree of lns nd outcomes Strt stte t the root node Children corresond to successors Nodes leled with sttes, corresond to PLANS to those sttes For most rolems, cn never uild the whole tree So, hve to find wys to use only the imortnt rts!
8 Hl Dumé III (me@hl3.nme) Stte Sce Grhs u.hl3.nme/ic.l?= There s some ig grh in which Ech stte is node Ech successor is n outgoing rc Imortnt: For most rolems we could never ctully uild this grh How mny sttes in Pcmn? S d c h Lughly tiny serch grh for tiny serch rolem e r f G
9 Hl Dumé III (me@hl3.nme) Exmle: Romni
10 Hl Dumé III (me@hl3.nme) Another Serch Tree Serch: Exnd out ossile lns Mintin fringe of unexnded lns Try to exnd s few tree nodes s ossile
11 Hl Dumé III (me@hl3.nme) Sttes vs. Nodes Prolem grhs hve rolem sttes Reresent n strcted stte of the world Hve successors, redecessors, cn e gol / non-gol Serch trees hve serch nodes Reresent ln (th) which results in the node s stte Hve 1 rent, length nd cost, oint to rolem stte Exnd uses successor function to crete new tree nodes The sme rolem stte in multile serch tree nodes
12 Hl Dumé III (me@hl3.nme) Generl Tree Serch Imortnt ides: Fringe Exnsion Exlortion strtegy Detiled seudocode is in the ook! Min uestion: which fringe nodes to exlore?
13 Hl Dumé III (me@hl3.nme) Exmle: Tree Serch c G S d h e f r
Stte Grhs vs Serch Trees S d c h e G f Ech NODE in in the serch tree is n entire PATH in the rolem grh. r S We lmost lwys construct oth on demnd nd we construct s little s ossile. 14 Hl Dumé III (me@hl3.nme) d c h e r f c G e h r f c G
15 Hl Dumé III (me@hl3.nme) Review: Deth First Serch S d c e h f r c G e h f r c G S G d c e h f r h f d c e r Strtegy: exnd deeest node first Imlementtion: Fringe is LIFO stck
Review: Bredth First Serch Strtegy: exnd shllowest node first Imlementtion: Fringe is FIFO ueue S d c h e r G f S Serch Tiers d c h e r h e r f f c G c G 16 Hl Dumé III (me@hl3.nme)
17 Hl Dumé III (me@hl3.nme) Serch Algorithm Proerties Comlete? Gurnteed to find solution if one exists? Otiml? Gurnteed to find the lest cost th? Time comlexity? Sce comlexity? Vriles: n Numer of sttes in the rolem The verge rnching fctor B (the verge numer of successors) C* Cost of lest cost solution s Deth of the shllowest solution m Mx deth of the serch tree
18 Hl Dumé III (me@hl3.nme) DFS n # sttes vg rnch C* lest cost s shllow gol m mx deth Algorithm Comlete Otiml Time Sce DFS Deth First Serch N N N N O(B Infinite LMAX ) O(LMAX) Infinite START GOAL Infinite ths mke DFS incomlete How cn we fix this?
19 Hl Dumé III (me@hl3.nme) DFS With cycle checking, DFS is comlete. 1 node nodes 2 nodes m tiers n # sttes vg rnch C* lest cost s shllow gol m mx deth u.hl3.nme/ic.l?=dfs m nodes Algorithm Comlete Otiml Time Sce DFS w/ Pth Checking N N O(B LMAX ) O(LMAX) Y
20 Hl Dumé III (me@hl3.nme) BFS n # sttes vg rnch C* lest cost s shllow gol m mx deth s tiers 1 node nodes 2 nodes s nodes m nodes
21 Hl Dumé III (me@hl3.nme) Itertive Deeening Itertive deeening uses DFS s suroutine: 1. Do DFS which only serches for ths of length <=1 (DFS gives u on th of length 2) 2. If 1 filed, do DFS which only serches ths of length 2 or less. 3. If 2 filed, do DFS which only serches ths of length 3 or less..nd so on. n # sttes vg rnch C* lest cost s shllow gol m mx deth Algorithm Comlete Otiml Time Sce DFS w/ Pth Y BFS ID Checking Y Y
22 Hl Dumé III (me@hl3.nme) Comrisons n # sttes vg rnch C* lest cost s shllow gol m mx deth When will BFS outerform DFS? When will DFS outerform BFS?
Costs on Actions START 2 3 1 1 d 2 c 3 8 2 e 9 8 2 h 4 4 15 r GOAL 2 f 1 Notice tht BFS finds the shortest th in terms of numer of trnsitions. It does not find the lest-cost th. We will uickly cover n lgorithm which does find the lest-cost th. 23 Hl Dumé III (me@hl3.nme)
Uniform Cost Serch Exnd cheest node first: Fringe is riority ueue S 1 2 1 3 d 15 8 9 2 c h e 8 1 r G f 2 1 S 0 Cost contours 4 6 24 Hl Dumé III (me@hl3.nme) d c 3 9 1 11 h e 13 r f 11 c G 5 7 8 10 h e 17 11 r f c G 16
25 Hl Dumé III (me@hl3.nme) Priority Queue Refresher A riority ueue is dt structure in which you cn insert nd retrieve (key, vlue) irs with the following oertions:.ush(key, vlue).o() inserts (key, vlue) into the ueue. returns the key with the lowest vlue, nd removes it from the ueue. You cn romote or demote keys y resetting their riorities Unlike regulr ueue, insertions into riority ueue re not constnt time, usully O(log n) We ll need riority ueues for most cost-sensitive serch methods.
26 Hl Dumé III (me@hl3.nme) Uniform Cost Serch Wht will UCS do for this grh? 0 START 1 0 1 GOAL Wht does this men for comleteness?
27 Hl Dumé III (me@hl3.nme) Uniform Cost Serch Algorithm Comlete Otiml Time Sce DFS BFS UCS w/ Pth Checking Y* Y O(C* C*/ε ) O( C*/ε ) n # sttes vg rnch C* lest cost s shllow gol m mx deth C*/ε tiers We ll tlk more out uniform cost serch s filure cses lter
Uniform Cost Prolems Rememer: exlores incresing cost contours c 1 c 2 The good: UCS is comlete nd otiml! c 3 The d: Exlores otions in every direction No informtion out gol loction Strt Gol 28 Hl Dumé III (me@hl3.nme) [demo: ucs contours ]
29 Hl Dumé III (me@hl3.nme) Heuristics
30 Hl Dumé III (me@hl3.nme) Best First / Greedy Serch Exnd the node tht seems closest Wht cn go wrong?
31 Hl Dumé III (me@hl3.nme) Best First / Greedy Serch START h=12 h=11 2 1 3 d 1 4 15 h=11 h=8 h=8 8 2 c 2 e 9 1 9 h 4 3 h=9 h=5 h=4 h=6 2 f 5 r h=6 GOAL 5 h=0 h=4
32 Hl Dumé III (me@hl3.nme) Best First / Greedy Serch A common cse: Best-first tkes you stright to the (wrong) gol Worst-cse: like dlyguided DFS in the worst cse Cn exlore everything Cn get stuck in loos if no cycle checking Like DFS in comleteness (finite sttes w/ cycle checking)
33 Hl Dumé III (me@hl3.nme) Serch Gone Wrong?
34 Hl Dumé III (me@hl3.nme) Extr Work? Filure to detect reeted sttes cn cuse exonentilly more work. Why?
35 Hl Dumé III (me@hl3.nme) Grh Serch In BFS, for exmle, we shouldn t other exnding the circled nodes (why?) S d e c e h r h r f f c G c G
36 Hl Dumé III (me@hl3.nme) Grh Serch Very simle fix: never exnd stte tye twice Cn this wreck comleteness? Why or why not? How out otimlity? Why or why not?
37 Hl Dumé III (me@hl3.nme) Some Hints Grh serch is lmost lwys etter thn tree serch (when not?) Fringes re sometimes clled closed lists ut don t imlement them with lists (use sets)! Nodes re concetully ths, ut etter to reresent with stte, cost, nd reference to rent node
38 Hl Dumé III (me@hl3.nme) Best First Greedy Serch n # sttes vg rnch C* lest cost s shllow gol m mx deth Algorithm Comlete Otiml Time Sce Greedy Best-First Serch Y* N O( m ) O( m ) m Wht do we need to do to mke it comlete? Cn we mke it otiml? Next clss!