Artificial Intelligence: Course Instructor: Dr. Muhammad Kamran Malik
Artificial Intelligence: Course Instructor: Dr. Muhammad Kamran Malik
Lecture 3
Artificial Intelligence
Course Instructor: Dr. Muhammad Kamran Malik
Note: Some slides and/or pictures are adapted from Lecture slides / Books of
• Dr Zafar Alvi.
• Text Book - Aritificial Intelligence Illuminated by Ben Coppin, Narosa Publishers.
• Ref Books
• Artificial Intelligence- Structures & Strategies for Complex Problem Solving by George F. Luger, 4th edition,
Pearson Education.
• Artificial Intelligence A Modern Approach by Stuart Russell & Peter Norvig.
• Artificial Intelligence, Third Edition by Patrick Henry Winston
Outline
• Problems and their representation
• Goal Driven VS Data Driven
• Properties of search Methods
• Tree search algorithm
– Depth First algorithm
– Breadth First algorithm
– Iterative Deepening algorithm
Problems and their Representations
• Traversing a Maze
Data Driven or Goal Driven Search
• Data-driven search starts from an initial state
and uses actions that are allowed to move
forward until a goal is reached. This approach
is also known as forward chaining.
• Search can start at the goal and work back
toward a start state, by seeing what moves
could have led to the goal state. This is goal-
driven search, also known as backward
chaining.
Properties of Search Methods
• Complexity
• Completeness
• Optimality
• Admissibility
• Irrevocability
Complexity
• It is useful to describe how efficient that
method is, over time and space.
• The time complexity of a method is related to
the length of time that the method would take
to find a goal state.
• The space complexity is related to the amount
of memory that the method needs to use.
Completeness
• A search method is described as being
complete if it is guaranteed to find a goal state
if one exists.
• A method that is not complete has the
disadvantage that it cannot necessarily be
believed if it reports that no solution exists.
Optimality
• A search method is optimal if it finds a
solution in the quickest possible time.
Admissibility
• An algorithm is then defined as admissible if it
is guaranteed to find the best solution.
Irrevocability
• Methods that do not use backtracking, and
which therefore examine just one path, are
described as irrevocable.
• Irrevocable search methods will often find
suboptimal solutions to problems because
they tend to be fooled by local optima—
solutions that look good locally but are less
favorable when compared with other solutions
elsewhere in the search space.
Tree search algorithms
• Basic idea:
– offline, simulated exploration of state space by generating
successors of already-explored
Tree search example
Tree search example
Tree search example
Uninformed search strategies
• Uninformed search strategies use only the
information available in the problem definition
• Depth-first search
• Breadth-first search
– Iterative deepening search
– etc
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Expand deepest unexpanded node
• Implementation:
• put successors at front
–
Depth-first search
Function depth ()
{
queue = []; // initialize an empty queue
state = root_node; // initialize the start state
while (true)
{
if is_goal (state)
then return SUCCESS
else add_to_front_of_queue (successors (state));
if queue == []
then report FAILURE;
state = queue [0]; // state = first item in queue
remove_first_item_from (queue);
}
}
Breadth-first search
Expand shallowest unexpanded node
• Implementation:
• new successors go at end
–
Breadth-first search
Expand shallowest unexpanded node
• Implementation:
• new successors go at end
–
Breadth-first search
Expand shallowest unexpanded node
• Implementation:
• new successors go at end
–
Breadth-first search
Expand shallowest unexpanded node
• Implementation:
• fringe is a FIFO queue, i.e., new successors go at end
–
Breadth-first search
Function breadth ()
{
queue = []; // initialize an empty queue
state = root_node; // initialize the start state
while (true)
{
if is_goal (state)
then return SUCCESS
else add_to_back_of_queue (successors (state));
if queue == []
then report FAILURE;
state = queue [0]; // state = first item in queue
remove_first_item_from (queue);
}
}
1. Traversing a maze
2. Searching for a gift
Iterative deepening search l =0
Iterative deepening search l =1
Iterative deepening search l =2
Iterative deepening search l =3
Iterative deepening search
• Number of nodes generated in a depth-limited search to depth d with
branching factor b:
NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd
• GP
• For b = 10, d = 5,
• NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
–
– NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
–