This document summarizes an artificial intelligence lecture on problem solving by search. It discusses uninformed search strategies like BFS, DFS, and uniform cost search. It then covers informed, heuristic search strategies like greedy best-first search and A* search. The document provides an example to illustrate how A* search works to find the shortest path between nodes using an evaluation function that combines path cost and heuristic estimates. It concludes by outlining advantages and disadvantages of A* search and previewing topics to be covered in the next session.
ARTIFICAL INTELLIGENCE
(R18 III(IISem))
Department of computer science and
engineering (AI/ML)
Session 8
by
Asst.Prof.M.Gokilavani
VITS
3/1/2023 Department of CSE (AI/ML) 1
2.
TEXTBOOK:
• Artificial IntelligenceA 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 insession 8
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.
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.
• This is informed search technique also called as HEURISTIC search.
This algo. Works using heuristic value.
3/1/2023 Department of CSE (AI/ML) 4
5.
Working of A*Search algorithm
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-
• Evaluation 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
3/1/2023 Department of CSE (AI/ML) 5
6.
A* search 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.
3/1/2023 Department of CSE (AI/ML) 6
7.
A* search Algorithm
•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.
3/1/2023 Department of CSE (AI/ML) 7
8.
Example with
Solution
Consider thefollowing
graph,
• 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.
3/1/2023 Department of CSE (AI/ML) 8
9.
Step-01:
• We startwith 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
3/1/2023 Department of CSE (AI/ML) 9
10.
Step-02:
• Node Gand 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
3/1/2023 Department of CSE (AI/ML) 10
11.
Step-03:
• Node Ican 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
3/1/2023 Department of CSE (AI/ML) 11
12.
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.
3/1/2023 Department of CSE (AI/ML) 12
13.
Shortest path forthe given tree
3/1/2023 Department of CSE (AI/ML) 13
Advantages of BFS
•A* Algorithm is one of the best path finding algorithms.
• It is Complete & Optimal
• Used to solve complex problems.
Disadvantages of BFS
• Requires more memory
3/1/2023 Department of CSE (AI/ML) 16
17.
Topics to becovered in next session 9
• Beyond classical search: Hill- climbing Search
3/1/2023 Department of CSE (AI/ML) 17
Thank you!!!