You are on page 1of 2

A* algorithm (informed search technique)

- An admissible algorithm that guarantees optimal solution.


- Informed search implies that we have some knowledge about the problem/domain to be
solved, this knowledge is referred to as heuristic (estimation). We always have a goal state
in mind.
- In artificial intelligence (in heuristic or informed search) A* algorithm is the most important
one.
- Notice the equation f(N) = g(N) + h(N)
o where g(N)is actual cost from start node to n

B
IS
o And h(N) is estimated cost from n to Goal node
- Notice that n is referred as intermediate node(s) that takes us to the goal state.

ol
Now let’s consider the following graph

ho
Sc
rt
sa
ad
He
-
d
oo
qs
Ma

S = start node
G = Goal node
M.

Notice all other intermediate nodes are n nodes. The value(s) mentioned in black on the edge(s)
s

are the actual cost. And the values mentioned in red are estimated or heuristic cost.
au

The neighboring nodes of S are B and C


Gh

S → B = 4 (actual cost) + 12 (estimated cost/heuristic value) = 16; S → C = 3 + 11 = 14

As we can see 14 is a smaller value, we will opt to move towards C


The path is now S→C→ E = 3 + 10 + 4 = 17 or S→C → D = 3 + 7 + 6 = 16

Notice that the cost of moving from S→C → D is equals to the cost of moving from S→B i.e. 16.
We need to explore both of the paths.
S→B→F = 4 + 5 + 11 = 20 or S→B→E = 4 + 12 + 4 = 20

Page 1 of 2 - A* algorithm - Heuristics approach - informed search - AI AL CS


Notice both the values are equal but greater than the value for path S→C → D

We therefore need to move to S→C → D→E = 3 + 7 + 2 + 4 = 16

Our path now is S→C → D→E→G = 3 + 7 + 2 + 5 + 0 = 17

Note: The heuristic value of goal state is always set to 0.


The shortest path with minimum cost is S→ C → D→ E→ G

B
Example:

IS
Find the shortest path between the Home and School nodes using the A* algorithm.
Show your working in the table provided.

ol
ho
Sc
rt
sa
ad
He
-
d
oo
qs
Ma

Node Cost from home node Heuristic Total = (f = g + h)


(g) (h)
Home 0 14 14
M.

A 1 10 11
B 5 7 12
s

C 4 9 13
au

B 1+3 = 4 7 11
Gh

E 1+6 = 7 3 10
F 7+1 = 8 3 11
School 7+5 = 12 0 12
School 8+3 = 11 0 11

Final/shortest path: Home → A → E →F →School

Page 2 of 2 - A* algorithm - Heuristics approach - informed search - AI AL CS

You might also like