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

Lecture 5, Beam Search & A Estrick

The document discusses various heuristic search strategies including beam search and A* search. It explains that beam search is an optimization of best-first search that retains only the most promising nodes at each step to reduce memory requirements. A* search uses both cost to reach a node (g(n)) and heuristic estimate of cost to reach the goal (h(n)) to guide its search, expanding nodes with the lowest f(n)=g(n)+h(n) value first. The document provides pseudocode and an example of applying A* search to a problem. It notes that A* is optimal if the heuristic is admissible but may not find the shortest path with inadmissible heuristics.

Uploaded by

M. Talha Nadeem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Lecture 5, Beam Search & A Estrick

The document discusses various heuristic search strategies including beam search and A* search. It explains that beam search is an optimization of best-first search that retains only the most promising nodes at each step to reduce memory requirements. A* search uses both cost to reach a node (g(n)) and heuristic estimate of cost to reach the goal (h(n)) to guide its search, expanding nodes with the lowest f(n)=g(n)+h(n) value first. The document provides pseudocode and an example of applying A* search to a problem. It notes that A* is optimal if the heuristic is admissible but may not find the shortest path with inadmissible heuristics.

Uploaded by

M. Talha Nadeem
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Week 5

Heuristic Search Strategies


Beam Search & A*Search
By
Dr. Fazeel Abid
Assistant Professor
The University of Lahore, Pakistan
Beam Search
• Greedy Algorithm
• Beam search is an optimization of best-first search.
• In Beam Search Only the most promising nodes at each step of the search are
considered for further branching?
• Beam Search was developed in an attempt to achieve the optimal (or sub-
optimal) solution without consuming too much memory, How?
• What was Best First Search?
• Best First Search was Good Enough?
• What was the Drawback?
Best First Search?

Node H(n)
A→G 40
B→G 32
C→G 25
D→G 35
E→G 19
F→G 17
G→G 0
H→G 10
Beam Search
• Greedy Algorithm
• Beam search is an optimization of best-first search that reduces its memory
requirements.
• Only the most promising nodes (instead of all nodes) at each step of the search
are retained for further branching.
• Beam Search was developed in an attempt to achieve the optimal (or sub-
optimal) solution without consuming too much memory.
• Explore a Graph by expanding the most promising node in a limited set.
• What is Limited Set?
• Beam Value is also called Beta or Beam Width refers to the number of
nodes to be expand. ( Value is Given)
Beam Search Algorithm
OPEN = {initial state}
while OPEN is not empty do
1. Remove the best node from OPEN, call it n.
2. If n is the goal state, return path.
3. Create n's successors.
4. Evaluate each successor, add it to OPEN, and record its
parent.
5. If |OPEN| > ß , take the best ß nodes (according to
heuristic) and remove the others from the OPEN.
Done
Completeness of Beam Search
• In general, the Beam Search Algorithm is not
complete.
• Even given unlimited time and memory, it is
possible for the Algorithm to miss the goal
node
• A more accurate heuristic function and a larger
beam width can improve Beam Search's
chances of finding the goal. Steps
1. OPEN= {A}
• Clearly, open set becomes empty without 2. OPEN= {B,C}
3. OPEN={D,E}
finding goal node . 4. OPEN={E}
5. OPEN={}
Optimality In Beam Search

• Just as the Algorithm is not complete, it is also not


guaranteed to be optimal.
• This can happen because the beam width and an
inaccurate heuristic function may cause the algorithm 1. OPEN= {A}
to miss expanding the shortest path.
2. OPEN= {B,C}
• A more precise heuristic function and a larger beam 3. OPEN={C,E}
width can make Beam Search more likely to find the 4. OPEN={F,E}
optimal path to the goal. 5. OPEN={G,E}
6. found goal node, stop.
Path : A->B->C->F->G
Optimal Path : A->D->G
Time & Space Complexity In Beam Search
• Depends on the accuracy of the heuristic function.
• In the worst case, the heuristic function leads Beam Search all the way to the deepest
level in the search tree.
The worst case time = O(B*m)
where B is the beam width and m is the maximum depth of any path in the search tree.
• Beam Search's memory consumption is its most desirable trait.
• Since the algorithm only stores B nodes at each level in the search tree,
The worst-case space complexity = O(B*m)
where B is the beam width, and m is the maximum depth of any path in the search tree.
• This linear memory consumption allows Beam Search to probe very deeply into large
search spaces and potentially find solutions that other algorithms cannot reach.
A* Search Algorithm

• A* search is the most commonly known form of best-first search.


• It uses heuristic function h(n), and cost to reach the node n from the start state
g(n).
• It has combined features of UCS and greedy best-first search, by which it solve
the problem efficiently.
• A* search algorithm try to find the shortest path through the search space using
the heuristic function.
• This search algorithm expands less search tree and provides optimal result faster.
• A* algorithm is similar to UCS except that it uses g(n)+h(n) instead of g(n).
• The efficiency of A* algorithm depends on the quality of heuristic.
• A* algorithm expands all nodes which satisfy the condition.
A* Search Algorithm
• In A* search algorithm, we use search heuristic as well as the cost to reach the
node.
• We can combine both costs as following, and this sum is called as a fitness
number.
Cost to Reach n Node From Start Node

Heuristic Value of
Estimated Cost of Each Node to
Cheapest Solution Reach Goal Node

• At each point in the search space, only those node is expanded which have the
lowest value of f(n), and the algorithm terminates when the goal node is
A* Search Algorithm
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.
A* Search Algorithm (Example)
• Traverse the given graph using the A*
algorithm.
• The heuristic value of all states is given
in the below table so calculate the f(n) of
each state using the formula

where g(n) is the cost to reach any node


from start state.
• OPEN and CLOSED list are used.
A* Search Algorithm (Example)
A* Search Algorithm
Complete: 
A* algorithm is complete as long as:
• Branching factor is finite.
• Cost at every action is fixed.
Optimal: 
• A* search algorithm is optimal.
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)
Assignment ! Assignment ! Assignment !
You are all required to Submit Hand Written Assignment.
The Deadline for the Submission is 6th of November 2020. (Thursday).
The Topic of the Assignment are:
• British Museum Search Algorithm
• Branch and Bound Algorithm
You will prepare for assessment as well as assignments contains following
contents:
• Complete Description
• Flowchart
• Algorithm
• Example with Solution
Best of Luck

You might also like