Local Search and Optimization Problems

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Local Search and

Optimization Problems
Local Search and Optimization Problems
Local search algorithms operate by searching from a start state to neighboring states, without keeping track
of the paths, nor the set of states that have been reached.

That means they are not systematic—they might never explore a portion of the search space where a
solution actually resides.

The two key advantages:

● They use very little memory.


● They can often find reasonable solutions in large or infinite state spaces for which systematic
algorithms are unsuitable
One-dimensional state-space landscape objective function.
Hill-climbing search

● Hill-climbing search keeps track of one current state and on each iteration
moves to the neighboring state with highest value that is, it heads in the
direction that provides the steepest ascent.
● It terminates when it reaches a “peak” where Steepest ascent no neighbor
has a higher value.
● Hill climbing does not look ahead beyond the immediate neighbors of the
current state.

https://www.geeksforgeeks.org/introduction-hill-climbing-artificial-intelligence/
Hill-climbing search algorithm
8-Queens problem
h=17

Ref: https://www.geeksforgeeks.org/n-queen-problem-local-search-using-hill-climbing-with-random-neighbour/
Terminologies:
Notion of a State:
A state here in this context is any configuration of the N queens on the N X N board. Also, in order to
reduce the search space let’s add an additional constraint that there can only be a single queen in a
particular column. A state in the program is implemented using an array of length N, such that if state[i]=j
then there is a queen at column index i and row index j.

Notion of Neighbours:
Neighbours of a state are other states with board configuration that differ from the current state’s board
configuration with respect to the position of only a single queen. This queen that differs a state from its
neighbour may be displaced anywhere in the same column.

Optimisation function or Objective function:


We know that local search is an optimization algorithm that searches the local space to optimize a function
that takes the state as input and gives some value as an output. The value of the objective function of a
state here in this context is the number of pairs of queens attacking each other. Our goal here is to find a
state with the minimum objective value.
Disadvantages of Hill Climbing Algorithm

Local maxima:
● A local maximum is a peak that is higher than each of its neighboring states but lower than the
global maximum.
● Hill-climbing algorithms that reach the vicinity of a local maximum will be drawn upward toward the
peak but will then be stuck with nowhere else to go.

Ridges:
● Ridges result in a sequence of local maxima that is very
difficult for greedy algorithms to navigate.
Disadvantages of Hill Climbing Algorithm

Plateaus (Shoulder):
● A plateau is a flat area of the state-space landscape.
● It can be a flat local maximum, from which no uphill exits.
● A hill-climbing search can get lost wandering on the plateau.
Complexity Analysis:
Calculating Objective:

The calculation of objective involves iterating through all queens on board and checking the no. of attacking
queens, which is done by our calculate Objective function in O(N2) time.

Neighbour Selection and Number of neighbours:

The description of neighbours in our problem gives a total of N(N-1) neighbours for the current state. The
selection procedure is best fit and therefore requires iterating through all neighbours, which is again O(N2).

Search Space:
Search space of our problem consists of a total of NN states, corresponding to all possible configurations
of the N Queens on board.

The worst-case time complexity of our algorithm is O(NN)

You might also like