Uninformed Serch [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.]
Tody Serch Problems Uninformed Serch Methods Depth-First Serch Bredth-First Serch Uniform-Cost Serch
Serch Problems A serch problem consists of: A stte spce A successor function (with ctions, costs) A strt stte nd gol test N, 1.0 E, 1.0 A solution is sequence of ctions ( pln) which trnsforms the strt stte to gol stte
Serch Problems Are Models
Exmple: Trveling in Romni Stte spce: Cities Successor function: Rods: Go to djcent city with cost = distnce Strt stte: Ard Gol test: Is stte == Buchrest? Solution?
Wht s in Stte Spce? The world stte includes every lst detil of the environment A serch stte keeps only the detils needed for plnning (bstrction) Problem: Pthing Sttes: (x,y) loction Actions: NSEW Successor: updte loction only Gol test: is (x,y)=end Problem: Et-All-Dots Sttes: {(x,y), dot boolens} Actions: NSEW Successor: updte loction nd possibly dot boolen Gol test: dots ll flse
Stte Spce Sizes? World stte: Agent positions: 120 Food count: 30 Ghost positions: 12 Agent fcing: NSEW How mny World sttes? 120x(2 30 )x(12 2 )x4 Sttes for pthing? 120 Sttes for et-ll-dots? 120x(2 30 )
Stte Spce Grphs nd Serch Trees G b c S d h e f p q r
Stte Spce Grphs Stte spce grph: A mthemticl representtion of serch problem Nodes re (bstrcted) world configurtions Arcs represent successors (ction results) The gol test is set of gol nodes (mybe only one) In stte spce grph, ech stte occurs only once! We cn rrely build this full grph in memory (it s too big), but it s useful ide
Stte Spce Grphs Stte spce grph: A mthemticl representtion of serch problem Nodes re (bstrcted) world configurtions b c G Arcs represent successors (ction results) The gol test is set of gol nodes (mybe only one) d e f S h In serch grph, ech stte occurs only once! p q r We cn rrely build this full grph in memory (it s too big), but it s useful ide Tiny serch grph for tiny serch problem
Serch Trees This is now / strt N, 1.0 E, 1.0 Possible futures A serch tree: A wht if tree of plns nd their outcomes The strt stte is the root node Children correspond to successors Nodes show sttes, but correspond to PLANS tht chieve those sttes For most problems, we cn never ctully build the whole tree
Stte Spce Grphs vs. Serch Trees S Stte Spce Grph b c e d f h p q r G Ech NODE in in the serch tree is n entire PATH in the stte spce grph. We construct both on demnd nd we construct s little s possible. b d c Serch Tree S e e h r h r p q f p q f q c G q c G p q
Quiz: Stte Spce Grphs vs. Serch Trees Consider this 4-stte grph: How big is its serch tree (from S)? S G b Importnt: Lots of repeted structure in the serch tree!
Tree Serch
Serch Exmple: Romni
Serching with Serch Tree Serch: Expnd out potentil plns (tree nodes) Mintin fringe of prtil plns under considertion Try to expnd s few tree nodes s possible
Generl Tree Serch Importnt ides: Fringe Expnsion Explortion strtegy Min question: which fringe nodes to explore?
Exmple: Tree Serch b c G S d h e f p q r
Depth-First Serch
Depth-First Serch S b d p c e p h f r q q c G q e p h f r q q c G S G d b p q c e h f r q p h f d b c e r Strtegy: expnd deepest node first Implementtion: Fringe is LIFO stck
Serch Algorithm Properties
Serch Algorithm Properties Complete: Gurnteed to find solution if one exists? Optiml: Gurnteed to find the lest cost pth? Time complexity? Spce complexity? b 1 node b nodes Crtoon of serch tree: b is the brnching fctor m is the mximum depth solutions t vrious depths Number of nodes in entire tree? 1 + b + b 2 +. b m = O(b m ) m tiers b 2 nodes b m nodes
Depth-First Serch (DFS) Properties Wht nodes DFS expnd? Some left prefix of the tree. Could process the whole tree! b 1 node b nodes If m is finite, tkes time O(b m ) b 2 nodes How much spce does the fringe tke? Only hs siblings on pth to root, so O(bm) m tiers Is it complete? m could be infinite, so only if we prevent cycles (more lter) b m nodes Is it optiml? No, it finds the leftmost solution, regrdless of depth or cost
Bredth-First Serch
Bredth-First Serch Strtegy: expnd shllowest node first Implementtion: Fringe is FIFO queue S b p d q c h e r f G S Serch Tiers b d c h e r p h q e r f p q p q f q c G q c G
Bredth-First Serch (BFS) Properties Wht nodes does BFS expnd? Processes ll nodes bove shllowest solution Let depth of shllowest solution be s Serch tkes time O(b s ) s tiers b 1 node b nodes b 2 nodes How much spce does the fringe tke? b s nodes Hs roughly the lst tier, so O(b s ) Is it complete? b m nodes s must be finite if solution exists, so yes! Is it optiml? Only if costs re ll 1 (more on costs lter)
Quiz: DFS vs BFS When will BFS outperform DFS? When will DFS outperform BFS?
Wht serch strtegy is this? Bredth-First Serch (BFS)
Wht serch strtegy is this? Depth-First Serch (DFS)
Wht serch strtegy is this? Depth-First Serch (DFS)
Wht serch strtegy is this? Bredth-First Serch (BFS)
Itertive Deepening Ide: get DFS s spce dvntge with BFS s time / shllow-solution dvntges Run DFS with depth limit 1. If no solution Run DFS with depth limit 2. If no solution Run DFS with depth limit 3... b Isn t tht wstefully redundnt? Generlly most work hppens in the lowest level serched, so not so bd!
Cost-Sensitive Serch b 2 3 1 d 2 c 3 8 2 e 9 8 2 GOAL 2 f START 1 p 4 15 q 4 h r 2 BFS finds the shortest pth in terms of number of ctions. It does not find the lest-cost pth. We will now cover similr lgorithm which does find the lest-cost pth.
Uniform Cost Serch
Uniform Cost Serch Strtegy: expnd chepest node first: Fringe is priority queue (priority: cumultive cost) 2 b 1 3 S 1 p d 15 8 9 q 2 c h e 8 2 r G 2 f 1 S 0 d 3 e 9 p 1 b 4 c 11 e 5 h 17 r 11 q 16 Cost contours 6 h 13 r 7 p q f p q f 8 q c G q 11 c G 10
Uniform Cost Serch (UCS) Properties Wht nodes does UCS expnd? Processes ll nodes with cost less thn chepest solution! If tht solution costs C* nd rcs cost t lest, then the effective depth is roughly C*/ Tkes time O(b C*/ ) (exponentil in effective depth) C*/ tiers b c 1 c 2 c 3 How much spce does the fringe tke? Hs roughly the lst tier, so O(b C*/ ) Is it complete? Assuming best solution hs finite cost nd minimum rc cost is positive, yes! Is it optiml? Yes! (Proof next lecture vi A*)
Uniform Cost Issues Remember: UCS explores incresing cost contours The good: UCS is complete nd optiml! c 1 c 2 c 3 The bd: Explores options in every direction No informtion bout gol loction Strt Gol We ll fix tht soon!
Wht serch strtegy is this? Bredth-First Serch (BFS)
Wht serch strtegy is this? Uniform Cost Serch (UCS)
The One Queue All these serch lgorithms re the sme except for fringe strtegies Conceptully, ll fringes re priority queues (i.e. collections of nodes with ttched priorities) Prcticlly, for DFS nd BFS, you cn void the log(n) overhed from n ctul priority queue, by using stcks nd queues Cn even code one implementtion tht tkes vrible queuing object
Serch Gone Wrong?
Old Greece Assignment
Serch nd Models Serch opertes over models of the world The gent doesn t ctully try ll the plns out in the rel world! Plnning is ll in simultion Your serch is only s good s your models