0% found this document useful (0 votes)
6 views39 pages

2-Module2 - Introduction To Problem Solving by Searching Methods-30-07-2024

Informed search algorithms utilize additional knowledge, such as heuristic functions, to efficiently navigate large search spaces and find goal nodes. The document discusses various strategies, including best-first search and A* algorithm, highlighting their mechanisms, advantages, and disadvantages. A* is noted for its optimality and completeness, though it can have high memory requirements and may not always yield the shortest path.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views39 pages

2-Module2 - Introduction To Problem Solving by Searching Methods-30-07-2024

Informed search algorithms utilize additional knowledge, such as heuristic functions, to efficiently navigate large search spaces and find goal nodes. The document discusses various strategies, including best-first search and A* algorithm, highlighting their mechanisms, advantages, and disadvantages. A* is noted for its optimality and completeness, though it can have high memory requirements and may not always yield the shortest path.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Informed Search

1
Informed Search
• The uninformed search algorithms which looked through search space for all
possible solutions of the problem without having any additional knowledge about
search space.
• But 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.

2
Informed Search
Strategies
● Add domain-specific information to select what is the best path to continue searching
along. Using this info it will choose the most promising node at each stage.
● Terminology:
● Define a heuristic function, h(n), that estimates the "goodness" of a node n with respect to
reaching a goal. i.e., cheapest estimated path from current state (n) to a goal state.
● g(n) – cheapest known path from start state to current state(n)
● f(n) = g(n) + h(n) = estimated total cost of path through n
● h(n) is an estimate (rule of thumb), based on domain-specific information that is
computable from the current state description.
● Heuristics do not guarantee feasible solutions and are often without theoretical
basis.
Heuristics function
• Heuristic is a function which is used in Informed Search,
and it finds the most promising path. ● In general:

• It takes the current state of the agent as its input and ● h(n) > = 0 for all nodes
produces the estimation of how close agent is from the n
goal. ● h(n) = 0 implies that n
• The heuristic method, however, might not always give the is a goal node
best solution, but it guaranteed to find a good solution in ● h(n) = infinity implies
reasonable time. that n is a dead end from
• Heuristic function estimates how close a state is to the goal. which a goal cannot be
It is represented by h(n), and it calculates the cost of an reached
optimal path between the pair of states.
• The value of the heuristic function is always positive .
4
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.

5
Best-first search

• The general approach we consider is called best first search.


• Best-first search is an instance of the general Tree-Search or
Graph-Search algorithm in which a node is selected for
expansion based on an evaluation function, f(n).
• The evaluation function is construed as a cost-estimate, so the
node with the lowest evaluation is expanded first.
• The implementation of best first graph search is identical to
that for Uniform-Cost Search, except for the use of f instead
of g to order the priority queue.

6
Best First Search
• A search method of selecting the best local choice at each step in hopes of finding
an optimal solution.
• Does not consider how optimal the current solution is.
• At each step, uses a heuristic to estimate the distance (cost) of each local choice
from the goal.
• Steps:
1. Define a heuristic function h(x) to estimate the distance to the goal from any
state.
2. From the current state, determine the search space (actions) for one step ahead.
3. Select the action from the search space that minimizes the heuristic function.

7
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. 8
Advantages:
• Best first search can switch between BFS
and DFS by gaining the advantages of both
the algorithms.
• This algorithm is more efficient than BFS
and DFS algorithms.
Disadvantages:
• It can behave as an unguided depth-first
search in the worst case scenario.
• It can get stuck in a loop as DFS.
• This algorithm is not optimal.
9
Greedy best-first search
• Evaluation function f(n) = h(n) (heuristic)
= estimate of cost from n to goal
• e.g., hSLD(n) = straight-line distance from n to goal state/place

• Greedy best-first search expands the node that appears to be closest to


goal

10
Example:
Consider the below search problem, and we will
traverse it using greedy best-first search. At each
iteration, each node is expanded using evaluation
function f(n)=h(n) , which is given in the below
table.

11
12
Greedy Best-First
Search
Greedy Best-First Search
Greedy Best-First Search
Greedy Best-First Search
Example:
Consider the below search problem, and we will
traverse it using greedy best-first search. At each
iteration, each node is expanded using evaluation
function f(n)=h(n) , which is given in the below
table.

17
18
19
20
21
22
23
24
Performance

• 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.
25
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.

26
Cont…
• 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

Idea: avoid expanding paths that are already expensive


Evaluation function f(n) = g(n) + h(n)
g(n) = cost so far to reach n
h(n) = estimated cost from n to goal
f(n) = estimated total cost of path through n to goal

27
Working of A*
1. The algorithm maintains two sets
• OPEN list: The OPEN list keeps track of those nodes that need to
be examined.
• CLOSED list: The CLOSED list keeps track of nodes that have
already been examined.
2. Initially, the OPEN list contains just the initial node,
and the CLOSED list is empty
• g(n) = the cost of getting from the initial node to n
• h(n) = the estimate, according to the heuristic function, of the
cost from n to goal node
• f(n) = g(n)+h(n); intuitively, this is the estimate of the best
solution that goes through n

28
Working of A*
3. Each node also maintains a pointer to its parent, so that the
best solution if found can be retrieved.

• It has main loop that repeatedly gets the node, call it n with lowest f(n) value
from OPEN list.
• If n is goal node then stop (done) otherwise, n is removed from OPEN list &
added to the CLOSED list.
• Next all the possible successor nodes of n are generated.

4. For each successor node n, if it is already in the CLOSED list


and the copy there has an equal or lower f estimate, and then
we can safely discard the newly generated n and move on.

• Similarly, if n is already in the OPEN list & the copy there has an equal or
lower f estimate, we can discard the newly generated n and move on.

29
Example

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.

30
A* Search
33
34
35
36
37
38
Cont…
Advantages
• A* search algorithm is the best algorithm than other search algorithms.
• A* search algorithm is optimal and complete.
• This algorithm can solve very complex problems.
Disadvantages
• It does not always produce the shortest path as it mostly based on heuristics
and approximation.
• A* search algorithm has some complexity issues.
• The main drawback of A* is memory requirement as it keeps all generated
nodes in the memory, so it is not practical for various large-scale problems.
39

You might also like