FAI - Unit 2 - Search
FAI - Unit 2 - Search
by
Dr. Abdul Ahad
Contents
2.1 Search in Intelligent Systems
2.2 Search Space (State Space Graphs)
2.3 Generate and Test Paradigm (Algorithm)
2.4 Uninformed Search (Blind Search) Algorithms
2.4.1 Breadth First Search (BFS)
2.4.2 Depth First Search (DFS)
2.4.3 Uniform Cost Search (UCS)
2.4.4 Depth First Iterative Deepening Search (DFIDS)
2.4.5 Bi-Directional Search (BDS)
2.5 Comparing Blind Search Algorithms
2.6 Informed Search (Heuristic Search) Algorithms
2.6.1 Best First Search
2.6.2 Hill Climbing (Greedy Search)
2.6.3 A* Search
2.6.4 Beam Search Dr. Abdul Ahad, Department of AI 2
2.1 Search in Intelligent Systems
Search is a natural part of people’s lives. Search in
Artificial Intelligence is the process of navigating from a
starting state to a goal state by transitioning through
intermediate states.
An intelligent agent is trying to find a set or sequence
of actions to achieve a goal. Software that solves search
problems faster are deemed to be more intelligent.
Algorithm: Generate-And-Test
– 1. Generate a possible solution.
– 2. Test to see if this is the expected solution.
– 3. If the solution has been found quit else go to step 1.
Dr. Abdul Ahad, Department of AI 13
➢ Like depth-first search, Generate-and-test requires
that complete solutions be generated for testing.
Solutions can also be generated randomly but
solution is not guaranteed.
➢ This approach is what is known as British Museum
algorithm: finding an object in the British Museum
by wandering randomly.
➢ Depth-first search tree with backtracking can be
used to implement systematic generate-and test
procedure.
Complete N Y Y
Optimal N N Y
Heuristic N N N
Time bm bd+1 bm
Space bm bd+1 bm
Local Maximum: Local maximum is a state which is better than its neighbor
states, but there is also another state which is higher than it.
Global Maximum: Global maximum is the best possible state of state space
landscape. It has the highest value of objective function.
Current state: It is a state in a landscape diagram where an agent is currently
present.
Flat local maximum: It is a flat space in the landscape where all the neighbor
states of current states have the same value.
Shoulder: It is a plateau region which
Dr. Abdul Ahad,has an uphill
Department of AI edge. 45
Simple Hill climbing algorithm:
1.Define the current state as an initial state
2.Loop until the goal state is achieved or no more operators can
be applied on the current state:
i. Apply an operation to current state and get a new state
ii. Compare the new state with the goal
iii. Quit if the goal state is achieved
iv. Evaluate new state with heuristic function and compare it
with the current state
v. If the newer state is closer to the goal compared to
current state, update the current state
Solution: Starting from S, the algorithm computes g(x) + h(x) for all
nodes in the fringe at each step, choosing the node with the lowest sum.
The entire working is shown in the table below.
Dr. Abdul Ahad, Department of AI 55
Path: S -> D ->Dr.BAbdul
-> Ahad,
E ->Department
G of AICost: 7 56
2.5.4 Beam Search
Beam search is a heuristic search algorithm that explores a
graph by expanding the most promising node in a limited set.
Beam search is an optimization of best-first search that
reduces its memory requirements.
Beam search uses breadth-first search to build its search
tree. At each level of the tree, it generates all successors of the
states at the current level, sorting them in increasing order of
heuristic cost. However, it only stores a predetermined number
(β), of best states at each level called the beamwidth. Only
those states are expanded next.
A beam search takes three components as its input:
▪ A problem to be solved,
▪ A set of heuristic rules for pruning,
▪ And a memory with aDr.limited available capacity.
Abdul Ahad, Department of AI 57
For example,
Explore I. Nodes N and H are the top two nodes, so those are added to the tree: