0% found this document useful (0 votes)
5 views59 pages

Unit 2 L3

Uploaded by

20190201051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views59 pages

Unit 2 L3

Uploaded by

20190201051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 59

Noida Institute of Engineering and Technology, Greater

Noida

Local search algorithms and optimistic


problems

Unit: 02

Introduction to Search

B Tech 3rd Sem


Alka Singh
CSE (AIML)
1
August 4, 2024
Local Search and Optimization
• Previous lecture : path to goal is solution to
problem
- systematic exploration of search space
• This lecture : a state is solution to problem
- for some problem path is irrelevant
- E.g , 8-queens

–Different algorithms can be used


- Depth First Branch and Bound
- Local 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

• “Pure Optimization” problems


- All states have an objective function
- Goal is to find state with max(or min) objective
value
- Does not quite fit into path-cost/goal-state
formulation
- Local search can do quite well on these problems

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

• Step 1: Evaluate the initial state, if it is goal state


then return success and Stop.
• Step 2: Loop Until a solution is found or there is no
new operator left to apply.
• Step 3: Select and apply an operator to the current
state.
• Step 4: Check new state:
– If it is goal state, then return success and quit.

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

• Ridge : It is region which is higher than its


neighbours but itself has a slope. It is a special
kind of local maximum.
• Current state : The region of state space diagram
where we are currently present during the
search.
• Shoulder : It is a plateau that has an uphill edge.

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

• Solution: Backtracking technique can be a


solution of the local maximum in state space
landscape. Create a list of the promising path
so that the algorithm can backtrack the search
space and explore other paths as well.

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

• Solution: The solution for the plateau is to take


big steps or very little steps while searching, to
solve the problem. Randomly select a state
which is far away from the current state so it is
possible that the algorithm could find non-
plateau region.

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

• Solution: With the use of bidirectional search,


or by moving in different directions, we can
improve this problem.

August 4, 2024 20
Steepest-Ascent hill climbing:

• The steepest-Ascent algorithm is a variation of


simple hill climbing algorithm.
• This algorithm examines all the neighboring
nodes of the current state and selects one
neighbor node which is closest to the goal state.
• This algorithm consumes more time as it
searches for multiple neighbors

August 4, 2024 21
Algorithm for Steepest-Ascent hill climbing:

Step 1 : Evaluate the initial state. If it is a goal


state then stop and return success. Otherwise,
make initial state as current state.
Step 2 : Repeat these steps until a solution is
found or current state does not change
a) Select a state that has not been yet applied to
the current state.
b) Initialize a new ‘best state’ equal to current
state and apply it to produce a new state.

August 4, 2024 22
Algorithm for Steepest-Ascent hill climbing:

c) Perform these to evaluate new state


i. If the current state is a goal state, then stop
and return success.
ii. If it is better then best state, then make it best
state else continue loop with another new state.
d) Make best state as current state and go to
Step 2

Step 3 : Exit
August 4, 2024 23
Example

08/04/24 24
Stochastic hill climbing:

• Stochastic hill climbing does not examine for


all its neighbor before moving. Rather, this
search algorithm selects one neighbor node at
random and decides whether to choose it as a
current state or examine another state.

August 4, 2024 25
Algorithm for Stochastic hill climbing:

Step 1: Evaluate the initial state. If it is a goal


state then stop and return success. Otherwise,
make initial state as current state.
Step 2: Repeat these steps until a solution is
found or current state does not change.
a)Select a state that has not been yet applied to
the current state.
b)Apply successor function to the current state
and generate all the neighbor states.
August 4, 2024 26
Algorithm for Stochastic hill climbing:

c) Among the generated neighbor states which


are better than current state choose a state
randomly (or based on some probability
function).
d) If the chosen state is goal state, then return
success, else make it current state and repeat
step 2.

Step 3: Exit.
August 4, 2024 27
Simulated Annealing

• A hill-climbing algorithm which never makes a


move towards a lower value guaranteed to be
incomplete because it can get stuck on a local
maximum.
• Simulated Annealing is an algorithm which yields
both efficiency and completeness.
• In mechanical term Annealing is a process of
hardening a metal or glass to a high temperature
then cooling gradually, so this allows the metal to
reach a low-energy crystalline state.
08/04/24 28
Simulated Annealing

• The same process is used in simulated


annealing in which the algorithm picks a
random move, instead of picking the best
move. If the random move improves the state,
then it follows the same path. Otherwise, the
algorithm follows the path which has a
probability of less than 1 or it moves downhill
and chooses another path.

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.

2.The second step involves defining the target or


desired goal that needs to be achieved.

August 4, 2024 40
How means-ends analysis Works:

3. The target goal is split into sub-goals, that are


further split into other smaller goals.

4. This step involves establishing the actions or


operations that will be carried out to achieve
the end state.

5. In this step, all the sub-goals are linked with


corresponding executable actions (operations).
August 4, 2024 41
How means-ends analysis Works:

6. After that is done, intermediate steps are


undertaken to solve the problems in the current
state. The chosen operators will be applied to
reduce the differences between the current
state and the end state.

7. This step involves tracking all the changes


made to the actual state. Changes are made
until the target state is achieved.
August 4, 2024 42
How means-ends analysis Works:
• The following image shows how the target goal is
divided into sub-goals, that are then linked with
executable actions.

August 4, 2024 43
Algorithm for Means-Ends Analysis:

The following are the algorithmic steps for


means end analysis:

1.Conduct a study to assess the status of the


current state. This can be done at a macro or
micro level.
2.Capture the problems in the current state and
define the target state. This can also be done at
a macro or micro level.
August 4, 2024 44
Algorithm for Means-Ends Analysis:

3. Make a comparison between the current


state and the end state that you defined. If
these states are the same, then perform no
further action. This is an indication that the
problem has been tackled. If the two states are
not the same, then move to step 4.
4. Record the differences between the two
states at the two aforementioned levels (macro
and micro).
August 4, 2024 45
Algorithm for Means-Ends Analysis:

5. Transform these differences into adjustments


to the current state.

6. Determine the right action for implementing


the adjustments in step 5.

7. Execute the changes and compare the results


with the target goal.
August 4, 2024 46
Algorithm for Means-Ends Analysis:

8. If there are still some differences between the


current state and the target state, perform
course correction until the end goal is achieved.

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:

4. Applying Expand Operator: Now a new state is


generated in the third step, and we will compare
this state with the goal state. After comparing the
states there is still one difference which is the size of
the square, so, we will apply Expand operator, and
finally, it will generate the goal state.

August 4, 2024 53
Example of Mean-Ends Analysis:

August 4, 2024 54
Applications of Means End Analysis

Organizational planning

Means end analysis is used in organizations to


facilitate general management. It helps
organizational managers to conduct planning to
achieve the objectives of the organization. The
management reaches the desired goal by
dividing the main goals into sub-goals that are
linked with actionable tasks.
August 4, 2024 55
Applications of Means End Analysis

Business transformation

This technique is used to implement


transformation projects. If there are any desired
changes in the current state of a business
project, means end analysis is applied to
establish the new processes to be implemented.
The processes are split into sub-processes to
enhance effective implementation.
August 4, 2024 56
Applications of Means End Analysis

Gap analysis

Gap analysis is the comparison between the


current performance and the required
performance. Means end analysis is applied in
this field to compare the existing technology and
the desired technology in organizations. Various
operations are applied to fill the existing gap in
technology.
August 4, 2024 57
References

• American Association for Artificial Intelligence (AAAI),


Welcome to AI Topics, 2003, http://www.aaai.org/AITopics/ --
a Web-based library.
• George Luger,
Artificial Intelligence: Structures and Strategies for Complex P
roblem Solving, Fourth Edition
Addison-Wesley, 2002 -- a well-respected introduction to
artificial intelligence, as witnessed by its being in its fourth
edition.
• Peter Norvig, AI on the Web,
August 4, 2024 58
http://aima.cs.berkeley.edu/ai.html -- a list of over 800 links
August 4, 2024 59

You might also like