AI_Session 7 Greedy Best first search algorithm.pptx
1. ARTIFICAL INTELLIGENCE
(R18 III(II Sem))
Department of computer science and
engineering (AI/ML)
Session 7
by
Asst.Prof.M.Gokilavani
VITS
3/1/2023 Department of CSE (AI/ML) 1
2. TEXTBOOK:
• Artificial Intelligence A modern Approach, Third
Edition, Stuart Russell and Peter Norvig, Pearson
Education.
REFERENCES:
• Artificial Intelligence, 3rd Edn, E. Rich and K.Knight
(TMH).
• Artificial Intelligence, 3rd Edn, Patrick Henny
Winston, Pearson Education.
• Artificial Intelligence, Shivani Goel, Pearson
Education.
• Artificial Intelligence and Expert Systems- Patterson,
Pearson Education.
3/1/2023 Department of CSE (AI/ML) 2
3. Topics covered in session 7
3/1/2023 Department of CSE (AI/ML) 3
• Problem solving by search-I: Introduction to AI, Intelligent
Agents.
• Problem solving by search-II: Problem solving agents,
searching for solutions
• Uniformed search strategies: BFS, Uniform cost search,
DFS, Iterative deepening Depth-first search, Bidirectional
search,
• Informed ( Heuristic) search strategies: Greedy best-first
search, A* search, Heuristic functions
• Beyond classical search: Hill- climbing Search, Simulated
annealing search, Local search in continuous spaces, Searching
with non-deterministic Actions, searching with partial
observations, online search agents and unknown environments.
4. Informed search algorithm
• 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.
Example Tree: node with information (weight )
3/1/2023 4
Department of CSE (AI/ML)
5. Heuristics function
• 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.
3/1/2023 5
Department of CSE (AI/ML)
6. Heuristics function
• 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.
Where,
h(n) <= h*(n)
Here h(n) is heuristic cost,
h*(n) is the estimated cost.
Hence heuristic cost should be less than or equal to
the estimated cost.
3/1/2023 Department of CSE (AI/ML) 6
7. Types of informed search algorithm
In the informed search we will discuss two main
algorithms which are given below:
• Best First Search Algorithm(Greedy search)
• A* Search Algorithm
3/1/2023 Department of CSE (AI/ML) 7
8. What is Best First Search?
• BFS uses the concept of a Priority queue and heuristic search.
To search the graph space, the BFS method uses two lists for
tracking the traversal.
• An ‘Open’ list that keeps track of the current ‘immediate’
nodes available for traversal and a ‘CLOSED’ list that keeps
track of the nodes already traversed.
• 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,
• Where,
f(n)= g(n)
G(n) path distance
3/1/2023 8
Department of CSE (AI/ML)
9. Algorithm
1. Create 2 empty lists: OPEN and CLOSED
2. Start from the initial node (say N) and put it in the ‘ordered’ OPEN
list
3. Repeat the next steps until the GOAL node is reached
1. If the OPEN list is empty, then EXIT the loop returning ‘False’
2. Select the first/top node (say N) in the OPEN list and move it
to the CLOSED list. Also, capture the information of the
parent node
3. If N is a GOAL node, then move the node to the Closed list
and exit the loop returning ‘True’. The solution can be found
by backtracking the path
4. If N is not the GOAL node, expand node N to generate the
‘immediate’ next nodes linked to node N and add all those to
the OPEN list
5. Reorder the nodes in the OPEN list in ascending order
according to an evaluation function f(n).
3/1/2023 9
Department of CSE (AI/ML)
11. Expand the nodes of S and put in the CLOSED
list
• Initialization: Open [A, B], Closed [S]
• Iteration 1: Open [A], Closed [S, B]
• Iteration 2: Open [E, F, A], Closed [S, B]
: Open [E, A], Closed [S, B, F]
• Iteration 3: Open [I, G, E, A], Closed [S, B, F]
: Open [I, E, A], Closed [S, B, F, G]
• Hence the final solution path will be:
S----> B----->F----> G
3/1/2023 Department of CSE (AI/ML) 11
14. • 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.
3/1/2023 Department of CSE (AI/ML) 14
15. Topics to be covered in next session 8
• A* Search Algorithm
3/1/2023 Department of CSE (AI/ML) 15
Thank you!!!