Unit1 Class3.3 Informed Search
Unit1 Class3.3 Informed Search
Preethi.P
Department of Computer Science & Engineering
Machine Intelligence
Informed Search Strategy
• Informed Search algorithms have information on the goal state which helps in
more efficient searching. This information is obtained by a function f(n) that
estimates how close a state is to the goal state
• The evaluation function f(n) is a function that takes a node as a input and
gives out a positive number similar to the g(n) function we used in UCS.
• For example, when searching on google maps you give the search algorithm
information like a place you plan to visit from your current location for it to
accurately navigate the distance, the time taken and real-time traffic updates
on that particular route. This is all driven by complex Informed search
algorithms powering google maps search functionality.
Machine Intelligence
Informed Search vs Uninformed Search
Machine Intelligence
Heuristic function h(n)
h(n)= estimated cost of the cheapest path from the state at node n to a goal state
• Best first search uses the concept of a priority queue and heuristic search.
It is a search algorithm that works on a specific rule. The aim is to reach
the goal from the initial state via the shortest path
• The efficiency of the greedy best-first algorithm depends on how good the
heuristic function is.
• Special cases:
• Greedy best-first search
• A* search
Machine Intelligence
Greedy Best First Search
• Greedy best-first search tries to expand the node that is closest to the
goal, on the grounds that this is likely to lead to a solution quickly.
• Thus, it evaluates nodes by using just the heuristic function f(n)=h(n).
• The greedy best first algorithm is implemented by the priority queue.
• Psuedo Code
Machine Intelligence
Greedy Best First Search - Example
Adrad-->>>Bucharest
notice
The
the
yes
we
we will
h that
will
GOAL!!!
task
LSDnowtothe
use
explore
now
table values
find
straight
explore
begin
we of
isadrad
route
given
found
withhSLD
line
sibiu
from
and
for
the cannot
exploration
distance
and
example
choose
goal
ADRAD be
proceed
and computed
heuristic
the
from
h(adrad)=366
return
to one from
BURACHEST
with
adrad
with
the
same
paththe problem
lowest
stepshLSD (n)description itself
further
ad
ra
36
d 6
ti
mi
- 32 ze
rin
37
so
9 d 4
ar
a
si
bi
25
u 3
ri
ad
ra
36 or
ad
38 mi 19
ne
d 6 ea 0 u 3
fa
ga 17
ra
s 6
si 25 buch
bi
arest 0
u 3
Machine Intelligence
Lets Analyse
TIME
COMPLETE SPACE OPTIMALIT
COMPLEXI
NESS COMPLEXITY Y
TY
Advantages:
• Best first search can switch between BFS and DFS by
gaining the advantages of both the algorithms.
• This algorithm is more efficient than BFS and DFS
algorithms.
Disadvantages:
• It can behave as an unguided depth-first search in the
worst case scenario.
• It can get stuck in a loop as DFS.
• This algorithm is not optimal
Machine Intelligence
A* Search
Admissibility
• An admissible heuristic is one that never overestimates EXAMPLE:
the cost to reach the goal. straight-line distance hSLD
Straight-line distance is
• A heuristic h(n) is admissible if for every node n, h(n) ≤ admissible because the
shortest path between any
h*(n), where h*(n) is the true cost to reach the goal state
two
from n points is a straight line, so
the
• Admissible heuristics are by nature optimistic because straight line cannot be an
they think the cost of solving the problem is less than it overestimate.
actually is.
Machine Intelligence
Conditions for optimality
Consistency / Monotone
• A heuristic h(n) is consistent , if its
estimate is always less than or equal to the
estimated distance from any neighboring
vertex to the goal, plus the cost of reaching
that neighbor
• Consistent heuristic is also admissible
• Consistency is therefore a stricter
requirement than admissibility,
Machine Intelligence
A* Search - Example
G3, 1
1 0
C,4 G2, 1 5
3 F,6 21
0 3
TIME SPACE
COMPLETE
COMPLEXIT COMPLEXIT
NESS OPTIMALITY
Y Y
Yes
(unless there
are infinitely Keeps all nodes
Exponential YES
many in memory
nodes with
f ≤ f(G) )
Machine Intelligence
Applications of A*
• In the Eight-puzzle, for example, the function h(n)=W(n) (where W (n) is the
number of tiles in the wrong place) is a lower bound on h (n), but it does not
provide a very good estimate of the difficulty (in terms of number of steps to
the goal) of a tile configuration.
• A better estimate is the function h(n)=P(n), where P(n) is the sum of the
(Manhattan) distances that each tile is from “home” (ignoring intervening
pieces)
Manhattan Distance
7 2 4 1 2
5 6 3 4 5
8 3 1 6 7 8
GOAL STATE
1 2 3 4 5 6 7 8
We calculate the distance between all the tiles from the goal state
h2 (S) = 3 + 1 + 2 + 2 + 2 + 3 + 3 + 2 = 18
Similarly we calculate the distance between the remaining slides and their sum
gives the manhattan distance
Machine Intelligence
Choice of a Heuristic
It is the distance between the current cell and the goal cell using the
distance formula
Nishtha Varshney
Department of Computer Science & Engineering
[email protected]