AI ch03 Search
AI ch03 Search
1
Chapter Objectives
2
Chapter 3: Search Quotations
3
Chapter 3: Search Quotations
4
Intro: Theory of State Space Search
6
The city of Königsberg
7
Graph of the Königsberg bridge system
8
Definition of a graph
A graph consists of
• A set of nodes (can be infinite)
• A set of arcs that connect pairs of nodes.
An arc is an ordered pair, e.g.,
(i1, rb1),
(rb1, i1).
9
A labeled directed graph
10
A rooted tree, exemplifying family
relationships
11
Definition of a graph (cont’d)
12
Definition of a graph (cont’d)
13
Definition of a graph (cont’d)
14
A unifying view (Newell and Simon)
15
Searching on a graph (simplified)
16
1 4 3 1 4 3
7 6 7 6 2
5 8 2 5 8
17
State space of the 8-puzzle generated by
“move blank” operations
18
State space search
20
State space of the 8-puzzle (repeated)
21
Traveling salesperson problem as state space
search
22
An instance of the traveling salesperson
problem
23
Search of the traveling salesperson
problem. (arc label = cost from root)
24
Nearest neighbor path
• states:
• operators:
• initial state:
• goal state:
Note: this is a “two-player” game
26
Goal-directed search
27
Data-directed search
28
29
Trace of backtracking search (Fig. 3.12)
30
A trace of backtrack on the graph of
Fig. 3.12
31
Graph for BFS and DFS (Fig. 3.13)
32
Breadth_first search algorithm
33
Trace of BFS on the graph of Fig. 3.13
34
Graph of Fig. 3.13 at iteration 6 of BFS
35
Depth_first_search algorithm
36
Trace of DFS on the graph of Fig. 3.13
37
Graph of Fig. 3.13 at iteration 6 of DFS
38
BFS, label = order state was removed
from OPEN
39
DFS with a depth bound of 5, label =
order state was removed from OPEN
40
State space graph of a set of
implications in propositional calculus
41
And/or graph of the expression qrp
42
Hypergraph
43
And/or graph of the expression qrp
44
And/or graph of a set of propositional
calculus expressions
45
And/or graph of the part of the state
space for integrating a function (Nilsson 1971)
47
The solution subgraph showing that fred
is at the museum
48
Facts and rules for the example
49
Five rules for a simple subset of English
grammar
50
Figure 3.25: And/or graph for the grammar of Example 3.3.6. Some of the nodes (np, art, etc.)
have been written more than once to simplify drawing the graph.
51
Parse tree for the sentence
52
“Blind search”
53
BFS and DFS
54
Evaluating BFS
• Complete?
Yes
• Optimal quality solution?
Yes
• Time required in the worst case
O(bd)
• Memory required in the worst case (in OPEN)
O(bd)
where b is the branching factor, d is the depth
of the solution
55
Evaluating DFS
• Complete?
Yes (only if the tree is finite)
• Optimal quality solution?
No
• Time required in the worst case
O(bm)
• Memory required in the worst case (in OPEN)
O(bm)
where b is the branching factor, m is the
maximum depth of the tree
56
Example search problems
57
The importance of the problem space
58