Download Today Uninformed search strategies Breadth

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1
2
Uninformed search strategies
Today
Uninformed strategies use only the information available in the problem
definition.
• Uninformed search
We look at some such strategies:
• Several search strategies
• Breadth-first search
• Properties of the strategies
• Uniform-cost search
See Russell and Norvig, Chapter 3.
• Depth-first search
• Depth-limited search
• Iterative deepening search
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
3
4
Breadth-first search
Properties of breadth-first search
Expand shallowest unexpanded node
Recall: Strategies are evaluated along the following dimensions:
completeness—does it always find a solution if one exists?
time complexity—number of nodes generated/expanded
space complexity—maximum number of nodes in memory
optimality—does it always find a least-cost solution?
Implementation:
fringe is a FIFO queue (First In First Out),
i.e., new successors go at end
A
A
B
D
C
E
Alan Smaill
F
A
B
G
D
C
E
F
D
C
E
Time and space complexity are measured in terms of
b—maximum branching factor of the search tree
d—depth of the least-cost solution
m—maximum depth of the state space (may be infinite)
A
B
G
Oct 9, 2008
F
Fundamentals of Artificial Intelligence
B
G
D
C
E
F
G
Oct 9, 2008
Complete??
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
5
6
Properties of breadth-first search
Properties of breadth-first search
Complete?? Yes (if b is finite)
Complete?? Yes (if b is finite)
Time??
Time?? 1 + b + b2 + b3 + . . . + bd + b(bd − 1) = O(bd+1), i.e., exp. in d
Space??
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
7
8
Properties of breadth-first search
Uniform-cost search
Complete?? Yes (if b is finite)
2
3
Expand least-cost unexpanded node
d
d
Time?? 1 + b + b + b + . . . + b + b(b − 1) = O(b
d+1
Implementation:
fringe = queue ordered by path cost
), i.e., exp. in d
Space?? O(bd+1) (keeps every node in memory)
Equivalent to breadth-first if step costs all equal
Optimal?? Yes (if cost = 1 per step); not optimal in general
Complete?? Yes, if step cost ≥ ǫ for ǫ > 0
Space is the big problem; can easily generate nodes at 10MB/sec –
so 24hrs = 860GB.
Time?? # of nodes with g ≤ cost of optimal solution, O(b⌈C
where C ∗ is the cost of the optimal solution
∗
Space?? # of nodes with g ≤ cost of optimal solution, O(b⌈C
/ǫ⌉
∗
)
/ǫ⌉
)
Optimal?? Yes—nodes expanded in increasing order of g(n)
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
9
Depth-first search
10
A
Depth-first search
A
B
C
D
Expand deepest unexpanded node
H
E
I
Implementation:
fringe = LIFO queue (Last In First Out),
J
B
F
K
L
G
N
M
C
D
O
H
E
I
J
K
C
i.e., put successors at front
E
I
J
L
G
N
M
H
J
O
H
I
J
L
G
N
M
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
N
M
O
H
E
I
J
L
G
O
H
E
I
L
G
J
M
N
O
H
F
K
J
N
M
G
N
M
O
H
E
I
J
F
L
K
O
G
N
M
B
F
K
L
O
A
E
I
O
C
D
C
D
G
N
M
B
F
K
L
A
B
F
K
K
C
D
G
C
D
C
J
J
A
E
I
I
A
B
H
L
K
A
D
H
F
B
F
B
F
K
O
E
A
E
C
E
I
C
D
C
D
A
B
D
N
M
B
F
K
L
G
A
B
H
B
F
A
D
A
L
G
M
N
C
D
O
H
E
I
J
F
K
L
G
M
N
O
Fundamentals of Artificial Intelligence
11
Oct 9, 2008
12
Properties of depth-first search
Properties of depth-first search
Complete?? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
⇒ complete in finite spaces
Complete?? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
⇒ complete in finite spaces
Time??
Time?? O(bm): terrible if m is much larger than d
but if solutions are dense, may be much faster than breadth-first
Space??
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
13
14
Properties of depth-first search
Properties of depth-first search
Complete?? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
⇒ complete in finite spaces
Complete?? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
⇒ complete in finite spaces
Time?? O(bm): terrible if m is much larger than d
but if solutions are dense, may be much faster than breadth-first
Time?? O(bm): 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!
Space?? O(bm), i.e., linear space!
Optimal??
Optimal?? No
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
15
16
Depth-limited search
Iterative deepening search
= depth-first search with depth limit l, i.e., do not look at nodes at depth > l
function Depth-Limited-Search( problem, limit) returns soln/fail/cutoff
Recursive-DLS(Make-Node(Initial-State[problem]), problem, limit)
Fundamentals of Artificial Intelligence
function Iterative-Deepening-Search( problem) returns a solution
inputs: problem, a problem
for depth ← 0 to ∞ do
result ← Depth-Limited-Search( problem, depth)
if result 6= cutoff then return result
end
function Recursive-DLS(node, problem, limit) returns soln/fail/cutoff
cutoff-occurred? ← false
if Goal-Test[problem](State[node]) then return node
else if Depth[node] = limit then return cutoff
else for each successor in Expand(node, problem) do
result ← Recursive-DLS(successor, problem, limit)
if result = cutoff then cutoff-occurred? ← true
else if result 6= failure then return result
if cutoff-occurred? then return cutoff else return failure
Alan Smaill
Oct 9, 2008
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Iterative deepening search l = 0
17
A
Limit = 0
A
B
C
C
C
E
G
C
D
E
C
E
D
G
D
J
M
L
O
N
H
J
K
C
E
I
J
O
N
H
J
Alan Smaill
E
I
J
L
G
M
N
O
H
I
J
H
J
D
F
M
L
O
N
H
H
I
J
F
K
J
B
F
K
G
M
L
H
E
I
J
F
K
N
C
D
O
H
E
I
J
B
F
K
G
M
L
O
N
A
B
G
M
O
N
C
D
O
N
A
L
G
M
L
A
E
I
G
C
E
C
D
O
N
F
K
G
C
E
A
B
G
M
L
E
I
D
B
F
K
G
B
G
C
E
C
D
O
F
A
B
F
K
D
C
F
A
C
D
G
N
F
K
A
B
H
M
L
E
I
E
A
E
C
D
G
M
L
C
D
A
B
F
K
D
A
B
D
G
B
F
A
H
G
C
E
I
B
F
B
F
B
F
K
E
A
C
E
I
C
D
C
E
A
B
D
H
G
C
A
B
F
Limit = 3
G
A
B
B
A
B
F
A
D
C
A
B
F
Complete??
A
B
A
B
D
A
B
A
Limit = 2
Properties of iterative deepening search
A
A
Limit = 1
18
L
G
M
N
C
D
O
H
E
I
J
F
K
L
G
M
N
O
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
19
Oct 9, 2008
20
Properties of iterative deepening search
Properties of iterative deepening search
Complete?? Yes
Complete?? Yes
Time??
Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd)
Space??
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
21
22
Properties of iterative deepening search
Properties of iterative deepening search
Complete?? Yes
Complete?? Yes
Time?? (d + 1)b + db + (d − 1)b + . . . + b = O(b )
Time?? (d + 1)b0 + db1 + (d − 1)b2 + . . . + bd = O(bd)
Space?? O(bd)
Space?? O(bd)
Optimal??
Optimal?? Yes, if step cost = 1
0
1
2
d
d
Numerical comparison for b = 10 and d = 5, solution at far right of tree:
N (IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450
N (BFS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
Fundamentals of Artificial Intelligence
23
24
Summary of algorithms
Criterion
Complete?
Time
Space
Optimal?
Here
∗
BreadthFirst
Yes∗
bd+1
bd+1
Yes∗
Repeated states
UniformCost
DepthFirst
DepthLimited
Iterative
Deepening
Yes∗
No
bm
bm
No
Yes, if l ≥ d
bl
bl
No
Yes
bd
bd
Yes
⌈C ∗ /ǫ⌉
b
∗
b⌈C /ǫ⌉
Yes∗
Oct 9, 2008
Failure to detect repeated states can turn a linear problem into an exponential
one!
A
A
B
B
C
C
indicates conditions stated earlier.
B
C
C
A
C
D
(a)
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Alan Smaill
(b)
Fundamentals of Artificial Intelligence
(c)
Oct 9, 2008
25
26
Graph search
Summary
The state space with actions leading from state to state corresponds naturally to
a graph rather than a tree; the state appears only once in the graph.
There are data structures corresponding to graphs, and graph search algorithms
that avoid repetition of states already seen.
The idea is to keep track of nodes that have already been expanded; if search
arrives back at such a node, it is ignored in future search.
See Russell and Norvig for details.
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
• 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
Alan Smaill
Fundamentals of Artificial Intelligence
Oct 9, 2008
Related documents