Best First Search & A-Star Algorithm
Best First Search & A-Star Algorithm
Best First Search & A-Star Algorithm
Combines the advantages of both DFS and BFS into a single method.
1
BEST-FIRST SEARCH
At each step of the BFS search process, we select the most
promising of the nodes we have generated so far.
We then expand the chosen node by using the rules to generate its
successors
2
BEST-FIRST SEARCH
A A A
B C D B C D
3 5 1 3 5
E F
4 6
A A
B C D B C D
5 5
G H E F G H E F
6 5 4 6 6 5 6
I J
3
2 1
BEST FIRST SEARCH VS HILL CLIMBING
Similar to Steepest ascent hill climbing with two exceptions:
In hill climbing, one move is selected and all the others are
rejected, never to be reconsidered. In BFS, one move is
selected, but the others are kept around so that they can be
revisited later if the selected path becomes less promising
The best available state is selected in the BFS, even if that
state has a value that is lower than the value of the state that
was just explored. Whereas in hill climbing the progress stop
if there are no better successor nodes.
4
BEST-FIRST SEARCH
OPEN: nodes that have been generated, but have not examined.
This is organized as a priority queue.
5
Algorithm : Best-First Search
1. Start with OPEN containing just the initial state.
(i) If it has not been generated before, evaluate it, add it to OPEN, and
record its parent.
(ii) If it has been generated before, change the parent if this new path
is better than the previous one. In that case, update the cost of
getting to this node and to any successors that this node may
already, have.
54
7
A* ALGORITHM
Best First Search is a simplification of A* Algorithm
Algorithm uses:
f’: Heuristic function that estimates the merits of each node we
generate. This is sum of two components, g and h’
f’ represents an estimate of the cost of getting from the initial state to a
goal state along with the path that generated the current node.
g : The function g is a measure of the cost of getting from initial
state to the current node.
h’ : The function h’ is an estimate of the additional cost of
getting from the current node to a goal state.
OPEN
CLOSED
8
ALGORITHM A*
Algorithm A* (Hart et al., 1968):
g(n) = cost of the cheapest path from the initial state to node n.
Algorithm A*:
9
A* ALGORITHM
1. Start with OPEN containing only initial node. Set that node’s g
value to 0, its h’ value to whatever it is, and its f’ value to h’+0
or h’. Set CLOSED to empty list.