Professional Documents
Culture Documents
The earlier search algorithms are designed to explore search spaces systematically.
In many problems, the path to the goal is irrelevant.
Ex: 8-queens -- only final configuration matters, not the order in which they are added.
This class of problems include applications such as:
integrated-circuit design
vehicle routing etc.
Figure 10.1: A one-dimensional state space landscape in which elevation corresponds to the objective function. The
aim is to find the global maximum. Hill-climbing search modifies the current state to try to improve it, as shown by
the arrow.
If elevation corresponds to
cost -- aim is to find the lowest valley (a global minimum)
objective function -- aim is to find the highest peak (a global maximum)
Algorithm: Steepest-ascent
In the above algorithm, if a heuristic cost estimate h is used, the neighbour will have the lowest
h value.
Ex: 8-queens
Each state has 8 queens on the board.
Successor function returns all possible states generated by moving a single queen to another
square in the same column.
Heuristic function h :
The number of pairs of queens that are attacking each other, either directly or indirectly.
Global minimum is zero (i.e., the number of pairs attacking each other is zero).
movement
It is a state that is better than all its neighbours but is not better than some other states farther away.
When local maxima occur almost within sight of a solution, they are called ‘foothills’.
Plateau:
It is a flat area of the search space, in which all neighbours
have the same value.
It is not possible to determine the best direction.
Ridge:
valley
It is a special kind of local maximum.
This area in the path must be traversed
very carefully because movement in any
direction maintain one at the same level movement
or result in fast descent.
1. Stochastic hill climbing : Chooses at random among the uphill moves, the probability of selection can vary with
the steepness of the uphill move.
2. First-choice hill climbing : Implements stochastic hill climbing by generating successors randomly until one is
generated that is better than the current state.
3. Random-restart hill climbing: Conducts a series of hill climbing searches from randomly generated initial states,
until a goal is found.
Hill-climbing algorithm that never makes downhill moves is guaranteed to be incomplete because it can get stuck
on a local maximum.
In contrast, a purely random walk (choosing a successor randomly) is complete, but inefficient.
Simulated annealing is an algorithm that combines hill-climbing with random walk and yields both efficiency and
completeness.
As a computational process, Simulated annealing is patterned after the physical process of annealing.
Annealing: A process in which physical substances such as metals are melted (i.e., raised to high energy levels [high
temperatures]) and then gradually cooled until some solid state is reached.
Algorithm:
The algorithm is similar to hill-climbing, but instead of picking the best move, it picks a random move.
If the move improves the situation, it is always accepted. Otherwise, it accepts the move with some probability
less than 1.
The probability decreases exponentially with the “badness” of the move – the amount ΔE by which the evaluation
is worsened.
Consider the rows having ‘next’ value as 5 in the above two tables.
The probability value (1/e3) when T=5 is less than the probability value (1/e 1.5) when T=10
(i.e., if temperature decreases, then probability also decreases)
If the schedule lowers T slowly enough, the algorithm will find a global optimum with
probability approaching 1.
k random states
In this search, useful information is passed among the k parallel search threads.
For example,
if one state generates several good successors and the other k-1 states all generate bad
successors,
then the algorithm quickly abandons unfruitful searches and moves its resources to where the
most progress is being made.
In this search, successor states are generated by combining two parent states, rather than by modifying a
single state.
GAs begin with a set of k randomly generated states, called the population.
Each state or individual is represented as a string over a finite alphabet – most commonly a string of 0s and 1s.
Ex: An 8-queen state must specify the positions of 8 queens, each in a column of 8 squares and so requires
8 x log28 = 24 bits.
Alternatively, the state could be represented as 8 digits, each in the range from 1 to 8.
(b): Each state is ranked by the fitness function (or an evaluation function).
A fitness function should return higher values for better states, so for this problem we use:
number of non-attacking pairs of queens.
In this particular variant of the GA, the probability of being chosen for reproducing is directly proportional to the
fitness score and the percentages are shown next to the raw scores.
Explanation for ‘the number of non-attacking pairs’:
Consider the 4th state in (a) : 32543213 (positions are from bottom to top)
All pairs:
1-2 1-3 1-4 1-5 1-6 1-7 1-8
• 2-3 2-4 2-5 2-6 2-7 2-8
Q
• 3-4 3-5 3-6 3-7 3-8 Direct or Indirect attacking :
Q
• 4-5 4-6 4-7 4-8 Not marked with Red
• 5-6 5-7 5-8
Q Q Q
• 6-7 6-8 Total no. of Pairs : 28
Q Q
• 7-8 No. of non-attacking pairs : 11
Q
(c) A random choice of two pairs is selected for reproduction in accordance with the probabilities
in (b).
(one individual is selected twice and one not at all)
(d) The offspring are created by crossing over the parent strings at the crossover point.
One digit was mutated in the 1st, 3rd and 4th offspring.
Algorithm:
In this algorithm,
each mating of two parents produces only one offspring, not two.
****