0% found this document useful (0 votes)
27 views

Unit 3 - Blind Search

Uploaded by

RashmiRavi Naik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Unit 3 - Blind Search

Uploaded by

RashmiRavi Naik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

RN

3. 4 , C h a
– 3 p te r
.6

Blind S earch

1
Search Overview
? Introduction to Search

? Blind Search Techniques


aka “Uninformed Search” (Goal vs NonGoal)
? Breadth-First (Uniform Cost)

? Depth-First

? “Iterative Deepening"

? Bi-Directional
? Heuristic Search Techniques
? Stochastic Algorithms
? Game Playing search
? Constraint Satisfaction Problems

2
Generic Search Algorithm
Searchinsert( start, operations, isGoal ): path
L = make-queue( start )
loop
n := pop( L )
if [ isGoal( n )]
return( n )
S := successors( n, operators )
L := insert( S, L )
until L is empty
return( failure )

insert could be queue, stack, . . .


defines strategy! 3
Blind S earch

? Blind Search
? Depth-first search
? Breadth-first search
? Iterative deepening
? …
? Not “guided” by goal
? No matter where the goal is,
these algorithms will do the
same thing.
4
Performance Measures of
S earch Algorithms
? Completeness
Does algorithm always find a sol’n (if ∃)?
? Optimality
Does it always find least cost sol’n?
? Time complexity
How long does it take to find sol’n?
? Space complexity
How much memory is required to find a sol’n?

5
Parameters b
d

To measure Time and Space complexity:


? b: maximum branching factor of ⋮

the search tree


? Max number of operations at any state
? d: depth of the least-cost solution
? depth of shallowest goal node in search tree
? m: maximum depth of the state space
(may be ∞)
6
Breadth-first search
? Expand shallowest unexpanded node
? Implementation:
? fringe is a FIFO queue,
… new successors go at end

7
Breadth-First Search

8
Properties of Breadth-First search
? Complete? Yes (if b is finite)
? Optimal? Yes (if cost = 1 per step)
? Time? O(bd)
? 1 + b + b2 + … + bd/2 = O(bd)

? Space? O(bd)
? keeps every intermediate node in memory

? Space is the bigger problem (more than time)


9
Time and Memory R equirements
d #Nodes Time Memory
2 111 .01 msec 11 Kbytes
4 11,111 1 msec 1 Mbyte
6 ~106 1 sec 100 Mb
8 ~108 100 sec 10 Gbytes
10 ~1010 2.8 hours 1 Tbyte
12 ~1012 11.6 days 100 Tbytes
14 ~1014 3.2 years 10,000 Tb
Assumptions: b = 10; 1,000,000 nodes/sec; 100bytes/node
11
Uniform Cost S earch
? BreadthFirst returns SHALLOW-est Goal
… not necessarily best. . .
? Uniform Cost Search:
Expand LEAST Cost node
? If COST ≡ Depth, then UC = BF
? Complete

? Optimal
* *: If g( Successor(n) ) ≥ g(n)
Eg, if g(n) = ∑i c(ai)
? Time: O(b )
d is SUM of arc-costs

? Space: O(b )
d

12
To insure optimality

? To guarantee OPTIMAL path,


need to maintain queue,
sorted in increasing order:

A S
0
1 10
S 5 B 5 G
A B C
1 5 15
5
15 C
G G
11 10
13
Uniform-cost search
? Expand least-cost unexpanded node
? Implementation:
? fringe = queue ordered by path cost
? Equivalent to breadth-first if step costs all equal
? Complete? Yes, if step cost ≥ ε
(in trouble if cost = 0)
? Optimal? Yes
…as nodes expanded in increasing order of cost
? Time? O(b⌈C*/ ε⌉)
where C* = cost of optimal solution
? Space? O(b⌈C*/ ε⌉)
15
Depth-first search
? Expand deepest unexpanded node
? Implementation:
? fringe = LIFO queue, i.e., put successors at front

16
Depth-first Search

17
Properties of Depth-First Search
? Complete? No: fails in infinite-depth spaces, or if loops
? Modify to avoid repeated states along path
? complete in finite spaces

? Optimal? No
… first found ≠? best 20

? Time? O( bm) :
?terrible if m is much larger than d
?but if solutions are dense, may be much faster than BF

? Space? ( b m)
? d=12 ⇒ 12 kb, not 111 terabytes! 18
BFS/UC vs. DFS
Complete? Optimal? Time Space
BFS/UC YES YES bd bd
DFS finite depth NO bm bm

? Time:
? m=d DFS typically wins
:might winguara n t e e s ,
g
m>dllenBFS
a e s
Cmh= ’
?

e t B F S o r y ? ?
?

w to g
BFS probably
s m em
better
Ho ’
?

n l y D F S
? Space
u si n g o
? DFS almost always beats BFS
19
Which Strategy to Use?
? Depends on problem.
? If there are infinite paths
⇒ depth-first is bad
? If goal is at known depth
⇒ depth-first is good
? If ∃ large (possibly ∞) branching factor
⇒ breadth-first is bad

(Could try nondeterministic search:


Expand an open node at random.)

20
Depth- Limited S trategy
? Depth-first with depth cut-off k
(do NOT expand nodes below depth k)

? Three possible outcomes:


? Solution
? Failure (no solution)
? Cutoff (no solution within cutoff)

21
Depth-Limited Depth-First-Search
? Depth cut-off: k=3

? Complete: No unless soln @ depth ≤ k


? Optimal: No
? Time: O(bk)
? Space: O(b k)
22
Iterative Deepening S trategy

Use an artificial depth cutoff, k.


? For k = 1…
? Use Depth-limited Depth-First Search(k)
? If succeeds: DONE.

? If not: increase k by 1
(Regenerate nodes, as necessary)

23
Iterative Deepening Search k=0

24
Iterative Deepening Search: k=1

25
Iterative Deepening Search: k =2

26
Iterative Deepening Search k=3

27
28
Iterative Deepening: Analysis
? Time: ≈ BFS !
? … even though it regenerates intermediate nodes !
? Why? Almost all work ON FINAL LEVEL anyway!
? Eg: b = 10, d = 5:
? BFS expands 1 + 10 + 100 + … + 100,000 = 111,111
? IDS expands
? bottom level: 1 time
? second to bottom: 2 times
? …
? toplevel: d+1 times
total:(d+1)b0 + d b1 + (d-1)b2 + … + 3bd-2 +2bd-1 + 1bd
… 100,000 + 20,000 + …+ 50 + 6 = 123,456
? Ratio of IDS to BFS: ≈ [b / (b-1)]2
? Cost of repeating work at shallow depths: MINOR!
29
Properties of
Iterative Deepening S earch

? Complete? Yes
? Optimal? Yes, if step cost = 1
? Time?
(d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
? Space? O(b d)
? IDS does not get stuck on infinite path
? Space: Same as DFS – but with d, not m
(as each search is DFS) 32
BiDirectional
S earch
? Simultaneously:
? Search “forward" from start
? Search “backward" from goal
Stop when two searches meet in middle
? If branching factor = b in each direction & solution at depth d
⇒ need only O(2bd/2) = O(bd/2) steps

? Eg: b = 10, d = 6:
BFS expands 1,111,111 nodes
BiDirectional: 2,222 !
? Issues:
? How to “search backwards from goal"?
? What if > 1 goals (chess)?
? How to check if paths meet? constant time?
? What type of search done in each half? (BFS)

33
34
Comparing “Blind" Search
Strategies

35
Comparison of S trategies
? Breadth-first is complete and optimal,
but has high space complexity
? Bad when branching factor is high
? Depth-first is space efficient,
but not complete nor optimal
? Bad when search depth is infinite
? Iterative deepening is asymptotically
optimal !

36
Avoiding Repeated States
? May reach same state thru multiple paths

? ... if operations are REVERSIBLE (∞)


? ⇒ “Obvious" algorithms may
? be inefficient (exponentially worse)
? loop forever!
37
R epeated S tates
No Few Many

1 2 3
search tree is finite search tree is infinite
4 5
7 8 6

8-queens assembly 8-puzzle and robot navigation


planning
38
Approaches to Deal
w/Repeated State
? Don't return to parent state
? Don't generate successor ≡ node's parent
? Don't allow cycles
? Don't generate successor ≡ node's ancestor
? Don't ever revisit state
? Keep every visited state in memory! O(bd)

39
S ummary of Blind S earch
? Search strategies:
? breadth-first, depth-first, iterative deepening, …
? Evaluation of strategies:
? completeness, optimality, time and space
complexity
? Iterative deepening search
? uses only linear space
? ≈ same time as other blind-searchers
? Avoid repeated states

40
41

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy