Session 56 Co1_local Search Algorithm
Session 56 Co1_local Search Algorithm
MACHINE LEARNING
Topic:
LOCAL SEARCH ALGORITHM:
HILL CLIMBING
Session – 05 &
06
AIM OF THE SESSION
INSTRUCTIONAL
OBJECTIVES
LEARNING OUTCOMES
• Local search is an algorithm that is used to find the best solution to a problem by starting with
a random solution and then making small changes to it until it finds a better solution.
• The objective function is at the heart of any local search algorithm; it defines what constitutes
an acceptable solution and serves as a measure of how well any given candidate solution fits
that definition.
• Hill climbing or k opt are examples of local optimisation algorithms that use such functions to
identify promising candidates for further refinement until a satisfactory result is obtained.
• Search algorithms like quick search can be employed to traverse the search space efficiently,
while customer reviews and BBB business profiles provide valuable additional data points for
informed decision-making.
Local Search Algorithm…..
• The ability for customers to search locally has been made even easier by advances in
technology such as voice-activated searches on devices like smartphones and tablets.
• This enables customers to quickly find what they are looking for without having to
enter extensive search terms into a web browser.
• With these advancements, Local Search has become increasingly important for
businesses who want to stay competitive in their industry.
• Local Search also provides valuable insights about customer behavior that can inform
marketing strategies and help brands better understand their target audience.
• For companies seeking success, understanding how best to leverage Local Search is
essential; it offers significant opportunities but must be approached strategically.
5
SESSION INTRODUCTION…..
6
Local Search Algorithm
7
HILL CLIMBING
8
TYPES OF HILL CLIMBING
9
STATE SPACE DIAGRAM FOR HILL CLIMBING:
10
DIFFERENT REGIONS IN THE STATE SPACE
DIAGRAM:
• Local maximum: A state exists that is better than it (the global maximum),
but it is not better than its neighbour. This state is preferable because the goal
function's value is higher here than it is in its surrounding states.
• Global maximum: In the state space diagram, it is the ideal state that is
conceivable. This is due to the goal function having the maximum value at this
point.
• Plateau/flat local maximum: It is a flat area in state space where states
close by have equal values.
11
• Ridge: It is a location that is higher than its surroundings yet has a slope of its own. This
particular local maximum is unique.
• Current state: The region of the state space diagram where we are currently present
during the search.
• Hill Climbing Algorithm is a very widely used algorithm for Optimization related
problems as it gives decent solutions to computationally challenging problems.
• It has certain drawbacks associated with it like its Local Minima, Ridge, and Plateau
problem which can be solved by using some advanced algorithm.
12
PROBLEMS IN HILL
CLIMBING:
• 1. Local Maximum: A local maximum is a state that dominates its
surrounding states but is surpassed by another state that is also present and is
higher than the local maximum.
• Solution: In the state space landscape, the local maximum can be resolved
using the backtracking approach. Make a list of the promising paths so that the
algorithm may go back and investigate other routes.
13
• Plateau: A plateau is a flat region of the search space where all neighbour
states of the current state have the same value. As a result, the algorithm is
unable to determine the optimum course of action. In the plateau region, a hill-
climbing search may become disoriented.
• Solution: Making either large or little movements while looking for a solution
can help you get over the plateau. Choose a state at random that is remote
from the one you are in now, giving the algorithm a chance to discover a non-
plateau region.
14
Ridges: The local maximum might take distinctive forms, such as ridges. It has a
portion that is higher than the places around it, but because of its own slope, it
cannot be reached in a single motion.
Solution: We can make this situation better by using bidirectional search or by
going in separate ways.
15
BLOCK WORLD PROBLEM
• The most important step in solving any hill-climbing issue is to pick the right
heuristic function.
• Definition of such a function, h
• If the block is appropriately positioned, h(x) = +1 for all the blocks in the
support structure; otherwise, h(x) = -1 for all the blocks in the support
structure.
•
16
• Any block that has the same support structure as the objective state is referred
to in this context as being appropriately positioned. Let's have a look at all the
iterations and their heuristics to achieve the goal state using the hill climbing
approach we outlined earlier:
17
STEEPEST-ASCENT HILL CLIMBING
This is a variation of simple hill climbing which considers all the moves from the current
state and selects the best one as the next state. Also known as Gradient search
Algorithm: Steepest-Ascent Hill Climbing
1. Evaluate the initial state. If it is also a goal state, then return it and quit. Otherwise,
continue with the initial state as the current state.
2. Loop until a solution is found or until a complete iteration produces no change to
current state:
a. Let SUCC be a state such that any possible successor of the current state will be
better than SUCC
b. For each operator that applies to the current state do:
i. Apply the operator and generate a new state
ii. Evaluate the new state. If is is a goal state, then return it and quit. If not,
compare it to SUCC. If it is better, then set SUCC to this state. If it is not
better, leave SUCC alone.
c. If the SUCC is better than the current state, then set current state to SUCC.
HILL-CLIMBING (CONTINUED…) - LIMITATIONS
Both simple Hill climbing and Steepest-Ascent Hill climbing may have
following limitations:
1. Local Maxima: a local maximum as opposed to global
maximum.
Way Out: Backtrack to some earlier node and try going in a
different direction
2. Plateaus: An area of the search space where evaluation function
is flat, thus requiring random walk.
Way out: Make a big jump to try to get in a new section
3. Ridge: Where there are steep slopes and the search direction is
not towards the top but towards the side.
19the test.
Way out: Apply two or more rules before doing
Simulated Annealing
• Simulated Annealing
• Simulated Annealing is a heuristic search algorithm applied to optimization
and artificial intelligence issues. By allowing the algorithm to occasionally
accept moves that do not improve, this variation of the hill climbing algorithm
can avoid the issue of getting stuck in local optima.
20
STEPS OF THE SIMULATED ANNEALING
ALGORITHM
• Start with an initial solution.
• Set the initial temperature to a high value.
• Repeat the following steps until the stopping criterion is met:
• Generate a new solution by making a small modification to the current solution.
• Evaluate the objective function of the new solution.
• If the new solution improves the objective function, accept it as the new current solution.
• If the new solution does not improve the objective function, accept it with a probability
that depends on the difference between the objective function values of the current and
new solutions and the current temperature.
• Decrease the temperature according to a cooling schedule.
21
• Return the current solution as the final solution.
• The main principle of the simulated annealing algorithm is to control the level of
randomness in the search process by altering the temperature parameter. High
temperatures enable the algorithm to explore new regions of the search space by
increasing its propensity to accept non-improving moves. The algorithm becomes
more selective and concentrates on improving the solution as the temperature drops.
• Simulated annealing has been successfully applied to a wide range of optimization
problems, such as the traveling salesman problem, the vehicle routing problem, and
the job shop scheduling problem. However, it requires careful tuning of the
temperature and cooling schedule parameters to achieve good performance.
22
TRAVELLING SALESMAN PROBLEM
23
TRAVELLING SALESMAN PROBLEM
24
SUMMARY
25
SELF ASSESSMENT
1. QUESTIONS
Local search algorithms can solve?
27
• Reference Books:
• 1. Russel and Norvig, ‘Artificial Intelligence’, third edition, Pearson Education, PHI, (2015)
• 2. Elaine Rich & Kevin Knight, ‘Artificial Intelligence’, 3nd Edition, Tata Mc Graw Hill Edition,
Reprint( 2008)
1. https://www.virtusa.com/digital-themes/heuristic-search-techniques
2. https://towardsdatascience.com/a-star-a-search-algorithm-eb495fb156bb
3. https://www.tutorialandexample.com/local-search-algorithms-and-optimization-problem/
4. http://cgi.di.uoa.gr/~ys02/siteAI2008/local-search-2spp.pdf
5. http://aima.eecs.berkeley.edu/slides-pdf/chapter04b.pdf
28