Chapter 4 - Searching The Knowledge Space I
Chapter 4 - Searching The Knowledge Space I
Chapter 4 - Searching The Knowledge Space I
Artificial Intelligence
Chapter 4: Searching the
Knowledge Space – Uninformed
Search
1
Introduction
• When solving a problem, it’s convenient to
think about the solution space in terms of a
number of actions that we can take, and the
new state of the environment as we perform
those actions
• The space problem is represented by graph
• To find a solution is equivalent to searching a
path in graph
Introduction
• While solving the problem, some paths may
lead to dead-ends while others lead to
solutions
• there may also be multiple solutions, some
better than others.
• The problem of search is to find a sequence of
operators that transit from the start to goal
state.
• That sequence of operators is the solution.
Types of Search in AI
• We have two types of search:
• Uninformed or blind search and,
• Informed or heuristic search.
Artificial Intelligence 4
07:15 PM
Evaluating Search Strategies
• Completeness: Is the strategy guaranteed to find a
solution if one exists?
• Optimality: Does the solution have low cost or the
minimal cost?
• Complexity: What is the search cost associated
with the time and memory required to find a
solution?
• Time complexity: Time taken (number of nodes expanded) (worst or
average case) to find a solution.
• Space complexity: Space used by the algorithm measured in terms of
the maximum size of fringe
Evaluating Search Strategies
• Big-O is used to compare the algorithms.
– Defines asymptotic upper bound given:
• Depth of tree (d).
• Average number of branches (b) (branch factor).
Uninformed Search
• The uninformed search methods offer a
variety of techniques for graph search, each
with its own advantages and disadvantages
Artificial Intelligence 8
07:15 PM
Improvement on the Search Algorithm
1. Initialize: Open ={s} closed={}
2. Fail: If Open={} then return FAIL.
3. Select: select a state n from Open.
Save n in closed
4. Terminate:
If n ∈ G then terminate with success.
5. Expand:
Generate the successor of n using the
operators O. For each successor m, insert
them in Open if m ∉ (Open ∪ Closed).
6. Loop: Go to step 2.
Artificial Intelligence 9
07:15 PM
Depth First Search (DFS)
Depth First Search (DFS)
• Search each branch to its greatest depth.
• Treat Open list as stack (LIFO)
Artificial Intelligence
07:15 PM
Depth First Search
• Branch factor: b (Average number of branches ),
• goal depth: d, tree depth: m
• Space complexity: O(bm) (linear).
• Time complexity: O(bm)=1+b+b2+b3+…+bm (exponential).
m
Depth First Search
• Assume: b=10, space: 100 bytes/node,
• Time: 1000 nodes/seconds.
• Disadvantages:
– Can get stuck into wrong path, too deep.
Artificial Intelligence 14
07:15 PM
Comments on Depth First Search
• DFS is not optimal.
9 8 6 deQ 6 57
7 deQ 5 7
Path is {1,2,3,4,7} 8 deQ 7, goal found
Artificial Intelligence 19
07:15 PM
Complexity of Breadth First Search
• Branch factor = b. Depth = d.
• Space complexity: O(bd).
• Time complexity: 1+b+b2+b3+..bd = O(bd)
Artificial Intelligence 20
07:15 PM
Complexity of Breadth First Search
• Assume: b=10, 100 bytes/nodes,
1000nodes/second.
Depth Nodes Time Space
0 1 1 ms 100 bytes
2 1+b+b2=111 111 ms 11 kilobytes
4 11,111 11 seconds 1 megabytes.
6 ≅ 106 ≅ 17 minutes ≅ 100 megabytes
8 ≅ 108 ≅ 28 hours ≅ 11 gigabytes
10 ≅ 1010 ≅ 128 days ≅ 1 terabytes
12 ≅ 1012 ≅ 35 years ≅ 111 terabytes
Artificial Intelligence 21
07:15 PM
Comments on Breadth First Search
• BFS is complete
(The strategy guaranteed to find a solution if one
exists)
• BFS is optimal
(it can find the best goal, in terms of shortest
path to the node)
Artificial Intelligence 22
07:15 PM
Comparison of DFS and BFS