You are on page 1of 27

In Last Week

• We use heuristic function h(n)


• We select promising state on the
basis of evaluation function
f(n)=h(n)
• Hill Climbing Algorithm
• Greedy Best First Search
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
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
Heuristics Dilemma

A Possible Result of a Heuristic Search Procedure


Evaluation Function
• If two states have same or nearly same
heuristic evaluation
• Because the heuristic are fallible, it is
possible search algorithm misled down
some path that fails to lead the goal
• It is generally preferable to examine the
state that is near to the root state
• The distance from starting state is
measured in g(n) note for initial state
g(n)=0
• Now our evaluation function will be ;
f(n)= g(n)+ h(n)
Introducing g(n)
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
A* search example

10
A* search example

11
A* search example

12
A* search example
A* search example
A* search example
1
2 8 3
Open=[a4] State a g(n)=0
1 6 4
f(a)=4
Closed=[ ] 7 5
1
2 8 3
Open=[a4] State a g(n)=0
1 6 4
f(a)=4
Closed=[ ] 7 5

g(n)=1
1 1
2 8 3 2 8 3 2 8 3
State b State c State d
1 6 4 1 4 1 6 4
f(b)=6 f(c)=4 f(d)=6
7 5 7 6 5 7 5

Open=[c4,b6,d6] Closed=[a4]
Admissibility, Monotoncity and
Informed-ness
• We judge the behavior of heuristic on
number of dimensions
• Heuristic that find the shortest path to a
goal whenever it exists are said to be
admissible
• In what sense one heuristic is better than
other this is the informed ness of a
heuristic
• Monotone heuristic are locally optimal
Admissibility
• If a search algorithm ensure shortest
path from initial state to the goal
state it is admissible
• Breath first search is an admissible
search strategy
• But cost of this algorithm make it
inapplicable
• Using the evaluation function
f(n)=g(n)+h(n), we define the
class of admissible algorithms
Admissibility
• For determining the property of
admissibility we define the evaluation
function f*(n)=g*(n)+h*(n) where:
g*(n)  actual cost of shortest
path from start to n node
h*(n)  return actual cost of
shortest path from n to goal node
Algorithm A: consider the
evaluation function f(n)=g(n)+h(n) if
this is used by the best_first_search
it is called Algorithm A
A* Algorithm
• If algorithm A is used with and
evaluation function in which:
h(n) ≤ h*(n)
the resulting algorithm is called A*
algorithm
• All A* algorithm are admissible
Admissible heuristics
For the 8-puzzle:
• h1(n) = number of misplaced tiles
• h2(n) = total Manhattan distance
• For Romani Map
• HSLD
Monotonicity
• A* algorithm did not require
g(n)=g*(n)
• Mean admissible can reach on sub
optimal paths initially
• If there are heuristic that are locally
admissible i.e. that constantly find
minimal path to each state that
encounter in search
• This property of heuristic is called
monotonic
Monotonicity
• A heuristic function is monotone if :
1. For all states ni and nj where nj is
descendent of ni : h(ni)
– h(nj) ≤ cost(ni,nj)
2. The heuristic evaluation of goal
state is zero h(goal)=0
• We can say that heuristic is
everywhere admissible
Better Heuristic (Informed-
ness)
• For two heuristic h1 and h2 if
h1(n) ≤ h2(n) for all states n in
search space, heuristic h2 is more
informed
• For more informed algorithm less
space is required to expand to the
goal state
Search Cost for 8-Puzzle game
d IDS A*(h1) A*(h2)
2 10 6 6
4 112 13 12
6 680 20 18
8 6384 39 25
10 47127 93 39
12 3644035 227 73
14 - 539 113
16 1301 211
18 3056 363
20 7276 676
22 18094 1219
24 39135 1641

You might also like