Professional Documents
Culture Documents
OVERVIEW
02/27/2024
Local Search Algorithm
Hill Climbing Search
Simple Hill Climbing
Steepest-ascent Hill Climbing
Stochastic Hill Climbing
Genetic algorithm
Local Beam Search
Simulated Annealing Search
LOCAL SEARCH
ALGORITHMS
In many optimization problems, the path to the goal is
irrelevant; the goal state itself is the solution.
Example: N-Queen problem, IC Design, Job scheduling, vehicle
routing, To reduce cost, as in cost functions
Advantages:
Very memory efficient (only remember current state)
State-space landscape
LOCAL SEARCH ALGORITHMS
EXAMPLE: N-QUEENS
Put n queens on an n × n board with no two queens on
the same row, column, or diagonal
HILL CLIMBING SEARCH
Hill climbing search algorithm is simply a loop that
continuously moves in the direction of increasing value.
It stops when it reaches a “peak” where no neighbour has
higher value.
This algorithm is considered to be one of the simplest
procedures for implementing heuristic search.
The hill climbing comes from the idea that if you are trying
to find the top of the hill and you go up direction from
wherever you are.
Sometimes called Greedy Local Search
Hill-Climbing Search
HILL CLIMBING SEARCH
Only records the state and its objective function value.
Does not look ahead beyond the immediate.
02/27/2024
Begin
/*Initially OPEN contains the root node and CLOSE is EMPTY*/
OPEN=[start]
CLOSE=[]
/*We Continue the loop till OPEN list is not EMPTY*/
While OPEN≠[] do
Begin
Remove the left most state from OPEN and call it X The algorithm
If X=GOAL then described is
Return SUCCESS called as
Else steepest
Begin ascent hill
1. Generate children of X climbing.
2. Put X on close
3. Discard the children of X if already on OPEN or CLOSE
4. Sort the remaining Children
5. Put the children on left side of OPEN in sorted order. according to the
heuristic value of each state
/*Note that the children are sorted first according to the heuristic merit and are
then put to the left sideof OPEN*/
End
End
Return Fail
End
Apply hill climbing to the following tree considering G is the Goal State and
Node A as the initial state.
Step 1: The hill climbing algorithm starts with the initial state.
OPEN = [A3]
CLOSE = []
Note that leftmost node in the OPEN list is Node A, and hence, we
expand Node A in the next step.
Apply hill climbing to the following tree considering
G is the Goal State and Node A as the initial state.
Note that the leftmost node in the OPEN list is Node C. Hence, we
expand Node C in Step 3.
Apply hill climbing to the following tree considering G is the Goal State and
Node A as the initial state.
Step 3: Amongst all the children of Node root Node A Node C has the
highest heuristic. Hence, all the children of Node C are now generated.
Note that leftmost node in OPEN list is Node E. Hence, we expand Node E
in Step 4.
Apply hill climbing to the following tree considering G is the Goal State and
Node A as the initial state.
Step 4: Now the algorithm proceeds towards Node E and among all the
children of Node E (only G is the child of Node E). Node G has a highest
Heuristic merit; and hence, Node G is generated.
Note that the leftmost node in OPEN list is Node G and Node G is a GOAL and
hence we STOP
DEMERITS OF HILL CLIMBING
2. Plateau: On plateau all neighbours have same value. Hence, it is not possible to
select the best direction. Plateau is a flat area of the search space in which a whole
set of neighbouring states has the value. On a plateau, it is not possible to
determine the best direction in which to move the local comparisons.
To overcome plateaus:
(a) A big jump in some direction can be done in order to get to a new
section of search space. This method is recommended as in a plateau all
neighbouring points have the same value.
(b) Another solution is to apply small steps several times in the same
direction. This depends on the rules available.
Problems in Different Regions in Hill climbing
02/27/2024
Here, h is heuristic cost function, is the number of pairs of queens
that are attacking each other, either directly or indirectly. Global
minimum is h=0, which occurs in perfect situation.
23
02/27/2024
HILL CLIMBING (EXAMPLE-1), 4-QUEEN
PROBLEM
24
02/27/2024
25
EXAMPLE: 4-QUEEN PROBLEM
* * * *
02/27/2024
4 5 5 4
4 4 4 4
4 3 3 4
Genetic Algorithm (GA)
GENETIC ALGORITHM (GA)
Inspired by evolutionary biology and natural selection,
such as inheritance.
Evolves toward better solutions.
02/27/2024
Two individuals, are selected at random for reproduction, in accordance with the
probabilities. This phase is called as Selection.
The offspring themselves are created using crossing over the parent strings at
crossover point. This phase is called as Crossover.
One or more digits are mutated in randomly chosen offspring. This phase is called as
Mutation.
For ex: In 8-queens it corresponds to choosing a queen at random and moving it to a
random square in its column.
GENETIC ALGORITHM
8 QUEEN PROBLEM
A better state is generated by combining two parent
states.
8 QUEEN PROBLEM
Represent individuals (chromosomes) : Can be
represented by a string digits 1 to 8, that represents the
position of the 8 queens in the 8 columns.
8 QUEEN PROBLEM
02/27/2024
Local Beam Search
LOCAL BEAM SEARCH
Function Beam-Search(Problem, k) returns a solution state
Start with k randomly generated states
Loop
Generate all successors of all k states
If any of them is a solution then return it
Else select the k best successors
LOCAL BEAM SEARCH
Start with k- random generated states.
Now obtain successor values of all the random generated
state.
The state that generate the best successor say to other come
here to find the solution.
i.e. in this we select k best successor state and repeat all if it is
not the goal state.