Professional Documents
Culture Documents
Blind (Uninformed) Search: Simple Problem-Solving-Agent Agent Algorithm
Blind (Uninformed) Search: Simple Problem-Solving-Agent Agent Algorithm
Blind (Uninformed) Search: Simple Problem-Solving-Agent Agent Algorithm
Agent Algorithm
Blind (Uninformed)
Search
1.
2.
3.
4.
5.
Search Tree
State graph
Search tree
5 1
6
8
8 4
8 2
3 4 7
5 1
8 2
3 4 7
3 4 7
5 1
6
4
5 1
STATE
PARENT-NODE
6
BOOKKEEPING
CHILDREN
If states
states are
are allowed
allowed to
to be
be revisited,
revisited,
If
the search
search tree
tree may
may be
be infinite
infinite even
even
the
when the
the state
state space
space is
is finite
finite
when
6
8
8 4
2
7
...
8 2
3 4 7
5 1
6
5
Action
Right
Depth
Path-Cost 5
Expanded
yes
Depth of a node N
= length of path from root to N
(depth of the root = 0)
Node expansion
8 4
8 2 7
3 4
5 1 6
8 2
3 4 7
5 1
6
7
8
2
3 4 7
5 1 6
8 2
3 4 7
5 1 6
8 4 2
3
7
5 1 6
8 2
3 4 7
5 1 6
Search Strategy
The fringe is the set of all search nodes
that havent been expanded yet
The fringe is implemented as a priority
queue FRINGE
INSERT(node,FRINGE)
REMOVE(FRINGE)
Is it identical
to the set of
leaves?
Search Algorithm #1
10
Performance Measures
SEARCH#1
1. If GOAL?(initial-state) then return initial-state
2. INSERT(initial-node,FRINGE)
3. Repeat:
a. If empty(FRINGE) then return failure
Expansion of N
b. N REMOVE(FRINGE)
c. s STATE(N)
d. For every state s in SUCCESSORS(s)
i. Create a new node N as a child of N
ii. If GOAL?(s) then return path or goal state
iii. INSERT(N,FRINGE)
11
Completeness
Optimality
Complexity
Example
STATE
N1
STATE
N2
Goal state
13
14
Example
8
1
4
7
N1
3
STATE
5
8
STATE
Remark
N2
Goal state
15
16
Blind Strategies
Breadth-First Strategy
Breadth-first
Bidirectional
Depth-first
Arc cost = 1
Depth-limited
Iterative deepening
Arc cost
(variant of breadth-first) = c(action) > 0
FRINGE = (1)
3
5
Uniform-Cost
17
18
Breadth-First Strategy
Breadth-First Strategy
2
4
FRINGE = (2, 3)
3
5
FRINGE = (3, 4, 5)
3
5
19
20
Breadth-First Strategy
Important Parameters
1
2
4
FRINGE = (4, 5, 6, 7)
3
7
Evaluation
22
Evaluation
b: branching factor
d: depth of shallowest goal node
Breadth-first search is:
Complete? Not complete?
Optimal? Not optimal?
b: branching factor
d: depth of shallowest goal node
Breadth-first search is:
Complete
Optimal if step cost is 1
Number of nodes generated:
???
23
24
Evaluation
Evaluation
b: branching factor
d: depth of shallowest goal node
Breadth-first search is:
Complete
Optimal if step cost is 1
Number of nodes generated:
1 + b + b2 + + bd = ???
b: branching factor
d: depth of shallowest goal node
Breadth-first search is:
Complete
Optimal if step cost is 1
Number of nodes generated:
1 + b + b2 + + bd = (bd+1-1)/(b-1) = O(bd)
Time and space complexity is O(bd)
25
Big O Notation
26
g(n) af(n)
27
d
2
4
6
8
10
12
14
# Nodes
111
11,111
~106
~108
~1010
~1012
~1014
Time
.01 msec
1 msec
1 sec
100 sec
2.8 hours
11.6 days
3.2 years
Remark
# Nodes
111
11,111
~106
~108
~1010
~1012
~1014
Time
.01 msec
1 msec
1 sec
100 sec
2.8 hours
11.6 days
3.2 years
Memory
11 Kbytes
1 Mbyte
100 Mb
10 Gbytes
1 Tbyte
100 Tbytes
10,000 Tbytes
Memory
11 Kbytes
1 Mbyte
100 Mb
10 Gbytes
1 Tbyte
100 Tbytes
10,000 Tbytes
10
11
12
13
14
15
10
11
12
13
15
14
30
Bidirectional Strategy
Depth-First Strategy
2
4
FRINGE = (1)
31
32
Depth-First Strategy
Depth-First Strategy
1
2
4
FRINGE = (2, 3)
1
3
FRINGE = (4, 5, 3)
33
34
Depth-First Strategy
Depth-First Strategy
1
2
4
1
3
35
3
5
36
Depth-First Strategy
Depth-First Strategy
1
2
4
1
3
3
5
37
38
Depth-First Strategy
Depth-First Strategy
1
2
4
1
3
3
5
39
40
Depth-First Strategy
Depth-First Strategy
1
2
4
1
3
41
3
5
42
Evaluation
Evaluation
b: branching factor
d: depth of shallowest goal node
m: maximal depth of a leaf node
Depth-first search is:
Complete?
Optimal?
b: branching factor
d: depth of shallowest goal node
m: maximal depth of a leaf node
Depth-first search is:
43
Depth-Limited Search
44
Main idea:
Totally horrifying !
IDS
For k = 0, 1, 2, do:
Perform depth-first search with
depth cutoff k
Solution
Failure (no solution)
Cutoff (no solution within cutoff)
45
Iterative Deepening
46
Iterative Deepening
47
48
Iterative Deepening
Performance
Iterative deepening search is:
Complete
Optimal if step cost =1
Calculation
(d-1)b2
db +
+ + (1)
= bd + 2bd-1 + 3bd-2 + + db
= (1 + 2b-1 + 3b-2 + + db-d)bd
bd
51
d = 5 and b = 10
ID
6
50
400
3,000
20,000
100,000
123,456
BF
1
2
4
8
16
32
63
ID
1x6=6
2 x 5 = 10
4 x 4 = 16
8 x 3 = 24
16 x 2 = 32
32 x 1 = 32
120
120/63 ~ 2
52
Comparison of Strategies
50
54
Revisited States
No
Few
Many
1 2 3
search tree is finite search tree is infinite
4 5
7 8 6
8-queens
assembly
planning
56
Solution 1:
Store all states associated with nodes in
current path in VISITED
If the state of a new node is in VISITED, then
discard the node
??
58
Solution 1:
Store all states associated with nodes in
current path in VISITED
If the state of a new node is in VISITED, then
discard the node
Only avoids loops
Solution 2:
Store all generated states in VISITED
If the state of a new node is in VISITED, then
discard the node
59
Same space complexity as breadth-first !
Uniform-Cost Search
Each arc has some cost c > 0
The cost of the path to each node N is
g(N) = costs of arcs
The goal is to generate a solution path of minimal cost
The nodes N in the queue FRINGE are sorted in
increasing g(N)
S
A
S
5 B
15
10
5 G
1
11
B
G
15
10
60
10
Search Algorithm #2
The goal test is applied
SEARCH#2
to a node when this node is
1. INSERT(initial-node,FRINGE) expanded, not when it is
generated.
2. Repeat:
a. If empty(FRINGE) then return failure
b. N REMOVE(FRINGE)
c. s STATE(N)
d. If GOAL?(s) then return path or goal state
e. For every state s in SUCCESSORS(s)
i. Create a node N as a successor of N
ii. INSERT(N,FRINGE)
61
11