You are on page 1of 21

Heuristics Search

• The study of methods or rules of


discovery
• Derived from Greek term ‘eurisco’
means ‘I discover’
• In AI heuristic are formalize as rules
for choosing those branches in state
space that are most likely lead to an
acceptable problem solution
• We select promising state on the
basis of evaluation function f(n)
Heuristics Search
AI problem solver apply heuristic most of
time on two basic situations;
1. Problem may not have exact solution
because of inherent ambiguities in the
problem statement or available data i.e.
Medical diagnosis and visionary scenes
are examples of this
2. A problem may have exact solution
but cost of finding it is prohibitive i.e.
chess game. state space grow
exponentially. Heuristic attack this
problem by selecting the most promising
states and ignoring others thus reducing
state space
Heuristics Search
• Unfortunately, like all rules of discovery
and invention, heuristic are fallible.
• A heuristic can lead a search algorithm to
a suboptimal solution or fail to find any
solution
• By designing good heuristics, this element
can be reduced but not completely
eliminated by designing good heuristics
• In spite of this limitation heuristics are
very helpful in the area of game
designing and expert systems
Heuristic Evaluation Function
• State expansion is based on an evaluation
function, f(n).
• Node with the lowest evaluation is
expanded first like Uniform-cost search
• HEURISTIC include as a component of f (n)
heuristic function, denoted h(n):
• h(n) = estimated cost of the cheapest path
from the state at node n to a goal state.
• h(n) is not g(n)
• if n is a goal node, then h(n)=0
Heuristics Search
• Systematically, heuristic algorithm
consists of two parts :
i. A heuristic measure h(n) : which
is an informed guess from n state
to goal state
ii. An algorithm : that uses the h(n)
to search in the state space
Heuristics for TIC TAC TOE
– (9!=326880) nodes to search
• A simple heuristic can be number of
wining lines which reduce almost the
2/3 of state space
X X
X

h(n)=3 h(n)=4 h(n)=2

Heuristics for State Space for TIC TAC TOE


Graph of Romania

Start
State

Goal
State
Graph of Romania (Heuristic Function)

in Romania, one might estimate the cost of the cheapest path from
Arad to Bucharest via the straight-line distance from Arad to Bucharest.
Algorithms Of Heuristics
Search
Hill Climbing
• Expand current state and evaluate its
children
• The best child is selected for further
expansion
• Neither its sibling nor its parents are
retained
• Because it keeps no history, it can be
caught in local maxima
Best First Search
• Also called greedy best first search
• Uses the approach of hill climbing strategy
but maintain the record
• open: to maintain the current fringe of
search
• close: to record the stated already
visited
• It arranges the states in open list
according to some heuristic estimate of
their closeness towards the goal
• On each iteration algorithm considers the
most promising state on basis of
evaluation function f(n)
• Note in this algorithm f(n)=h(n)
Romania with step costs in km

12
Greedy best-first search
Evaluation function f(n) = h(n) (heuristic)
◦= estimate of cost from n to goal
e.g., hSLD(n) = straight-line distance from n to
Bucharest
Greedy best-first search expands the node
that appears to be closest to goal

13
Greedy best-first search example
Greedy best-first search example

15
Greedy best-first search example

16
Greedy best-first search example

17
Properties of greedy best-first search

Complete? No – can get stuck in loops, e.g.,


Iasi  Neamt  Iasi  Neamt  …
Time? O(bm), but a good heuristic can give
dramatic improvement
Space? O(bm) -- keeps all nodes in memory
Optimal? No

18
Implementing Heuristic
Evaluation Function
• Consider the 8-puzzle game
2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5

• Average solution cost 22 steps the


branching factor is 3
• This mean that an exhaustive search
would look at about 322 ≈ 3.1 * 1010
8-puzzle game
• So it is impossible to search this kind of
state space
• We use heuristic, one possible heuristic
could be the number of tiles out of place
• h1(n): number of tile out of place
• This heuristic did not consider the distance
a tile have to cover so,
• h2(n):the sum of distance of tiles from
the goal
• Also suffer from the problem of direct
reversal
h1(n): 4
2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5

2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5

h2(n): 1+2+1+1=5

You might also like