Unit 2 L3
Unit 2 L3
Noida
Unit: 02
Introduction to Search
August 4, 2024 2
Local Search and Optimization
• Local search
- Keep track of single current state
- Move only to neighboring states
- Ignore path
Advantages:
- Use very little memory
- Can often find reasonable solutions in large or
infinite state space
August 4, 2024 3
Local Search and Optimization
August 4, 2024 4
Hill Climbing Algorithm in AI
• Hill climbing algorithm is a local search algorithm which
continuously moves in the direction of increasing
elevation/value to find the peak of the mountain or best
solution to the problem.
• It terminates when it reaches a peak value where no
neighbor has a higher value.
• Hill climbing algorithm is a technique which is used for
optimizing the mathematical problems.
August 4, 2024 5
Continue…
• Examples of Hill climbing algorithm is Traveling-salesman
Problem in which we need to minimize the distance
traveled by the salesman.
• It is also called greedy local search as it only looks to its
good immediate neighbor 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.
• In this algorithm, we don't need to maintain and handle the
search tree or graph as it only keeps a single current state.
August 4, 2024 6
Features of Hill Climbing
• Following are some main features of Hill Climbing
Algorithm:
• Generate and Test variant: Hill Climbing is the variant of
Generate and Test method. The Generate and Test
method produce feedback which helps to decide which
direction to move in the search space.
• Greedy approach: Hill-climbing algorithm search moves
in the direction which optimizes the cost.
• No backtracking: It does not backtrack the search
space, as it does not remember the previous states.
August 4, 2024 7
Simple Hill climbing
• Simple hill climbing is the simplest way to implement a hill
climbing algorithm.
• It only evaluates the neighbor node state at a time and selects
the first one which optimizes current cost and set it as a current
state.
• It only checks it's one successor state, and if it finds better than
the current state, then move else be in the same state. This
algorithm has the following features:
• Less time consuming
• Less optimal solution and the solution is not guaranteed
August 4, 2024 8
Algorithm of Hill Climbing
August 4, 2024 9
Continue…
– Else if it is better than the current state then
assign new state as a current state.
– Else if not better than the current state, then
return to step2.
• Step 5: Exit.
August 4, 2024 10
State Space diagram for Hill Climbing
• State space diagram is a graphical representation of
the set of states our search algorithm can reach vs
the value of our objective function(the function
which we wish to maximize).
X-axis : denotes the state space ie states or
configuration our algorithm may reach.
Y-axis : denotes the values of objective function
corresponding to a particular state.
The best solution will be that state space where
objective function has maximum value(global
maximum).
August 4, 2024 11
Different regions in the State Space Diagram
August 4, 2024 12
Different regions in the State Space Diagram
• Local maximum: It is a state which is better than its
neighboring state however there exists a state which is
better than it(global maximum). This state is better
because here the value of the objective function is
higher than its neighbors.
• Global maximum : It is the best possible state in the
state space diagram. This because at this state,
objective function has highest value.
• Plateau/flat local maximum : It is a flat region of state
space where neighboring states have the same value.
August 4, 2024 13
Different regions in the State Space Diagram
August 4, 2024 14
Problems in different regions in Hill climbing
• Hill climbing cannot reach the optimal/best
state(global maximum) if it enters any of the
following regions :
• Local maximum : At a local maximum all
neighboring states have a values which is worse
than the current state. Since hill-climbing uses a
greedy approach, it will not move to the worse state
and terminate itself. The process will end even
though a better solution may exist.
August 4, 2024 15
Problems in different regions in Hill climbing
August 4, 2024 16
Problems in different regions in Hill climbing
• Plateau : On plateau all neighbors have same
value . Hence, it is not possible to select the best
direction.
August 4, 2024 17
Problems in different regions in Hill climbing
August 4, 2024 18
Problems in different regions in Hill climbing
• Ridge : Any point on a ridge can look like peak
because movement in all possible directions is
downward. Hence the algorithm stops when it
reaches this state.
August 4, 2024 19
Problems in different regions in Hill climbing
August 4, 2024 20
Steepest-Ascent hill climbing:
August 4, 2024 21
Algorithm for Steepest-Ascent hill climbing:
August 4, 2024 22
Algorithm for Steepest-Ascent hill climbing:
Step 3 : Exit
August 4, 2024 23
Example
08/04/24 24
Stochastic hill climbing:
August 4, 2024 25
Algorithm for Stochastic hill climbing:
Step 3: Exit.
August 4, 2024 27
Simulated Annealing
08/04/24 29
• Basic inspiration: What is annealing?
– In metallurgy, annealing is the physical process used
to temperature or harden metals or glass by heating
them to a high temperature and then gradually
cooling them, thus allowing the material to coalesce
into a low energy crystalline state.
– Heating then slowly cooling a substance to obtain a
strong crystalline structure.
• Key idea: Simulated Annealing combines Hill Climbing
with a random walk in some way that yields both
efficiency and completeness.
08/04/24 30
MCQ
• Q1. In many problems the path to goal is irrelevant,
this class of problems can be solved using ______
a) Informed Search Techniques
b) Uninformed Search Techniques
c) Local Search Techniques
d) Informed & Uninformed Search Techniques
August 4, 2024 31
MCQ
• Q2. Though local search algorithms are not systematic,
key advantages would include __________
a) Less memory
b) More time
c) Finds a solution in large infinite space
d) Less memory & Finds a solution in large infinite space
August 4, 2024 32
MCQ
• Q3. A complete, local search algorithm always finds
goal if one exists, an optimal algorithm always finds a
global minimum/maximum.
a) True
b) False
August 4, 2024 33
MCQ
• Q 4. _______________ is an algorithm, a loop that
continually moves in the direction of increasing value
that is uphill.
a) Up-Hill Search
b) Hill-Climbing
c) Hill algorithm
d) Reverse-Down-Hill search
August 4, 2024 34
MCQ
• Q 5. When will Hill-Climbing algorithm terminate?
a) Stopping criterion met
b) Global Min/Max is achieved
c) No neighbor has higher value
d) All of the mentioned
August 4, 2024 35
MCQ
• Q6. What are the main cons of hill-climbing search?
a) Terminates at local optimum & Does not find optimum
solution
b) Terminates at global optimum & Does not find
optimum solution
c) Does not find optimum solution & Fail to find a solution
d) Fail to find a solution
August 4, 2024 36
MCQ
• Q7. Hill climbing sometimes called ____________
because it grabs a good neighbor state without
thinking ahead about where to go next.
a) Needy local search
b) Heuristic local search
c) Greedy local search
d) Optimal local search
August 4, 2024 37
MCQ
• Q8. Hill-Climbing approach stuck for which of the following
reasons?
a) Local maxima
b) Ridges
c) Plateau
d) All of the mentioned
August 4, 2024 38
Means-Ends Analysis
• Means-Ends Analysis is problem-solving techniques
used in Artificial intelligence.
• It is a mixture of Backward and forward search
technique.
• The MEA technique was first introduced in 1961 by
Allen Newell, and Herbert A. Simon in their problem-
solving computer program, which was named as
General Problem Solver (GPS).
• The MEA analysis process centered on the evaluation of
the difference between the current state and goal state.
August 4, 2024 39
How means-ends analysis Works:
Means end analysis uses the following processes to
achieve its objectives:
1.First, the system evaluates the current state to
establish whether there is a problem. If a problem is
identified, then it means that an action should be
taken to correct it.
August 4, 2024 40
How means-ends analysis Works:
August 4, 2024 43
Algorithm for Means-Ends Analysis:
August 4, 2024 47
Example of Mean-Ends Analysis:
• Let's take an example where we know the initial
state and goal state as given below. In this problem,
we need to get the goal state by finding differences
between the initial state and goal state and
applying operators.
August 4, 2024 48
Example of Mean-Ends Analysis:
Solution:
To solve the above problem, we will first find the
differences between initial states and goal states, and
for each difference, we will generate a new state and
will apply the operators. The operators we have for
this problem are:
•Move
•Delete
•Expand
August 4, 2024 49
Example of Mean-Ends Analysis:
1. Evaluating the initial state: In the first step, we
will evaluate the initial state and will compare the
initial and Goal state to find the differences
between both states.
August 4, 2024 50
Example of Mean-Ends Analysis:
2. Applying Delete operator: As we can check the first
difference is that in goal state there is no dot symbol
which is present in the initial state, so, first we will
apply the Delete operator to remove this dot.
August 4, 2024 51
Example of Mean-Ends Analysis:
3. Applying Move Operator: After applying the Delete
operator, the new state occurs which we will again
compare with goal state. After comparing these
states, there is another difference that is the square is
outside the circle, so, we will apply the Move
Operator.
August 4, 2024 52
Example of Mean-Ends Analysis:
August 4, 2024 53
Example of Mean-Ends Analysis:
August 4, 2024 54
Applications of Means End Analysis
Organizational planning
Business transformation
Gap analysis