0% found this document useful (0 votes)
26 views

Unit 1 Informed Search-Introduction

The document discusses informed search algorithms including best-first search and A* search. It provides details on how heuristic functions are used to estimate distances to the goal state and guide the search. The key aspects covered include admissibility of heuristics, maintaining open and closed lists, and calculating path costs.

Uploaded by

by708931
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Unit 1 Informed Search-Introduction

The document discusses informed search algorithms including best-first search and A* search. It provides details on how heuristic functions are used to estimate distances to the goal state and guide the search. The key aspects covered include admissibility of heuristics, maintaining open and closed lists, and calculating path costs.

Uploaded by

by708931
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Informed Search-Introduction

• Informed search algorithm contains an array of


knowledge such as how far we are from the goal,
path cost, how to reach to goal node, etc.
• This knowledge help agents to explore less to the
search space and find more efficiently the goal
node.
• The informed search algorithm is more useful for
large search space.
• Informed search algorithm uses the idea of
heuristic, so it is also called Heuristic search.
Heuristics function:
• Heuristic is a function which is used in Informed Search, and it finds the
most promising path.
• It takes the current state of the agent as its input and produces the
estimation of how close agent is from the goal.
• The heuristic method, however, might not always give the best solution,
but it guaranteed to find a good solution in reasonable time.
• Heuristic function estimates how close a state is to the goal.
• It is represented by h(n), and it calculates the cost of an optimal path
between the pair of states.
• The value of the heuristic function is always positive.
• Admissibility of the heuristic function is given as:
h(n) <= h*(n)
• Here h(n) is heuristic cost, and h*(n) is the estimated cost. Hence
heuristic cost should be less than or equal to the estimated cost.
Pure Heuristic Search:
• Pure heuristic search is the simplest form of heuristic search
algorithms.
• It expands nodes based on their heuristic value h(n). It maintains two
lists, OPEN and CLOSED list.
• In the CLOSED list, it places those nodes which have already
expanded and in the OPEN list, it places nodes which have yet not
been expanded.
• On each iteration, each node n with the lowest heuristic value is
expanded and generates all its successors and n is placed to the
closed list.
• The algorithm continues until a goal state is found.
• In the informed search we will discuss two main algorithms which are given
below:
• Best First Search Algorithm(Greedy search)
• A* Search Algorithm
1.) Best-first Search Algorithm (Greedy Search):
• Greedy best-first search algorithm always selects the path which
appears best at that moment.
• It is the combination of depth-first search and breadth-first search
algorithms.
• It uses the heuristic function and search. Best-first search allows
us to take the advantages of both algorithms.
• With the help of best-first search, at each step, we can choose the
most promising node.
• In the best first search algorithm, we expand the node which is
closest to the goal node and the closest cost is estimated by
heuristic function, i.e.
f(n)= g(n).
• Were, h(n)= estimated cost from node n to the goal.
Best-first Search Algorithm
• Step 1: Place the starting node into the OPEN list.
• Step 2: If the OPEN list is empty, Stop and return failure.
• Step 3: Remove the node n, from the OPEN list which has the lowest
value of h(n), and places it in the CLOSED list.
• Step 4: Expand the node n, and generate the successors of node n.
• Step 5: Check each successor of node n, and find whether any node is a
goal node or not. If any successor node is goal node, then return success
and terminate the search, else proceed to Step 6.
• Step 6: For each successor node, algorithm checks for evaluation
function f(n), and then check if the node has been in either OPEN or
CLOSED list. If the node has not been in both list, then add it to the OPEN
list.
• Step 7: Return to Step 2.
Best-first Search Algorithm
• We start from source “S” and search for goal “I” using given costs and Best
First search.

• pq initially contains S
• We remove S from pq and process unvisited neighbors of S to pq.
• pq now contains {A, C, B} (C is put before B because C has lesser cost)

• We remove A from pq and process unvisited neighbors of A to pq.


• pq now contains {C, B, E, D}

• We remove C from pq and process unvisited neighbors of C to pq.


• pq now contains {B, H, E, D}

• We remove B from pq and process unvisited neighbors of B to pq.


• pq now contains {H, E, D, F, G}
• We remove H from pq.
• Since our goal “I” is a neighbor of H, we return. SACBI
Best-first Search Algorithm

• Time Complexity: The worst case time complexity of


Greedy best first search is O(bm).
• Space Complexity: The worst case space complexity
of Greedy best first search is O(bm). Where, m is the
maximum depth of the search space.
• Complete: Greedy best-first search is also
incomplete, even if the given state space is finite.
• Optimal: Greedy best first search algorithm is not
optimal.
A* Algorithm-
• A* Algorithm is one of the best and popular techniques
used for path finding and graph traversals.
• A lot of games and web-based maps use this algorithm
for finding the shortest path efficiently.
• It is essentially a best first search algorithm.
• Working-
• A* Algorithm works as-
• It maintains a tree of paths originating at the start
node.
• It extends those paths one edge at a time.
• It continues until its termination criterion is satisfied.
• A* Algorithm extends the path that minimizes the following
function-
• f(n) = g(n) + h(n)
• Here,
• ‘n’ is the last node on the path
• g(n) is the cost of the path from start node to node ‘n’
• h(n) is a heuristic function that estimates cost of the cheapest path
from node ‘n’ to the goal node
• Algorithm-
• The implementation of A* Algorithm involves maintaining two lists-
OPEN and CLOSED.
• OPEN contains those nodes that have been evaluated by the heuristic
function but have not been expanded into successors yet.
• CLOSED contains those nodes that have already been visited.
The algorithm is as follows-
Step-01:
Define a list OPEN.
Initially, OPEN consists solely of a single node, the start node S.
Step-02:
If the list is empty, return failure and exit.
Step-03:
Remove node n with the smallest value of f(n) from OPEN and move it
to list CLOSED.
If node n is a goal state, return success and exit.
Step-04:
Expand node n.
Step-05:
If any successor to n is the goal node, return success and the solution by tracing the
path from goal node to S.
Otherwise, go to Step-06.

Step-06:

For each successor node,


Apply the evaluation function f to the node.
If the node has not been in either list, add it to OPEN.

Step-07:
Go back to Step-02.
The numbers written on edges represent the distance between the nodes.
The numbers written on nodes represent the heuristic value.
Find the most cost-effective path to reach from start state A to final state J using A* Algorithm.

Solution-

Step-01:

We start with node A.


Node B and Node F can be reached from node A.

A* Algorithm calculates f(B) and f(F).


f(B) = 6 + 8 = 14
f(F) = 3 + 6 = 9
Since f(F) < f(B), so it decides to go to node F.

Path- A → F
Step-02:
Node G and Node H can be reached from node F.
A* Algorithm calculates f(G) and f(H).
f(G) = (3+1) + 5 = 9
f(H) = (3+7) + 3 = 13
Since f(G) < f(H), so it decides to go to node G.
Path- A → F → G
Step-03:
Node I can be reached from node G.
A* Algorithm calculates f(I).
f(I) = (3+1+3) + 1 = 8
It decides to go to node I.
Path- A → F → G → I
Step-04:

Node E, Node H and Node J can be reached from node I.

A* Algorithm calculates f(E), f(H) and f(J).


f(E) = (3+1+3+5) + 3 = 15
f(H) = (3+1+3+2) + 3 = 12
f(J) = (3+1+3+3) + 0 = 10
Since f(J) is least, so it decides to go to node J.
Path- A → F → G → I → J
This is the required shortest path from node A to node J.
• Complete: A* algorithm is complete as long as:
• Branching factor is finite.
• Cost at every action is fixed.
• Optimal: A* search algorithm is optimal if it follows below two conditions:
• Admissible: the first condition requires for optimality is that h(n) should be
an admissible heuristic for A* tree search. An admissible heuristic is
optimistic in nature.
• Consistency: Second required condition is consistency for only A* graph-
search.
• If the heuristic function is admissible, then A* tree search will always find
the least cost path.
• Time Complexity: The time complexity of A* search algorithm depends on
heuristic function, and the number of nodes expanded is exponential to the
depth of solution d. So the time complexity is O(b^d), where b is the
branching factor.
• Space Complexity: The space complexity of A* search algorithm
is O(b^d)

You might also like