Solving problems by searching Part I: Uninformed Search - - PowerPoint PPT Presentation

solving problems by searching
SMART_READER_LITE
LIVE PREVIEW

Solving problems by searching Part I: Uninformed Search - - PowerPoint PPT Presentation

Solving problems by searching Part I: Uninformed Search Formula<ng a Problem Domain State: Some descrip<on of the current world state Ac<on:


slide-1
SLIDE 1

Solving ¡problems ¡by ¡searching ¡

Part ¡I: ¡Uninformed ¡Search ¡

slide-2
SLIDE 2

Formula<ng ¡a ¡Problem ¡Domain ¡

  • State: ¡Some ¡descrip<on ¡of ¡the ¡current ¡world ¡

state ¡

  • Ac<on: ¡Means ¡to ¡manipulate ¡the ¡world. ¡
  • Goal: ¡The ¡desired ¡descrip<on ¡of ¡the ¡world. ¡
  • Problem: ¡Descrip<on ¡of ¡the ¡problem ¡to ¡be ¡
  • solved. ¡
  • Solu<on: ¡Sequence ¡of ¡ac<ons ¡that ¡will ¡lead ¡us ¡

from ¡to ¡the ¡goal ¡state. ¡

slide-3
SLIDE 3

Example: ¡Romania ¡

  • On ¡holiday ¡in ¡Romania; ¡currently ¡in ¡Arad. ¡
  • Flight ¡leaves ¡tomorrow ¡from ¡Bucharest ¡

¡

  • Formulate ¡goal: ¡

– be ¡in ¡Bucharest ¡ ¡

  • Formulate ¡problem: ¡

– states: ¡various ¡ci<es ¡ – ac<ons: ¡drive ¡between ¡ci<es ¡ ¡

  • Find ¡solu<on: ¡

– sequence ¡of ¡ci<es, ¡e.g., ¡Arad, ¡Sibiu, ¡Fagaras, ¡Bucharest ¡ ¡

slide-4
SLIDE 4

Example: ¡Romania ¡

slide-5
SLIDE 5

Problem ¡types ¡

  • Determinis<c, ¡fully ¡observable ¡à ¡single-­‑state ¡problem ¡

– Agent ¡knows ¡exactly ¡which ¡state ¡it ¡will ¡be ¡in; ¡solu<on ¡is ¡a ¡sequence ¡ ¡

  • Non-­‑observable ¡à ¡sensorless ¡problem ¡(conformant ¡problem) ¡

– Agent ¡may ¡have ¡no ¡idea ¡where ¡it ¡is; ¡solu<on ¡is ¡a ¡sequence ¡ ¡

  • Nondeterminis<c ¡and/or ¡par<ally ¡observable ¡à ¡con<ngency ¡

problem ¡

– percepts ¡provide ¡new ¡informa<on ¡about ¡current ¡state ¡ – oRen ¡interleave} ¡search, ¡execu<on ¡ ¡

  • Unknown ¡state ¡space ¡à ¡explora<on ¡problem ¡
slide-6
SLIDE 6

Single-­‑state ¡problem ¡formula<on ¡

A ¡problem ¡is ¡defined ¡by ¡four ¡items: ¡

  • 1. ini<al ¡state ¡e.g., ¡"at ¡Arad" ¡

¡

  • 2. ac<ons ¡or ¡successor ¡func<on ¡S(x) ¡= ¡set ¡of ¡ac<on–state ¡pairs ¡ ¡

– e.g., ¡S(Arad) ¡= ¡{<Arad ¡à ¡Zerind, ¡Zerind>, ¡… ¡} ¡ ¡

  • 3. goal ¡test, ¡can ¡be ¡

– explicit, ¡e.g., ¡x ¡= ¡"at ¡Bucharest" ¡ – implicit, ¡e.g., ¡Checkmate(x) ¡ ¡

  • 4. path ¡cost ¡(addi<ve) ¡

– e.g., ¡sum ¡of ¡distances, ¡number ¡of ¡ac<ons ¡executed, ¡etc. ¡ – c(x,a,y) ¡is ¡the ¡step ¡cost, ¡assumed ¡to ¡be ¡≥ ¡0 ¡

  • A ¡solu<on ¡is ¡a ¡sequence ¡of ¡ac<ons ¡leading ¡from ¡the ¡ini<al ¡state ¡to ¡a ¡

goal ¡state ¡

slide-7
SLIDE 7

Selec<ng ¡a ¡state ¡space ¡

  • Real ¡world ¡is ¡absurdly ¡complex ¡ ¡

à ¡state ¡space ¡must ¡be ¡abstracted ¡for ¡problem ¡solving ¡ ¡

  • (Abstract) ¡state ¡= ¡set ¡of ¡real ¡states ¡

¡

  • (Abstract) ¡ac<on ¡= ¡complex ¡combina<on ¡of ¡real ¡ac<ons ¡

– e.g., ¡"Arad ¡à ¡Zerind" ¡represents ¡a ¡complex ¡set ¡of ¡possible ¡routes, ¡detours, ¡rest ¡ stops, ¡etc. ¡ ¡

  • For ¡guaranteed ¡realizability, ¡any ¡real ¡state ¡"in ¡Arad“ ¡must ¡get ¡to ¡some ¡real ¡

state ¡"in ¡Zerind" ¡ ¡

  • (Abstract) ¡solu<on ¡= ¡ ¡

– set ¡of ¡real ¡paths ¡that ¡are ¡solu<ons ¡in ¡the ¡real ¡world ¡ ¡

  • Each ¡abstract ¡ac<on ¡should ¡be ¡"easier" ¡than ¡the ¡original ¡problem ¡

¡

slide-8
SLIDE 8

Example: ¡The ¡8-­‑puzzle ¡

  • states ¡= ¡integer ¡loca<ons ¡of ¡<les ¡
  • ac<ons ¡= ¡move ¡blank ¡leR, ¡right, ¡up, ¡down ¡
  • goal ¡test: ¡= ¡goal ¡state ¡(given) ¡path ¡
  • cost: ¡1 ¡per ¡move ¡ ¡
  • [Note: ¡op<mal ¡solu<on ¡of ¡n-­‑Puzzle ¡family ¡is ¡NP-­‑hard] ¡ ¡

2

Start State Goal State

5 1 3 4 6 7 8 5 1 2 3 4 6 7 8 5

slide-9
SLIDE 9

Example: ¡robo<c ¡assembly ¡

  • states: ¡

– real-­‑valued ¡coordinates ¡of ¡robot ¡joint ¡angles ¡ – parts ¡of ¡object ¡to ¡be ¡assembled ¡

  • ac<ons: ¡con<nuous ¡mo<on ¡of ¡robot ¡joints ¡
  • goal ¡test: ¡complete ¡assembly ¡
  • path ¡cost: ¡<me ¡to ¡execute ¡

R R R P R R

slide-10
SLIDE 10

Tree ¡search ¡example ¡

  • Simple ¡means ¡to ¡find ¡a ¡path ¡to ¡the ¡goal ¡state. ¡
slide-11
SLIDE 11

14 ¡Jan ¡2004 ¡ CS ¡3243 ¡-­‑ ¡Blind ¡Search ¡ 11 ¡

Tree ¡search ¡example ¡

Rimnicu Vilcea

Lugoj Zerind Sibiu Arad Fagaras Oradea Timisoara Arad Arad Oradea Arad

slide-12
SLIDE 12

14 ¡Jan ¡2004 ¡ CS ¡3243 ¡-­‑ ¡Blind ¡Search ¡ 12 ¡

Tree ¡search ¡example ¡

Rimnicu Vilcea

Lugoj Arad Fagaras Oradea Arad Arad Oradea Zerind Arad Sibiu Timisoara

slide-13
SLIDE 13

14 ¡Jan ¡2004 ¡ CS ¡3243 ¡-­‑ ¡Blind ¡Search ¡ 13 ¡

Tree ¡search ¡example ¡

Lugoj Arad Arad Oradea

Rimnicu Vilcea

Zerind Arad Sibiu Arad Fagaras Oradea Timisoara

slide-14
SLIDE 14

Tic ¡Tac ¡Toe ¡Example ¡

X X X X X X X X X −

slide-15
SLIDE 15

Tic ¡Tac ¡Toe ¡Example ¡

X X X X X X X X X X X O O X O . . . −

slide-16
SLIDE 16

Tic ¡Tac ¡Toe ¡Example ¡

X X X X X X X X X X X O O X O X O X O X O X X X . . . . . . −

slide-17
SLIDE 17

Tic ¡Tac ¡Toe ¡Example ¡

X X X X X X X X X X X O O O X O O O O O O O X O X O X O X X X X X X X X O X X O X X O X . . . . . . . . . . . . . . . . . . . . . X X −1 +1

slide-18
SLIDE 18

Uninformed ¡search ¡strategies ¡

  • Uninformed ¡strategies ¡use ¡only ¡the ¡

informa<on ¡available ¡in ¡the ¡problem ¡ defini<on ¡ ¡

– Breadth-­‑first ¡search ¡ – Uniform-­‑cost ¡search ¡ – Depth-­‑first ¡search ¡ – Depth-­‑limited ¡search ¡ – Itera<ve ¡deepening ¡search ¡ ¡

slide-19
SLIDE 19

Search ¡strategies ¡

  • A ¡strategy ¡is ¡defined ¡by ¡picking ¡the ¡order ¡of ¡node ¡

expansion ¡ ¡

  • Strategies ¡are ¡evaluated ¡along ¡the ¡following ¡dimensions: ¡

– completeness—does ¡it ¡always ¡find ¡a ¡solu<on ¡if ¡one ¡exists? ¡ – <me ¡complexity—number ¡of ¡nodes ¡generated/expanded ¡ – space ¡complexity—maximum ¡number ¡of ¡nodes ¡in ¡memory ¡ – op<mality—does ¡it ¡always ¡find ¡a ¡least-­‑cost ¡solu<on? ¡ ¡

  • Time ¡and ¡space ¡complexity ¡are ¡measured ¡in ¡terms ¡of ¡

– b—maximum ¡branching ¡factor ¡of ¡the ¡search ¡tree ¡ – d—depth ¡of ¡the ¡least-­‑cost ¡solu<on ¡ – m—maximum ¡depth ¡of ¡the ¡state ¡space ¡(may ¡be ¡∞) ¡ ¡

slide-20
SLIDE 20

Breadth-­‑first ¡search ¡

Expand ¡shallowest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡FIFO ¡queue ¡new ¡successors ¡go ¡at ¡the ¡end: ¡ ¡

A B C D E F G

slide-21
SLIDE 21

Breadth-­‑first ¡search ¡

Expand ¡shallowest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡FIFO ¡queue ¡new ¡successors ¡go ¡at ¡the ¡end: ¡ ¡

A B C D E F G

slide-22
SLIDE 22

Breadth-­‑first ¡search ¡

Expand ¡shallowest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡FIFO ¡queue ¡new ¡successors ¡go ¡at ¡the ¡end: ¡ ¡ A B C D E F G

slide-23
SLIDE 23

Breadth-­‑first ¡search ¡

Expand ¡shallowest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡FIFO ¡queue ¡new ¡successors ¡go ¡at ¡the ¡end: ¡ ¡ A B C D E F G

slide-24
SLIDE 24

Proper<es ¡of ¡Breadth ¡First ¡Search ¡

  • Complete: ¡Yes ¡(if ¡b ¡is ¡finite) ¡
  • Time: ¡1+b+b2+b3+...+bd+b(bd−1) ¡= ¡O(bd+1) ¡
  • Space: ¡O(bd+1) ¡(keeps ¡every ¡node ¡in ¡memory) ¡
  • Op<mal: ¡

– Yes ¡(if ¡cost ¡= ¡1 ¡per ¡step) ¡ – Not ¡op<mal ¡in ¡general ¡

  • Space ¡is ¡the ¡big ¡problem; ¡can ¡easily ¡generate ¡nodes ¡

at ¡100MB/sec ¡so ¡24hrs ¡= ¡8640GB. ¡ ¡

slide-25
SLIDE 25

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-26
SLIDE 26

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-27
SLIDE 27

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-28
SLIDE 28

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-29
SLIDE 29

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-30
SLIDE 30

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-31
SLIDE 31

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-32
SLIDE 32

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-33
SLIDE 33

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-34
SLIDE 34

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-35
SLIDE 35

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-36
SLIDE 36

Depth-­‑first ¡search ¡

Expand ¡deepest ¡unexpanded ¡node ¡ Implementa<on: ¡ ¡fringe ¡is ¡a ¡LIFO ¡queue; ¡put ¡successors ¡at ¡front: ¡ ¡

A B C D E F G H I J K L M N O

slide-37
SLIDE 37

Proper<es ¡of ¡Depth ¡First ¡Search ¡

  • Complete: ¡No: ¡(fails ¡with ¡infinite-­‑depth, ¡loops) ¡

– Modify ¡to ¡avoid ¡repeated ¡states ¡

  • Complete ¡in ¡finite ¡state ¡spaces. ¡

¡

  • Time: ¡O(bm) ¡(terrible ¡if ¡m ¡is ¡much ¡larger ¡than ¡d) ¡
  • Space: ¡O(bm) ¡linear ¡(beler!) ¡
  • Op<mal: ¡No ¡
slide-38
SLIDE 38

Depth-­‑limited ¡search ¡

  • Depth-­‑first ¡search ¡with ¡depth ¡limit, ¡L ¡

– (i.e., ¡pretend ¡nodes ¡at ¡depth ¡L ¡have ¡no ¡successors) ¡

  • Itera<ve ¡deepening ¡search ¡

– Repeated ¡applica<on ¡of ¡depth-­‑limited ¡search ¡

  • Start ¡depth ¡at ¡0 ¡
  • Increase ¡depth ¡un<l ¡solu<on ¡is ¡found ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

(up ¡to ¡a ¡poten<al ¡cutoff) ¡

slide-39
SLIDE 39

Itera<ve ¡deepening ¡search ¡

Limit = 0

A A

slide-40
SLIDE 40

Itera<ve ¡deepening ¡search ¡

Limit = 1

A B C A B C A B C A B C

slide-41
SLIDE 41

Itera<ve ¡deepening ¡search ¡

Limit = 2

A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G A B C D E F G

slide-42
SLIDE 42

Itera<ve ¡deepening ¡search ¡

Limit = 3

A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H I J K L M N O A B C D E F G H J K L M N O I A B C D E F G H I J K L M N O

slide-43
SLIDE 43

Proper<es ¡of ¡IDS ¡

  • Complete: ¡Yes ¡
  • Time: ¡(d+1)b0 ¡+db1 ¡+(d−1)b2 ¡+...+bd ¡=O(bd) ¡ ¡
  • Space: ¡O(bd) ¡
  • Op<mal: ¡Yes, ¡if ¡step ¡cost ¡= ¡1 ¡
  • IDS ¡combines ¡the ¡low ¡memory ¡use ¡of ¡DFS ¡with ¡the ¡

completeness ¡of ¡BFS ¡search. ¡

slide-44
SLIDE 44

Summary ¡

  • Problem ¡formula<on ¡usually ¡requires ¡abstrac<ng ¡

away ¡real-­‑world ¡details ¡to ¡define ¡a ¡state ¡space ¡that ¡ can ¡feasibly ¡be ¡explored ¡ ¡

  • Variety ¡of ¡uninformed ¡search ¡strategies ¡ ¡
  • Itera<ve ¡deepening ¡search ¡uses ¡only ¡linear ¡space ¡

and ¡not ¡much ¡more ¡<me ¡than ¡other ¡uninformed ¡ algorithms ¡ ¡ ¡