Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Uninformed Search

Solving Problems by
Searching
How do you formulate a problem?
Given a problem formulation, how
do you solve it?

Formulating Problems
State: relevant information about the world
Goal: what are you trying to accomplish?

Goal test: check if the current state achieves the


goal

Initial state: what do you start with?


Actions: what can you do?
Action effects (transition model): if you take
an action a in state s, what state do you end up
with?
Path cost: how much cost do you incur by
using a particular sequence of actions to reach
a goal?

Goal-based Problem Solving


Example: The 8 Puzzle
Initial State

Goal State

Problem: Find sequence of actions that lead to the Goal


State configuration
Actions: move tiles up, down, left, or right when possible.

8-Puzzle
Initial State

Goal State

What are states, actions, and action effects?

State Space Definition for 8


Puzzle
State description:

position of each of the 8 tiles in one of 9


squares (or 3x3 board).

Actions:

blank position moves up, down, left, or right (if feasibl

Goal Test:

current state matches goal configuration:

Path cost:

each move is assigned a cost of 1.

Search Process: Generating


Solutions
Represented as a tree
How large is this tree?

Search Algorithms
Systematically explore the state space
to find the goal
High-level idea for TREE-SEARCH:

Start at initial state


Expand the initial state (node)
Try different actions, each leading to the next

state

If havent yet reached the goal, keep


expanding states
Keep going until you reach a goal

In what order should I expand


states?

Search Algorithms
Data structure: FRONTIER

Keeps track of states that we wish to


expand
A queue

POP(FRONTIER): choose a state s to


expand
When you expand a state s, you
generate a bunch more states s
(results of actions you take in state s)

Add these guys to FRONTIER

Problem with TREESEARCH


There can be many ways to get to
the same state
Each of these gets added to
FRONTIER

End up with cycles

Search Tree

down action

GRAPH-SEARCH
Introduce EXPLORED data
structure (set) to avoid adding
explored nodes to the FRONTIER
(Obviously, also dont add a node
to FRONTIER which is already
there)

Uninformed Search
Strategies
Breadth First Search
Uniform Cost Search
Depth First Search
Iterative Deepening Depth First
Search

How do these compare?


Completeness

Is the strategy guaranteed to find a solution


(goal) if one exists?

Time Complexity

How long does the algorithm take to find a


solution?

Space Complexity

How much memory does it take to perform the


search?

Optimality

Does the method find the best (lowest cost)


solution when there is more than one solution?

FRONTIER

Breadth-first Search (BFS)

Expanded
EXPLORED

All nodes at a given depth are


expanded before any nodes at a lower
level are expanded.
1
A
Start node
B

Level 1
Level 2

Level 3

I
8

K,
A
L
F,
G,
G,
H,
H
I,LK,
J,
C,
D
D,
B,C
C
E,
F
J, J,
K,
L
JI,LK,
H,
I,K,
J,
Queue
I,
F,
G,
H
Queue :: E,
E,
D
F
H,
J L

Queuing: FIFO

Properties of Breadth-first search

Completeness:
Yes (if b branching factor is finite)
Time Complexity: how long does it take to find a
solution?
1 + b + b2 + b3 + .. + bd = O(bd), i.e.,
exponential in d (d is depth of solution)
Space Complexity: how much memory does it take to
perform the search?
O(bd), because it keeps every node in
memory
Optimality: does the method find the best (highest
quality) solution when there is more than one
solution?
Yes, if cost = 1 per step, but not in general

FRONTIER
Expanded

Uniform-cost Search

EXPLORED

Expand node with least path cost first

Means retrieve nodes from queue by


increasing path cost (PC).
1

A
A
10
B
PC: 10 + 1 = 11

PC: 11 + 3 = 14

PC: 5 + 7 = 12

D
3

9
PC: 11 + 9 = 20

PC: 12 + 4 = 16

B,
A G,
E,
F
Queue
Queue :: E,
C,
E,
G,
B
F,
D,
G,
F, F,
H
I, H
B
F
J,
I,HH

2
10PC: 5 + 10 = 15
F

5
1

PC: 12 + 1 = 13

NOTE: Node F is never


expanded, therefore, nodes
K & L from our BFS tree are
never seen in this tree.

Uniform-cost Search
Only concerned about the total path
cost.
Can it get into an infinite loop?
Is it complete?
How does the worst case time and
space complexity compare to
breadth-first search?
Is it optimal?

Properties of Uniform-cost
search
Completeness: is the strategy guaranteed to find a solution if
one exists?
No (if step cost = 0, will keep exploring forever);
Yes if step cost > 0
Time Complexity: how long does it take to find a solution?
# of nodes with cost cost of optimal solution
Space Complexity: how much memory does it take to perform
the search?
# of nodes with cost cost of optimal solution
Optimality: does the method find the best (highest quality)
solution when there is more than one solution?
Yes.
Like BFS, both time and space complexity too large
for practical solutions

Depth-first Search (DFS)

FRONTIER
Expanded
EXPLORED

Follows each path to the greatest


depth before moving to the next path.
1

Level 1
Level 2

Start node
C

11
G

Level 3

Queue :: G,
F
J,
I, F
J,F
A
D,
CF C
Queue
B,C
H,
E,
H,
C

Queuing: LIFO

Depth-first Search
What is a problem with this
method?
What are the space requirements?

What is the worst case?

What about the processing


requirements?

What is the worst case?

Properties of Depth-first
search
Completeness
No: fails if infinite depth spaces, may also fail in
state spaces with loops (not a problem with
GRAPH-SEARCH); complete in finite spaces
Time Complexity:
O(bm), where m is maximum depth
Space Complexity:
O(bm), linear space requirements for TREESEARCH
Optimality:
No

FRONTIER
Expanded

Depth-Limited Search

EXPLORED

Depth-first search with depth limit l

i.e., cut off search at preset depth l

Let l = 3
B

Level 1
Level 2

Start node
C

11
G

Level 3

Queue :: G,
F
J,
I, F
J,F
A
D,
CF C
Queue
B,C
H,
E,
H,
C

What changes if l = 2?

Depth-limited Search
Does this algorithm solve the infinite path
problem?
What happens if the goal is at a node below
the depth limit?

What does this mean for completeness?

What happens if l is larger than d, the depth


of the goal node?

FRONTIER

Iterative deepening search

Expanded
EXPLORED

Depth-first search that gradually increases


the depth limit until the goal is found.
Combines DFS and BFS.
12
A
0
3
2
Limit = 1

14

3 612

7 13

5 11

15

18

Queue
B,
C
H,F C
Queue :: G,
A
C
F
D,
E,
J,
H,
I, F
J,F

9 17

4 8 16

10

Iterative Deepening
Search
Combines the best of breadth-first
and depth-first searches.
What is the time complexity?
Is iterative deepening faster than
breadth-first?
When is it best to apply this
algorithm?

Properties of Iterative
deepening search
Completeness:
Yes
Time Complexity:
O(bd), i.e., exponential in d
Space Complexity:
O(bd)
Optimality:
Yes, if cost = 1 per step,

Can be modified to explore uniform-cost tree

Conceptual Issues

IDS is truly wasteful, because you keep generating the


same nodes again and again (?)

True at the kth iteration, the root node will already have been
generated k times.
False: it does not have a significant effect on complexity of the
search.

Uninformed Search
Each of the algorithms discussed are
considered uninformed search
algorithms.

Why?
Is it possible to improve the search
process if it was more intelligent?

Assigned Reading
Chapter 3, 4.1

You might also like