UNIT - 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

UNIT – 2

Exhaustive Searches:
Generate and Test,
Breadth First Search,
Depth First Search and DFID

Heuristic Search Techniques:


Branch and Bounce technique;
Best first search;
A* algorithm;
Problem Reduction AND/OR Graphs and AO* algorithm.

Local Searches and Optimizations:


Hill climbing and its variants.

Constraint Satisfaction Problems:


Definition;
Constraint Propagation and Backtracking.

Game Playing:
Mini-Max Search Procedure;
Alpha-Beta Cutoffs;
Additional Refinements.
Q1. What is heuristic function? Mca 2022
Q2. Define ‘intelligent Agent’ #
Q1. which search method takes less memory.
Q2. Explain alpha-beta purning.
Q1. What is game theory ? how is it important in ai?

Q1. define problem reduction in ai .mca 2021.


Q2. Define the term optimization.
Q1. Write an algorithm for depth first search.
Q2. How does hill climbing work.
Q1. Describe the Alpha-Beta cutoffs.

Q1. What is searching? define blind search. Mca 2021 fifth sem.
Q2. What is heuristic search?
Q1. Explain min-max search.
Q2. Briefly define hill climbing algorithm.
Q1. Explain the AO* algorithm with suitable example.

Q1. Define breadth first search. Msc 2022.


Q2. What is alpha-beta cutoffs.
Q1. Explain problem reduction technique by suitable example.
Q2. Define constraint satisfaction problem.
Q1. Describe A* algorithm with suitable example.
Q2. Explain Mini-Max Search Procedure.
Q1. Differentiate breadth-first search and depth-first search.Mca fifth 2020.
Q2. What is Heuristic Search?
Q1. Explain branch and bound technique.
Q2. Explain Alpha-Beta cut-off.
Q1. Describe A* algorithm with suitable example.
Q2. Explain Mini-Max search procedure.

Q1. Msc 2021.


Q2.
Q1. List the various search strategies and explain or define any one strategy.
Q2. What is Heuristic search techniques ?
Q1. Explain the advantages and disadvantages of depth-first and breath-first search
with the algorithm.
Or
Discuss any two of the following :
(a) Minimax search procedure
(b) Alpha-beta cutoffs
(c) AO* algorithm .

Q1. Define the Heuristic search. Msc 2019.


Q2.
Q1. Explain Hill climbing.
Q2. Explain mini max search procedure.
Q1. Describe alpha beta pruning procedure.
Or
Discuss A* and AO* algorithm and the various observations about algorithm briefly.

mca 21
Exhaustive Searches:
Generate and Test,
Breadth First Search,

 Breadth-first search is the most common search strategy for traversing a tree or graph.
This algorithm searches breadthwise in a tree or graph, so it is called breadth-first
search.

 BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.

 The breadth-first search algorithm is an example of a general-graph search algorithm.

 Breadth-first search implemented using FIFO queue data structure.

 BFS needs lots of time if the solution is far away from the root node.

 It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
Depth First Search and DFID

 Depth-first search isa recursive algorithm for traversing a tree or graph data structure.

 It is called the depth-first search because it starts from the root node and follows each
path to its greatest depth node before moving to the next path.

 DFS uses a stack data structure for its implementation.

 The process of the DFS algorithm is similar to the BFS algorithm.

 It takes less time to reach to the goal node than BFS algorithm (if it traverses in the
right path).

 DFS requires very less memory.


Heuristic Search Techniques:
 A heuristic is a technique that is used to solve a problem faster than the classic methods.

 These techniques are used to find the approximate solution of a problem when classical
methods do not.

 Heuristics are said to be the problem-solving techniques that result in practical and quick
solutions.

 Heuristics are strategies that are derived from past experience with similar problems.

 Heuristics use practical methods and shortcuts used to produce the solutions that may or may
not be optimal, but those solutions are sufficient in a given limited timeframe.
Branch and Bounce technique;

Branch and
bound
What is Branch and bound?
Branch and bound is one of
the techniques used for
problem solving. It is
similar to the
backtracking since it also
uses the state space tree. It
is used for solving the
optimization
problems and minimization
problems. If we have given a
maximization problem then we
can
convert it using the Branch
and bound technique by
simply converting the
problem into a
maximization problem
Branch and
bound
What is Branch and bound?
Branch and bound is one of
the techniques used for
problem solving. It is
similar to the
backtracking since it also
uses the state space tree. It
is used for solving the
optimization
problems and minimization
problems. If we have given a
maximization problem then we
can
convert it using the Branch
and bound technique by
simply converting the
problem into a
maximization problem

Best first search;


 This algorithm always chooses the path which appears best at that moment.

 It is the combination of depth-first search and breadth-first search algorithms.

 It lets us to take the benefit of both algorithms.

 It uses the heuristic function and search.


 With the help of the best-first search, at each step, we can choose the most promising node.

 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, i.e.

A* 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 (Uniform Cost Search) and greedy best-first search, by which
it solve the problem efficiently.

 A* search algorithm finds 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 (Uniform Cost Search) except that it uses g(n)+h(n) instead of
g(n).
Advantages:

o A* search algorithm is the best algorithm than other search algorithms.


o A* search algorithm is optimal and complete.
o This algorithm can solve very complex problems.

Disadvantages:

o It does not always produce the shortest path as it mostly based on heuristics
and approximation.
o A* search algorithm has some complexity issues.
o The main drawback of A* is memory requirement as it keeps all generated
nodes in the memory.

Problem Reduction AND/OR Graphs and AO* algorithm.


Problem Reduction AND/OR Graphs: -

AO* algorithm.
 AO* algorithm is a best first search algorithm.

 AO* algorithm uses the concept of AND-OR graphs to decompose any


complex problem given into smaller set of problems which are further
solved.

 AND OR graphs are specialized graphs that are used in problems that can be
divided into smaller problems.
 The AND side of the graph represents a set of tasks that need to be done to
achieve the main goal, while the OR side of the graph represents the different
methods to achieve the same main goal.

 The AO* algorithm is a knowledge-based search technique, meaning the


start state and the goal state is already defined, and the best path is found
using heuristics.

 Compared to the A* algorithm, AO* algorithm is very efficient in searching


the AND-OR trees very efficiently.
Working of AO algorithm:
The AO* algorithm works on the formula given below:
f(n) = g(n) + h(n)
where,
 g(n): The actual cost of traversal from initial state to the current state.

 h(n): The estimated cost of traversal from the current state to the goal state.
 f(n): The actual cost of traversal from the initial state to the goal state.

Local Searches and Optimizations:


Hill climbing and its variants.
 Hill climbing is a simple optimization algorithm used in ai to find the best
possible solution for a given problem.

 Hill climbing algorithm is a local search algorithm which continuously moves in the
direction of increasing value to find the peak of the mountain or best solution to the
problem. It terminates when it reaches a peak value where no neighbour has a higher
value.

 Hill climbing algorithm is a technique which is used for optimizing the mathematical
problems.
 It is also called greedy local search as it only looks to its good immediate neighbour
state and not beyond that.

 A node of hill climbing algorithm has two components which are state and value.

 Hill Climbing is mostly used when a good heuristic is available.

Types of Hill Climbing Algorithm:


o Simple hill Climbing:
o Steepest-Ascent hill-climbing:
o Stochastic hill Climbing:

1. Simple Hill Climbing:

This algorithm examines the neighbouring nodes one by one and select the
first neighbouring node which optimize the current cost as the next node.

2. Steepest-Ascent hill climbing:

This algorithm examines all the neighbouring nodes of the current state
and selects one neighbour node which is closest to the goal state.
3. Stochastic hill climbing:

Stochastic hill climbing does not examine for all its neighbour before
moving. Rather, this search algorithm selects one neighbour node at
random and decides whether to choose it as a current state or examine
another state.

Constraint Satisfaction Problems:


Definition;
CSP is a specific type of problem-solving approach that involves identifying
constraints that must be satisfied and finding a solution that satisfies all the
constraints.

A CPS in ai involves a set of variables, a domain for each variable, and a set of
constraints that outline the possible combinations of values for these
variables.

The goal is find a value for each variable such that all the constraints are
satisfied.
Basic Components of CSP
The basic components of CSPs are:

1. Variable: Variables are the items that need to be determined. Variable in


a CSP are the objects that must have values assigned to them in order to
satisfy a particular set of constraints.
2. Domains: The domain of a variable is the set of possible values it can
take.
3. Constraints: Constraints define the relationships or limitations among
the variables.

Constraint Satisfaction Problems (CSP) representation:


 The finite set of variables V 1, V2, V3 ……………..Vn.
 Non-empty domain for every single variable D 1, D2, D3 …………..Dn.
 The finite set of constraints C 1, C2 …….…, Cm.

Constraint Propagation and Backtracking.

Game Playing:
 Game playing is a popular application of ai that involves the development of
computer programs to play games, such as chess, checkers. Or Go.

 The goal of game playing in ai is to develop algorithms that can learn how to
play games and make decision that will lead to winning outcomes.

There are two main approaches to game playing in ai, rule -based systems and
machine learning-based systems.
1. Rule-based systems use a set of fixed rules to play the game.
2. Machine learning-based systems use algorithms to learn from
experience and make decisions based on that experience.
Mini-Max Search Procedure;

o Mini-max algorithm is a recursive or backtracking algorithm which is used in


decision-making and game theory. It provides an optimal move for the player
assuming that opponent is also playing optimally.

o Mini-Max algorithm uses recursion to search through the game-tree.

o Min-Max algorithm is mostly used for game playing in AI. Such as Chess,
Checkers, tic-tac-toe, go, and various tow-players game. This Algorithm
computes the minimax decision for the current state.
o In this algorithm two players play the game, one is called MAX and other is
called MIN.

o Both the players fight it as the opponent player gets the minimum benefit
while they get the maximum benefit.

o Both Players of the game are opponent of each other, where MAX will select
the maximized value and MIN will select the minimized value.

o The minimax algorithm performs a depth-first search algorithm for the


exploration of the complete game tree.

o The minimax algorithm proceeds all the way down to the terminal node of the
tree, then backtrack the tree as the recursion.

Alpha-Beta Cutoffs;

 Alpha-beta pruning is a modified version of the minimax algorithm. It is an


optimization technique for the minimax algorithm.

 Its primary purpose is to reduce the number of nodes evaluated in the search
tree, making the search more efficient by pruning branches that cannot possibly
influence the final decision.

 It is called Alpha-Beta pruning because it passes 2 extra parameters in the


minimax function, namely Alpha and Beta.
 The two parameter can be define as:
1. Alpha: It is the best highest value choice that we have found in the path
of the maximizer. The starting value of alpha is -∞.
2. Beta: It is the best lowest value choice that we have found in the path
of the minimizer. The starting value of beta is +∞.

Condition for Alpha-beta pruning:


The main condition which required for alpha-beta pruning is:

Key points about alpha-beta pruning:


o The Max player will only update the value of alpha.
o The Min player will only update the value of beta.
o While backtracking the tree, the node values will be passed to upper nodes instead of
values of alpha and beta.
o We will only pass the alpha, beta values to the child nodes.

Additional Refinements.

You might also like