0% found this document useful (0 votes)
48 views20 pages

AI Lecture 04

Uploaded by

Richmond Nkansah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views20 pages

AI Lecture 04

Uploaded by

Richmond Nkansah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Artificial Intelligence

Search… (continued)
Lecture 4

CS 444 – Spring 2019


Dr. Kevin Molloy
Department of Computer Science
James Madison University
Outline for Today
• Continuing discuss uninformed search methods and problem
formulation.

• Short quiz
Problem 3.6b
Given a complete problem formulation for each of the following. Choose a
formulation that is precise enough to be implemented.

A 3-foot tall monkey is in a room where some bananas are suspended from
the 8-foot ceiling. He would like to get the bananas. The room contains
two stackable, movable, climbable 3 foot-high crates.
Initial state: As described (monkey, bananas suspended from ceiling, 2 crates
on the floor in a room)
Goal state: Monkey has bananas.
Successor Hop on crate, hop off crate, move/push crate, place crate on top of a
function: stack of crates, walk from a spot to another spot, grab bananas.
Cost function: Number of actions.
Problem 3.6d
Given a complete problem formulation for each of the following. Choose a
formulation that is precise enough to be implemented.
You have three jugs, measuring 12 gallons, 8 gallons, and 3 gallons, and a
water faucet. You can fill the jugs up, empty them out from one to another
or onto the ground. You need to measure out exactly one gallon.
Initial state: Jugs empty [0, 0, 0]
Goal state: [x, y, 1] or [x, 1, z] or [1, y, z] (if too many states, we could state as
one of the 3 jugs has exactly 1 gallon of water)
Fill([x, y, z],(1 || 2|| 3)) → [12, y, z] or [x, 8, z] or [x, y, 3]
Successor Empty([x, y, z], (1 || 2 || 3)) → [0, y, z] or [x, 0, z] or [x, y, 0]
function:
Transfer (x,y) transfer the contains of y into x until either y is empty OR
x is at capacity.
Cost function: Number of actions.
Properties of Breadth-first Search (BFS)
Problems:
• If the path cost is a non-decreasing function of the depth of the goal node, BFS is optimal
(uniform cost search a generalization).
• A graph with no weights can be considered to have edges of weight 1, in this case, BFS is
optimal.
• BFS will find the shallowest goal after expanding all shallower nodes (if branching factor
is finite). Hence, BFS is complete.
• BFS is not very popular because time and space complexity are exponential (with respect
to d).
• Memory requirements of BFS are a bigger problem.
Time and Memory Requirements for BFS
Depth Nodes Time Memory
2 110 .11 milliseconds 107 KB
4 11,110 11 milliseconds 10.6 MB
6 106 1.1 seconds 1 GB
8 108 2 minutes 103 GB
10 1010 3 hours 10 TB
12 1012 13 days 1 PB
14 1014 3.5 years 99 PB
16 1016 350 years 10 EB

For a branching factor of b = 10; 1 million nodes/second and 1,000 byte nodes.
Properties of Search Strategies

Breadth First Search

Depth First Search


Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Depth-first Search (DFS)
Strategy: Expand deepest unexpanded node
Implementation:
Fringe = last-in first-out (LIFO), i.e., unvisited successors at front (F is a stack)
Properties of Depth-first Search (DFS)
Complete? No. Fails in infinite-depth spaces (space with loops).
Modify to avoid repeated states can make it finite.
Time? O(bm): terrible if m is much larger than d.

Space? O(bm) i.e., linear in space !!!

Optimal? No

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 ∞ )
DFS Summary
Behavior
• Expands the deepest node in the tree
• Backtracks when reaches a non-goal node with no descendants
Problems:
• Makes a wrong choice and can go down an infinite path even though the solution may be
very close to initial vertex
• DFS is not optimal
• If subtree is of unbounded depth and contains no solutions, DFS will never terminate.
• Hence, DFS is not complete (in general)
• Let b be the maximum number of successors of any node, d be the depth of the
shallowest goal, and m be the maximum length of any path in the search tree
• Time complexity is O(bm) and space complexity is O(b · m)
Comparing BFS and DFS

When will BFS outperform DFS?

When will DFS outperform BFS?


Depth-limited Search (DLS)
• One problem with DFS is presence of infinite paths.
• DLS limits the depth of a path in the search tree of DFS.
• Modifies DFS by using a predetermined depth limit of dl.
• DLS is incomplete if the shallowest goal is beyond the depth limit dl.
• DLS is not optimal if d < dl
• Time complexity is now O(b dl) and space complexity is O(b·dl)
Iterative Deepening Search (IDS)
• Finds the best depth limit by incrementing dl until goal is found at dl = d.
• Can be viewed as running DLS consecutive values of dl
• IDS combines the benefits of both DFS and BFS
• Like DFS, its space complexity is O (b · d)
• Like BFS, it is complete when the branching factor is finite, and is optimal if the
path cost is a non-decreasing function of the depth of the goal node
• Its time complexity is O(bd)
• IDS is the preferred uninformed search when the state space is large, and the
depth of the solution is not known.
Summary of Uninformed Search Algorithms

Criterion BFS DFS DLS IDS


Complete? Yes No Yes if dl ≥ d Yes
Time bd+1 bm bdl bd
Space bd+1 bm bdl bd
Optimal? Yes* No No Yes*

You might also like