Unit 5 - Informed Search
Unit 5 - Informed Search
ARTIFICIAL
INTELLIGENCE
Unit 5
05/06/2024 Spring' 2024 2
Outline
• Uninformed Search
• Uniform Cost Search
• Informed Search
• Introduction
• Heuristics
• Best First Greedy Search
• A* Search
05/06/2024 Spring' 2024 3
Acknowledgment
• Some of the slides of this lecture have been taken from:
• The lecture slides of CS188 – “Introduction to Artificial Intelligence”
UC Berkeley
05/06/2024 Spring' 2024 4
Example Graph
05/06/2024 Spring' 2024 18
UCS Algorithm
05/06/2024 Spring' 2024 19
UCS Example
• It is important to note in this example that the USC does not stop
until the goal node is the top most node of the list. Which means
that we have found the optimal path.
05/06/2024 Spring' 2024 20
UCS Properties
• Is it complete?
• Assuming best solution has a finite cost and minimum arc cost is
positive, yes!
• Is it optimal?
05/06/2024 Spring' 2024 21
Informed Searches
05/06/2024 Spring' 2024 23
The 8-puzzle
• The puzzle consists of a 3 x 3 grid, with the
numbers 1 through 8 on tiles within the grid and
one blank square.
• Tiles can be slid about within the grid, but a tile
can only be moved into the empty square if it is
adjacent to the empty square.
• The start state of the puzzle is a random
configuration, and the goal state is as shown in
the picture below.
Goal State
05/06/2024 Spring' 2024 25
Heuristic Function
• Heuristic is an “estimate of the proximity of the goal”.
Heuristics
( Source: Wikipedia)
• Heuristic refers to experience-based techniques for
problem solving, learning, and discovery.
Heuristic # 1
• The first heuristic we consider is to count
how many tiles are in the wrong place.
We will call this heuristic, h1(node).
Heuristic # 2
• An improved heuristic, h2, takes into account
how far each tile had to move to get to its correct
state.
• This is achieved by summing the Manhattan
distances of each tile from its correct position.
• Manhattan distance is the sum of the horizontal
and vertical moves that need to be made to get
from one position to another, named after the
grid system of roads used in Manhattan.
• h2 (node) = 2 + 2 + 2 + 2 + 3 + 3 + 1 + 3 = 18
• It is worth noting that h2 (node) ≥ h1 (node) for
any node. This means that h2 dominates h1,
implying that a search method using heuristic h2
will always perform more efficiently than the
same search method using h1.
05/06/2024 Spring' 2024 30
Best-first search
• Best-first search expands the node that appears to be
closest to goal
• Evaluation function f(n) = h(n) (heuristic)
• = estimate of cost from n to goal
05/06/2024 Spring' 2024 31
Best-first Search
(Using Heuristic # 1)
Goal State
05/06/2024 Spring' 2024 32
Best-first Search
(Using Heuristic # 2)
2 8 3
1 6 4
7 5
Goal State
A* search
Idea: avoid expanding paths that are already expensive
• Evaluation function f(n) = g(n) + h(n)
• g(n) = cost so far to reach n
• h(n) = estimated cost from n to goal
• f(n) = estimated total cost of path through n to goal
05/06/2024 Spring' 2024 39
A* search example
05/06/2024 Spring' 2024 41
A* search example
05/06/2024 Spring' 2024 42
A* search example
05/06/2024 Spring' 2024 43
A* search example
05/06/2024 Spring' 2024 44
A* search example
05/06/2024 Spring' 2024 45
A* search example
05/06/2024 Spring' 2024 46
e h=1
1
1 3 2
S a d G
h=6 1 h=5 h=2 h=0
1
c b
h=7 h=6
Admissibility of a heuristic
• A heuristic h is admissible (optimistic) if:
• Example:
• If h(n) is exactly equal to the cost of moving from n to the goal, then A*
will only follow the best path and never expand anything else, making it
very fast. It’s nice to know that given perfect information, A* will behave
perfectly.