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

Artificial Intelligence: Uninformed Search

Uninformed search strategies do not use any heuristics to guide the search. These include breadth-first search, uniform-cost search, depth-first search, and iterative deepening search. Breadth-first search expands the shallowest nodes first. Uniform-cost search expands the node with the lowest path cost. Depth-first search expands the deepest nodes first. Iterative deepening search performs repeated depth-limited searches with increasing depth limits.

Uploaded by

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

Artificial Intelligence: Uninformed Search

Uninformed search strategies do not use any heuristics to guide the search. These include breadth-first search, uniform-cost search, depth-first search, and iterative deepening search. Breadth-first search expands the shallowest nodes first. Uniform-cost search expands the node with the lowest path cost. Depth-first search expands the deepest nodes first. Iterative deepening search performs repeated depth-limited searches with increasing depth limits.

Uploaded by

taurai
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Artificial Intelligence

UNINFORMED SEARCH
ENG P KADEBU
Recap on Search
2

Searching through a state space involves the


following:
• A set of states
• Operators and their costs
• Start state
• A test to check for goal state
The basic search algorithm
3
Uninformed search strategies
4

Uninformed: While searching you have no clue


whether one non-goal state is better than any other.
Your search is blind.
Various blind strategies:
Breadth-first search
Uniform-cost search
Depth-first search
Iterative deepening search
Breadth-first search
5
Breadth-first search
6

Expand shallowest unexpanded node


Implementation:
 fringe is a first-in-first-out (FIFO) queue, i.e., new successors
go at end of the queue.

Is A a goal state?
Breadth-first search

Expand shallowest unexpanded node


Implementation:
 fringe is a FIFO queue, i.e., new successors go at end

Expand:
fringe = [B,C]

Is B a goal state?

7
Breadth-first search
8

Expand shallowest unexpanded node


 fringe is a FIFO queue, i.e., new successors go at end
Implementation:

Expand:
fringe=[C,D,E]

Is C a goal state?
Breadth-first search
9

Expand shallowest unexpanded node


Implementation:
 fringe is a FIFO queue, i.e., new successors go at end

Expand:
fringe=[D,E,F,G]

Is D a goal state?
Example
BFS

10
Practice BFS
11
Properties of breadth-first search
12

Complete? Yes it always reaches goal (if b is finite)


Time? 1+b+b2+b3+… +bd + (bd+1-b)) = O(bd+1)
(this is the number of nodes we generate)
Space? O(bd+1) (keeps every node in memory,
either in fringe or on a path to fringe).
Optimal? Yes (if we guarantee that deeper
solutions are less optimal, e.g. step-cost=1).

Space is the bigger problem (more than time)


Uniform-cost search
13
Breadth-first is only
optimal if step costs
is increasing with
depth (e.g. constant).
Can we guarantee
optimality for any
step cost?
Uniform-cost
Search: Expand
node with
smallest
path cost g(n).
Uniform-cost search
14

Implementation: fringe = queue ordered by path cost


Equivalent to breadth-first if all step costs all equal.

Complete? Yes, if step cost ≥ ε


(otherwise it can get stuck in infinite loops of
sequence of zero cost actions)

Time? # of nodes with path cost ≤ cost of optimal solution.

Space? # of nodes on paths with path cost ≤ cost of optimal


solution.
O(b^(c/e)) – Both time and space
Optimal? Yes, for any step cost.
Depth-first search
15
Depth-first search
16

Expand deepest unexpanded node


Implementation:
 fringe = Last In First Out (LIFO) queue, i.e., put
successors at front

Is A a goal state?
Depth-first search
17

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[B,C]

Is B a goal state?
Depth-first search
18

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[D,E,C]

Is D = goal state?
Depth-first search
19

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[H,I,E,C]

Is H = goal state?
Depth-first search
20

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[I,E,C]

Is I = goal state?
Depth-first search
21

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[E,C]

Is E = goal state?
Depth-first search
22

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[J,K,C]

Is J = goal state?
Depth-first search
23

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[K,C]

Is K = goal state?
Depth-first search
24

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[C]

Is C = goal state?
Depth-first search
25

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[F,G]

Is F = goal state?
Depth-first search
26

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[L,M,G]

Is L = goal state?
Depth-first search
27

Expand deepest unexpanded node


 fringe = LIFO queue, i.e., put successors at front
Implementation:

queue=[M,G]

Is M = goal state?
Example DFS

28
Properties of depth-first search
29

Complete? No: fails in infinite-depth spaces


Can modify to avoid repeated states along path
Time? O(bm) with m=maximum depth
terrible if m is much larger than d
 but if solutions are dense, may be much faster than
breadth-first
Space? O(bm), i.e., linear space! (we only need to
remember a single path + expanded unexplored nodes)
Optimal? No (It may find a non-optimal goal first)
Practice DFS
30
Iterative deepening search
31

• To avoid the infinite depth problem of DFS, we can


decide to only search until depth L, i.e. we don’t expand beyond depth L.
 Depth-Limited Search

• What of solution is deeper than L?  Increase L iteratively.


 Iterative Deepening Search

• As we shall see: this inherits the memory advantage of Depth-First


search.
Iterative deepening search L=0, 1, 2
32
Iterative deepening search L=3
33
Iterative deepening search
34

 Number of nodes generated in a depth-limited search to


depth d with branching factor b:
NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd

 Number of nodes generated in an iterative deepening


search to depth d with branching factor b:
NIDS = (d+1)b0 + d b1 + (d-1)b2 + … + 3bd-2 +2bd-1 + 1bd =
O (b d )  O (b d 1 )

 For b = 10, d = 5, BFS


 NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
 NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,450
 NBFS = ............................................................................................ = 1,111,100
Properties of iterative deepening search
35

Complete? Yes
Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
Space? O(bd)
Optimal? Yes, if step cost = 1 or increasing function of
depth.
Example IDS
36
Bidirectional Search
37

Idea
 simultaneously search forward from S and backwards from G
 stop when both “meet in the middle”
 need to keep track of the intersection of 2 open sets of nodes
What does searching backwards from G mean
 need a way to specify the predecessors of G
 this can be difficult,
 e.g., predecessors of checkmate in chess?
 what if there are multiple goal states?
 what if there is only a goal test, no explicit list?
Bi-Directional Search
38

Complexity: time and space complexity are: O (b d / 2 )


Summary of algorithms
39
Repeated states
40
Avoiding Repeated States
41

Complication of wasting time by expanding states


that have already been encountered and expanded
before
 Failure to detect repeated states can turn a linear
problem into an exponential one

Sometimes, repeated states are unavoidable


 Problems where the actions are reversable
 Route finding
 Sliding blocks puzzles
Solutions to Repeated States
42 S
B
S
B C

C C S B S
State Space
Example of a Search Tree
Method 1 suboptimal but practical
 do not create paths containing cycles (loops)
Method 2 optimal but memory inefficient
 never generate a state generated before
 must keep track of all possible states (uses a lot of memory)
 e.g., 8-puzzle problem, we have 9! = 362,880 states
Summary
43

 Problem formulation usually requires abstracting away


real-world details to define a state space that can feasibly be
explored

 Variety of uninformed search strategies

 Iterative deepening search uses only linear space and not


much more time than other uninformed algorithms

You might also like