recap search example pancake problem
play

Recap: Search Example: Pancake Problem Search problem: - PowerPoint PPT Presentation

Today CS 232: Ar)ficial Intelligence Informed Search Informed Search Sep 10, 2015 Heuris)cs Greedy Search A* Search Graph Search


  1. Today ¡ CS ¡232: ¡Ar)ficial ¡Intelligence ¡ ¡ Informed ¡Search ¡ § Informed ¡Search ¡ Sep ¡10, ¡2015 ¡ § Heuris)cs ¡ § Greedy ¡Search ¡ § A* ¡Search ¡ § Graph ¡Search ¡ [These ¡slides ¡were ¡created ¡by ¡Dan ¡Klein ¡and ¡Pieter ¡Abbeel ¡for ¡CS188 ¡Intro ¡to ¡AI ¡at ¡UC ¡Berkeley. ¡ ¡All ¡CS188 ¡materials ¡are ¡available ¡at ¡hMp://ai.berkeley.edu.] ¡ Recap: ¡Search ¡ Example: ¡Pancake ¡Problem ¡ § Search ¡problem: ¡ § States ¡(configura)ons ¡of ¡the ¡world) ¡ § Ac)ons ¡and ¡costs ¡ § Successor ¡func)on ¡(world ¡dynamics) ¡ § Start ¡state ¡and ¡goal ¡test ¡ § Search ¡tree: ¡ § Nodes: ¡represent ¡plans ¡for ¡reaching ¡states ¡ § Plans ¡have ¡costs ¡(sum ¡of ¡ac)on ¡costs) ¡ § Search ¡algorithm: ¡ § Systema)cally ¡builds ¡a ¡search ¡tree ¡ § Chooses ¡an ¡ordering ¡of ¡the ¡fringe ¡(unexplored ¡nodes) ¡ § Op)mal: ¡finds ¡least-­‑cost ¡plans ¡ Cost: ¡Number ¡of ¡pancakes ¡flipped ¡ 1

  2. Example: ¡Pancake ¡Problem ¡ Example: ¡Pancake ¡Problem ¡ State ¡space ¡graph ¡with ¡costs ¡as ¡weights ¡ 4 ¡ 2 ¡ 3 ¡ 2 ¡ 3 ¡ 4 ¡ 3 ¡ 4 ¡ 2 ¡ 3 ¡ 2 ¡ 2 ¡ 4 ¡ 3 ¡ General ¡Tree ¡Search ¡ The ¡One ¡Queue ¡ § All ¡these ¡search ¡algorithms ¡are ¡the ¡ same ¡except ¡for ¡fringe ¡strategies ¡ § Conceptually, ¡all ¡fringes ¡are ¡priority ¡ queues ¡(i.e. ¡collec)ons ¡of ¡nodes ¡with ¡ aMached ¡priori)es) ¡ § Prac)cally, ¡for ¡DFS ¡and ¡BFS, ¡you ¡can ¡ Ac)on: ¡flip ¡top ¡two ¡ Ac)on: ¡flip ¡all ¡four ¡ avoid ¡the ¡log(n) ¡overhead ¡from ¡an ¡ Cost: ¡2 ¡ Cost: ¡4 ¡ actual ¡priority ¡queue, ¡by ¡using ¡stacks ¡ Path ¡to ¡reach ¡goal: ¡ and ¡queues ¡ Flip ¡four, ¡flip ¡three ¡ § Can ¡even ¡code ¡one ¡implementa)on ¡ Total ¡cost: ¡7 ¡ that ¡takes ¡a ¡variable ¡queuing ¡object ¡ 2

  3. Uninformed ¡Search ¡ Uniform ¡Cost ¡Search ¡ § Strategy: ¡expand ¡lowest ¡path ¡cost ¡ c ≤ 1 … c ≤ 2 c ≤ 3 § The ¡good: ¡UCS ¡is ¡complete ¡and ¡op)mal! ¡ § The ¡bad: ¡ § Explores ¡op)ons ¡in ¡every ¡“direc)on” ¡ Start Goal § No ¡informa)on ¡about ¡goal ¡loca)on ¡ [Demo: ¡contours ¡UCS ¡empty ¡(L3D1)] ¡ [Demo: ¡contours ¡UCS ¡pacman ¡small ¡maze ¡(L3D3)] ¡ Video ¡of ¡Demo ¡Contours ¡UCS ¡Empty ¡ Video ¡of ¡Demo ¡Contours ¡UCS ¡Pacman ¡Small ¡Maze ¡ Spots ¡with ¡brighter ¡color ¡are ¡visited ¡earlier ¡in ¡the ¡search, ¡darker ¡color ¡later. ¡ 3

  4. Informed ¡Search ¡ Search ¡Heuris)cs ¡ § A ¡heuris)c ¡is: ¡ § A ¡func)on ¡that ¡ es#mates ¡how ¡close ¡a ¡state ¡is ¡to ¡a ¡goal ¡ § Designed ¡for ¡a ¡par)cular ¡search ¡problem ¡ § Examples: ¡ManhaMan ¡distance, ¡Euclidean ¡distance ¡for ¡ pathing ¡ 10 5 11.2 Example: ¡Heuris)c ¡Func)on ¡ Example: ¡Heuris)c ¡Func)on ¡ Heuris)c: ¡the ¡number ¡of ¡the ¡largest ¡pancake ¡that ¡is ¡s)ll ¡out ¡of ¡place ¡ 3 h(x) 4 3 4 3 0 4 4 3 4 4 2 h(x) 3 4

  5. Greedy ¡Search ¡ Example: ¡Heuris)c ¡Func)on ¡ h(x) Greedy ¡Search ¡ Greedy ¡Search ¡ b § Expand ¡the ¡node ¡that ¡seems ¡closest… ¡ § Strategy: ¡expand ¡a ¡node ¡that ¡you ¡think ¡is ¡ … closest ¡to ¡a ¡goal ¡state ¡ § Heuris)c: ¡es)mate ¡of ¡distance ¡to ¡nearest ¡goal ¡for ¡ each ¡state ¡ § A ¡common ¡case: ¡ b § Best-­‑first ¡takes ¡you ¡straight ¡to ¡the ¡(wrong) ¡goal ¡ … § Worst-­‑case: ¡like ¡a ¡badly-­‑guided ¡DFS ¡ § What ¡can ¡go ¡wrong? ¡ [Demo: ¡contours ¡greedy ¡empty ¡(L3D1)] ¡ ¡ [Demo: ¡contours ¡greedy ¡pacman ¡small ¡maze ¡(L3D4)] ¡ 5

  6. Video ¡of ¡Demo ¡Contours ¡Greedy ¡(Empty) ¡ Video ¡of ¡Demo ¡Contours ¡Greedy ¡(Pacman ¡Small ¡Maze) ¡ A* ¡Search ¡ Combining ¡UCS ¡and ¡Greedy ¡ § Uniform-­‑cost ¡orders ¡by ¡path ¡cost, ¡or ¡ backward ¡cost ¡ ¡ g(n) ¡ § Greedy ¡orders ¡by ¡goal ¡proximity, ¡or ¡ forward ¡cost ¡ ¡ h(n) ¡ g ¡= ¡0 ¡ 8 ¡ S ¡ h=6 ¡ g ¡= ¡1 ¡ h=1 ¡ e ¡ a ¡ h=5 ¡ 1 ¡ 1 ¡ 3 ¡ 2 ¡ g ¡= ¡9 ¡ g ¡= ¡2 ¡ g ¡= ¡4 ¡ S ¡ a ¡ d ¡ G ¡ b ¡ d ¡ e ¡ h=6 ¡ h=1 ¡ h=2 ¡ h=6 ¡ h=5 ¡ 1 ¡ h=2 ¡ h=0 ¡ 1 ¡ g ¡= ¡3 ¡ g ¡= ¡6 ¡ g ¡= ¡10 ¡ c ¡ b ¡ c ¡ G ¡ d ¡ h=7 ¡ h=0 ¡ h=2 ¡ h=7 ¡ h=6 ¡ g ¡= ¡12 ¡ G ¡ h=0 ¡ § A* ¡Search ¡orders ¡by ¡the ¡sum: ¡f(n) ¡= ¡g(n) ¡+ ¡h(n) ¡ Example: ¡Teg ¡Grenager ¡ 6

  7. When ¡should ¡A* ¡terminate? ¡ Is ¡A* ¡Op)mal? ¡ h ¡= ¡6 ¡ § Should ¡we ¡stop ¡when ¡we ¡enqueue ¡a ¡goal? ¡ 1 ¡ 3 ¡ A ¡ h ¡= ¡2 ¡ A ¡ 2 ¡ 2 ¡ S ¡ h ¡= ¡ 7 ¡ G ¡ h ¡= ¡0 ¡ S ¡ G ¡ h ¡= ¡3 ¡ h ¡= ¡0 ¡ 5 ¡ 2 ¡ 3 ¡ B ¡ h ¡= ¡1 ¡ § What ¡went ¡wrong? ¡ § No: ¡only ¡stop ¡when ¡we ¡dequeue ¡a ¡goal ¡ § Actual ¡bad ¡goal ¡cost ¡< ¡es)mated ¡good ¡goal ¡cost ¡ § We ¡need ¡es)mates ¡to ¡be ¡less ¡than ¡actual ¡costs! ¡ Admissible ¡Heuris)cs ¡ Idea: ¡Admissibility ¡ Inadmissible ¡(pessimis)c) ¡heuris)cs ¡break ¡ Admissible ¡(op)mis)c) ¡heuris)cs ¡slow ¡down ¡ op)mality ¡by ¡trapping ¡good ¡plans ¡on ¡the ¡fringe ¡ bad ¡plans ¡but ¡never ¡outweigh ¡true ¡costs ¡ 7

  8. Admissible ¡Heuris)cs ¡ Op)mality ¡of ¡A* ¡Tree ¡Search ¡ § A ¡heuris)c ¡ h ¡is ¡ admissible ¡ (op)mis)c) ¡if: ¡ ¡where ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡is ¡the ¡true ¡cost ¡to ¡a ¡nearest ¡goal ¡ ¡ § Examples: ¡ 4 ¡ 15 ¡ § Coming ¡up ¡with ¡admissible ¡heuris)cs ¡is ¡most ¡of ¡what’s ¡involved ¡ in ¡using ¡A* ¡in ¡prac)ce. ¡ Op)mality ¡of ¡A* ¡Tree ¡Search ¡ Op)mality ¡of ¡A* ¡Tree ¡Search: ¡Blocking ¡ Assume: ¡ Proof: ¡ … § Imagine ¡B ¡is ¡on ¡the ¡fringe ¡ § A ¡is ¡an ¡op)mal ¡goal ¡node ¡ … § Some ¡ancestor ¡ n ¡of ¡A ¡is ¡on ¡the ¡ § B ¡is ¡a ¡subop)mal ¡goal ¡node ¡ fringe, ¡too ¡(maybe ¡A!) ¡ § h ¡is ¡admissible ¡ § Claim: ¡ n ¡will ¡be ¡expanded ¡before ¡B ¡ 1. f(n) ¡is ¡less ¡or ¡equal ¡to ¡f(A) ¡ Claim: ¡ § A ¡will ¡exit ¡the ¡fringe ¡before ¡B ¡ Defini)on ¡of ¡f-­‑cost ¡ Admissibility ¡of ¡h ¡ h ¡= ¡0 ¡at ¡a ¡goal ¡ 8

  9. Op)mality ¡of ¡A* ¡Tree ¡Search: ¡Blocking ¡ Op)mality ¡of ¡A* ¡Tree ¡Search: ¡Blocking ¡ Proof: ¡ Proof: ¡ … … § Imagine ¡B ¡is ¡on ¡the ¡fringe ¡ § Imagine ¡B ¡is ¡on ¡the ¡fringe ¡ § Some ¡ancestor ¡ n ¡of ¡A ¡is ¡on ¡the ¡ § Some ¡ancestor ¡ n ¡of ¡A ¡is ¡on ¡the ¡ fringe, ¡too ¡(maybe ¡A!) ¡ fringe, ¡too ¡(maybe ¡A!) ¡ § Claim: ¡ n ¡will ¡be ¡expanded ¡before ¡B ¡ § Claim: ¡ n ¡will ¡be ¡expanded ¡before ¡B ¡ 1. f(n) ¡is ¡less ¡or ¡equal ¡to ¡f(A) ¡ 1. f(n) ¡is ¡less ¡or ¡equal ¡to ¡f(A) ¡ 2. f(A) ¡is ¡less ¡than ¡f(B) ¡ 2. f(A) ¡is ¡less ¡than ¡f(B) ¡ 3. ¡ n ¡expands ¡before ¡B ¡ B ¡is ¡subop)mal ¡ § All ¡ancestors ¡of ¡A ¡expand ¡before ¡B ¡ h ¡= ¡0 ¡at ¡a ¡goal ¡ § A ¡expands ¡before ¡B ¡ § A* ¡search ¡is ¡op)mal ¡ Proper)es ¡of ¡A* ¡ UCS ¡vs ¡A* ¡Contours ¡ § Uniform-­‑cost ¡expands ¡equally ¡in ¡all ¡ Uniform-­‑Cost ¡ A* ¡ “direc)ons” ¡ b ¡ b ¡ Start ¡ Goal ¡ … … § A* ¡expands ¡mainly ¡toward ¡the ¡goal, ¡ but ¡does ¡hedge ¡its ¡bets ¡to ¡ensure ¡ op)mality ¡ Start ¡ Goal ¡ [Demo: ¡contours ¡UCS ¡/ ¡greedy ¡/ ¡A* ¡empty ¡(L3D1)] ¡ [Demo: ¡contours ¡A* ¡pacman ¡small ¡maze ¡(L3D5)] ¡ 9

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend