You are on page 1of 13

A* Algorithm

Objectives
To Answer Explain A* algorithm in detail Comparison with Best First/Hill Climbing Problems of overestimating & Underestimating h(n) Admissibility condition in A* Compare A* and AO*

Evaluation Function : a value that estimates how far a particular node is from the goal.
Cost Function : how much resources like time, money, energy have been spent in reaching a particular node from start. The sum of the evaluation function value and the cost along the path leading to that state is called as Fitness number

In Best first search we used Evaluation function alone but in A* we decide the next state to be selected based upon both Evaluation function and Cost Function.

Fitness Number ( f(n) )


f(n) is a heuristic function that estimates the merits of each node that we generate. Dash in the function indicates that its an approximation to a function, f(n) that gives actual or true evaluation of the node. f(n)=g(n) + h(n) Where,
f(n) is estimated cost of the cheapest solution through n. h'(n) is an estimate of additional cost of getting from current node to goal state. g(n) is an estimate of getting from initial node to current node.

For state space tree problems g(n) = g(n) Therefore, heuristic function for state space tree problem f(n)=g(n)+h(n)
By introducing g(n) into f(n) we will not be always choosing the node to expand that appears to be the closest to the goal.

A* can be used when we need to find a minimal-cost overall path or simply any path as quickly as possible.

h(n) is a measure of the cost of getting from the node to a solution. Therefore good nodes get low values and bad nodes get high values.
What happens if h(n) is neither perfect nor zero? Two possibilities
h(n) underestimates h(n) h(n) overestimates h(n)

h Underestimating h

h overestimating h

3+1 B 2+2 E 1+3 F 0+4 G A

4+1
C

5+1
D

How we Evaluate f(n) with ex:


While Best first Search uses the evaluation function value only for expanding the best node, A* uses the fitness number for its computation. Thus if we are trying to find the cheapest solution, a reasonable thing to try first is the node with the lowest value of g(n)+h(n).

Algorithm For A*
1: Put the initial node on a list OPEN 2: If ( OPEN is empty ) or ( OPEN = GOAL) terminate search. 3: Remove the first node from OPEN. Call this node a. 4: If (a=GOAL) terminate search with success. 5: Else if node a has successors, generate all of them. Estimate the fitness number of the successors by totaling the evaluation function value and cost-function value. Sort the list by fitness number. 6: Name the new list as CLOSED 7: Replace OPEN with CLOSED 8: Goto Step 2.

Common properties of Heuristic Search Algorithm Admissibility Condition


3 Conditions to be satisfied by A* to be admissible. 1: Each node in the graph has finite numbers of successors ( or 0 ) 2: All arcs in the graph have costs greater than some positive amount, (say C) 3: For each node in the graph, n h(n)<=h(n)

Only if these three conditions are satisfied A* is guaranteed to find an optimal(least) cost path.

Diff b/w A* & AO*


Rather than 2 lists OPEN and CLOSED in A*, the AO* algorithm use a single structure GRAPH representing the part of search graph explicitly generated so far. In AO* Each node has only value h associated with it, it will not store g( the cost of getting from start to current node) as in A*as, Its not possible to compute a single such value since there may be many paths to same state.

You might also like