0% found this document useful (0 votes)
66 views20 pages

AI Module-2 (Informed Search) GIFT College

Informed search algorithms utilize domain knowledge to improve search efficiency, with examples including Greedy Best-First Search and A* Search. Greedy Best-First Search prioritizes paths based on heuristic values but may not guarantee optimal solutions, while A* Search combines actual and heuristic costs to ensure optimality and completeness. Both algorithms have their advantages and disadvantages, impacting their applicability to various problem-solving scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views20 pages

AI Module-2 (Informed Search) GIFT College

Informed search algorithms utilize domain knowledge to improve search efficiency, with examples including Greedy Best-First Search and A* Search. Greedy Best-First Search prioritizes paths based on heuristic values but may not guarantee optimal solutions, while A* Search combines actual and heuristic costs to ensure optimality and completeness. Both algorithms have their advantages and disadvantages, impacting their applicability to various problem-solving scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

AI Module-2(Informed

searchh)
Informed (Heuristics) Search:
• Informed search algorithms use domain knowledge. In an informed search, problem
information is available which can guide the search.
• Informed search strategies can find a solution more efficiently than an uninformed
search strategy. Informed search is also called a Heuristic search.
• Informed search can solve much complex problem which could not be solved in another
way.
• An example of informed search algorithms is a traveling salesman problem.
1.Greedy Search
2.A* Search

N.B:
Heuristic Function: Informed search algorithms use a heuristic function h(n) that
provides an estimate of the minimal cost from node n to the goal. This function
helps the algorithm to prioritize which nodes to explore first based on their
potential to lead to an optimal solution.
Greedy Best-First Search :
• Greedy Best-First Search is an AI search algorithm that attempts to find the
most promising path from a given starting point to a goal.
• It prioritizes paths that appear to be the most promising, regardless of whether
or not they are actually the shortest path.
• The algorithm works by evaluating the cost of each possible path and then
expanding the path with the lowest cost. This process is repeated until the goal
is reached.
• The algorithm works by using a heuristic function h(x) to determine which path
is the most promising.
• The evaluation function, f(x) for the greedy best-first search algorithm is the
following:
f(x) = h(x)
• It is the combination of both BFS and DFS algorithm.
• Greedy BFS is not optimal and in complete (without systemetic checking of
repeated states).
• Time and space complexity of greedy search are both O(bm), where b= branching
factor and m= maximum path lenth
Algorithm Steps:
1.Initialize the open list (priority queue) with the start node.
2.Initialize the closed list (visited nodes) as empty.
3.While the open list is not empty:
1. Remove the node with the smallest heuristic value from the open list.
2. If the removed node is the goal, return the solution.
3. Otherwise, expand the node and add its neighbors to the open list if they
have not been visited.
4. Add the current node to the closed list.
4.If the open list becomes empty without finding a solution, return failure.
Example:Consider finding the path from P to S in the following graph:

In this example, the cost is measured strictly using the


heuristic value. In other words, how close it is to the
target.

C has the lowest cost of 6. Therefore, the search will


continue like so:
U has the lowest cost compared to M and R, so the search will continue by exploring U. Finally, S has a
heuristic value of 0 since that is the target node:
The total cost for the path (P -> C -> U -> S) evaluates to 11. The potential problem with a greedy
best-first search is revealed by the path (P -> R -> E -> S) having a cost of 10, which is lower than
(P -> C -> U -> S). Greedy best-first search ignored this path because it does not consider the
edge weights that is why it is not optimal.
Advantages of Greedy Best-First Search:
•Simple and Easy to Implement
•Fast and Efficient
•Low Memory Requirements
•Flexible: Greedy Best-First Search can be adapted to different types of problems and can be easily
extended to more complex problems.
•Efficiency: If the heuristic function used in Greedy Best-First Search is good to estimate, how close
a node is to the solution, this algorithm can be a very efficient and find a solution quickly, even in
large search spaces.

Disadvantages of Greedy Best-First Search:


•Inaccurate Results: Greedy Best-First Search is not always guaranteed to find the optimal solution,
as it is only concerned with finding the most promising path.
•Local Optima: Greedy Best-First Search can get stuck in local optima, meaning that the path
chosen may not be the best possible path.
•Heuristic Function: Greedy Best-First Search requires a heuristic function in order to work, which
adds complexity to the algorithm.
•Lack of Completeness: Greedy Best-First Search is not a complete algorithm, meaning it may not
always find a solution if one is exists. This can happen if the algorithm gets stuck in a cycle or if the
search space is a too much complex.
A* Search :
• A* (pronounced "A-star") is a powerful graph traversal and pathfinding
algorithm widely used in artificial intelligence and computer science.
• It is mainly used to find the shortest path between two nodes in a graph,
given the estimated cost of getting from the current node to the destination
node.
• The main advantage of the algorithm is its ability to provide an optimal path
by exploring the graph in a more informed way compared to traditional
search algorithms such as Dijkstra's algorithm.
• A heuristic function, denoted h(n), estimates the cost of getting from any
given node n to the destination node.
• The main idea of A* is to evaluate each node based on two parameters:
g(n): the actual cost to get from the initial node to node n. It represents
the sum of the costs of node n outgoing edges
h(n): Heuristic cost (also known as "estimation cost") from node n to
destination node n.
So, evaluation function, f(n)=g(n) + h(n)
Steps of the A* Algorithm:
1.Initialize:
1. Add the start node to the open list, with an initial cost f(start) = g(start) + h(start).
Set g(start) = 0.
2.Process the Open List:
1. While the open list is not empty, select the node n with the lowest f(n) from the
open list.
2. If n is the goal, return the path from the start to the goal.
3. Otherwise, move n from the open list to the closed list.
3.Expand Node:
1. For each neighbor of n:
1.If the neighbor is in the closed list, skip it.
2.Calculate g(neighbor) and f(neighbor).
3.If the neighbor is not in the open list or the newly calculated g(neighbor) is
smaller than the previously recorded value, update the node and set its parent to
n.
4.Repeat: Continue processing the open list until the goal is reached or the open list
becomes empty.
Example:

Each edge has an associated weight, and each node has


a heuristic cost (in parentheses).
An open list is maintained in which the node S is the only
node in the list. The search tree can now be constructed.
Exploring S:

A is the current most promising path, so it is explored


next:
Exploring D:
Exploring F:

Notice that the goal node G has been found. However, it hasn’t been explored, so the algorithm continues
because there may be a shorter path to G. The node B has two entries in the open list: one at a cost of 16
(child of S) and one at a cost of 18 (child of A). The one with the lowest cost is explored next:
Exploring C:

The next node in the open list is again B. However, because B has already been
explored, meaning a shortest path to B has been found, it is not explored again and the
algorithm continues to the next candidate.
The next node to be explored is the goal node G, meaning the shortest path to G has been
found! The path is constructed by tracing the graph backward from G to S:
•Time Complexity: Depends on the heuristic. In the worst case, it can approach
O(b^d) where b is the branching factor and d is the depth of the solution.
•Space Complexity: A* stores all generated nodes, so it requires O(b^d) space as well.

A* is complete (it will find a solution if one exists) and optimal (it will find the shortest
path), provided that the heuristic is admissible (i.e., it never overestimates the true
cost).

You might also like