What is a Local Search Algorithm?
Local search algorithms are a type of optimization algorithm used in artificial intelligence
that searches for a solution by iteratively improving a single candidate solution rather than
systematically exploring the search space like uninformed or informed search algorithms.
In local search, a single candidate solution is initially generated. Then, the algorithm
repeatedly evaluates and modifies the current solution until an optimal solution is found or a
stopping criterion is met. At each iteration, the algorithm considers a set of neighboring
solutions and selects the one that best improves the objective function.
Local search algorithms can effectively solve large, complex optimization problems with a
large search space, as they can quickly converge to a good solution by focusing on the most
promising regions of the search space.
Types of the Local Search Algorithm
There are several types of local search algorithms used in artificial intelligence. Some of the
most common types of local search algorithms are:
Hill Climbing: This is a simple local search algorithm that repeatedly makes small
improvements to the current solution by moving to the neighboring solution with the
highest objective function value.
Simulated Annealing: This is a probabilistic local search algorithm that allows the
algorithm to accept moves that worsen the objective function, with a decreasing
probability over time, to avoid getting trapped in local optima.
Tabu Search: This local search algorithm keeps track of recently visited solutions
and avoids revisiting them to avoid getting stuck in cycles.
Genetic Algorithms: This population-based search algorithm uses natural selection
and genetic operators to iteratively generate and improve a population of candidate
solutions.
Local Beam Search: This is a variation of beam search that maintains k states instead
of one and performs a local search on all k states.
Iterated Local Search: This metaheuristic starts with a random initial solution and
repeatedly applies local search to a perturbed version of the current best solution until
a stopping criterion is met.
Variable Neighborhood Search: This metaheuristic applies a sequence of local
searches to a candidate solution, each with a different neighbourhood structure.
Hill Climbing Search
Introduction
The purpose of the hill climbing search is to climb a hill and reach the topmost peak/ point of
that hill.
Hill climbing is a simple local search algorithm used in artificial intelligence for
optimization problems. It starts with an initial solution and iteratively improves the solution
by making small modifications to the current solution to maximize or minimize an objective
function.
The hill-climbing algorithm is called so because it tries to climb the hill of the objective
function by repeatedly selecting the neighbour with the highest objective function value until
no better neighbour can be found.
State-space Landscape of Hill Climbing Algorithm
Consider the above figure, representing the goal state/peak and the current state of the
climber.
The state-space landscape signifies a graphical representation of the hill-climbing
algorithm, which depicts a graph between various states of the algorithm and Objective
function/Cost.
The topographical regions shown in the figure can be defined as:
Global Maximum: It is the highest point on the hill, also the goal state.
Local Maximum: It is the peak higher than all other peaks but lower than the global
maximum.
Flat local maximum: It is the flat area over the hill with no uphill or downhill. It is a
saturated point of the hill.
Shoulder: It is also a flat area where the summit is possible.
Current state: It is the person's current position.
On Y-axis, we have taken the objective function or cost function and state space on the x-
axis. If the function on Y-axis is cost, then the aim of the search is to find the global
minimum and local minimum. If the function of the Y-axis is the cost function, then the goal
of the search is to find the local maximum and global maximum.
Algorithm
The algorithm has the following steps:
Generate an initial solution.
Evaluate the objective function for the initial solution.
Generate the neighbours of the current solution.
Select the neighbour with the highest objective function value.
If the objective function value of the selected neighbour is better than the current
solution, update the current solution with the selected neighbour and repeat step 2.
Otherwise, terminate the algorithm and return the current solution as the best solution
found.