0% found this document useful (0 votes)
14 views

Evolutionary algorithms

GENETIC algorithm in soft computing
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Evolutionary algorithms

GENETIC algorithm in soft computing
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 66

MODULE 3

EVOLUTIONARY ALGORITHMS
Module 3
EVOLUTIONARY ALGORITHMS:
• Evolutionary Algorithms, Genetic Algorithms, Fitness Scaling,
Selection, Mutation, Crossover, Other Genetic Operators, Algorithm
Working, Diversity, Grammatical Evolution, Other Optimization
Techniques, Meta heuristic Search, Traveling Salesman Problem
• Text Book 1: Chapter 5: 5.1 -5.15
Evolutionary Algorithms

• Evolution is a novel system that has led to the creation of great


systems in the natural and artificial world.
• Looking at any species in the natural world can give us a clear idea of
evolution. The most complex species is the result of continuous
evolution over time. Evolution started with a simple species.
• Over time, these species evolved into newer and newer species, each
more complex and better suited to the changing environments than the
last.
• Inspired by the natural systems, the artificial systems are also trying to
learn from evolutionary principles Optimization has always been one
of the major problems in the field of computation.
In these computations, we must optimize the solutions to any problem. If the
number of possible solutions were constant, it would make sense to find all the
possible solutions and then compare their performances.
In reality, however, the number of solutions is so large that any machine would not
be able to generate them all in a finite duration of time.
Optimization problems always have multiple solutions with varying degree of
goodness or accuracies.
The best solution is the one that has the most optimal (maximum or minimum)
value of the objective function.
The objective function is a means of measuring the goodness or accuracy of a
solution to these optimization problems.
Contd..

In other words, the aim of optimization is to minimize or maximize the


value of the objective function.
This is achieved by varying the parameters or variables upon which the
objective function depends.
Every set of values of variables corresponds to some level of goodness
as measured by the fitness function.
The final output of the algorithm is the value set of these variables,
which gives the most optimal value of the objective function.
GA (Genetic Algorithm)
• Evolutionary computation, or evolutionary algorithms (EAs), is an
inspiration derived from its biological counterparts
• The GA is inspired from the survival and reproductive systems of the
natural species.
• species consists of populations-->These populations comprise the set
of individuals
• The capability of the species may be taken as the average capability,
or fitness, of all the individual of that species.
• The different individuals in the population sexually interact to
generate newer individuals.
• It is generally observed that the average fitness of the newer
generation is better than that of the preceding generations, and thus
the newer generations can better adapt to the changing
environment, as theorized by Charles Darwin’s survival of the fittest.
Concept
• The GA starts with a set of solutions or populations.
• Each individual in the population set represents a
solution to the problem.
• The nature of the solution, however, varies. Some
solutions may be very good, while others are very bad.
• The goodness of the solution varies from individual to
individual within the population.
• To measure the goodness of the solution, we use a
function called the fitness function, which must be
made according to the program logic.
• Initially the population set contains all randomly
generated solutions that are initially generated.
• This is called the first generation of the population.
• Then the various genetic operators are applied over the
population.
• The genetic operators help in the generation of a new
population set from the old population set.
• The new population set is formed by the genetic
reproduction of the parents to form the children.
• Various other genetic operators are also applied that
help generate the new population set.
• These specialized operators help in better optimization
of the solution.

Dr. S. Priya, Assistant Professor, MIT Bengaluru


The simple genetic algorithm.
• The GA is applied to the optimization problems, in which we are
required to optimize an objective function by varying some
variables or parameters.
• Consider the problem of functional optimization, in which we are
given a set of input variables.
• We have an objective function that we must optimize, which is
the goal of the problem.
• In addition, we have a set of constraints that every solution must
follow.
• An example of this problem is given by
• The solution may be feasible or infeasible. Infeasible solutions
usually disobey some constraint of the problem and are hence
not valid solutions.
• Infeasible solutions cannot be returned as the final solutions
by the GA and are usually not accepted in the solutions at all.
• So far we have represented the solution in an easy-to-
understand format.
• This type of solution, known as the phenotype solution, may
be used for computation of fitness or other comparisons or
operations.
• The GA, however, may require a different representation of
the solution, in this case the genotype solution, to perform
and function.
• The genotype solution is usually a sequence of bits or numbers.
• Each bit may be either 0 or 1.
• The whole phenotype solution is represented in such a way that
we may represent it in the form of continuous bits.
• The entire bit sequence is the solution in the genotype form.
• The conversion of the solution into this format of bit string comes
from the classic theory of GA.
• The various genetic operators were designed assuming the
individuals were a series of bits.
• We shall later see that representation of the solution in the form
of a continuous series of numbers (not necessarily binary) also
works and often gives better performance.
• In general, for any problem that we need to optimize
with the help of GA, we first must represent it in the
form of a solution.
• Once this has been done, we can apply the various
genetic operators to optimize and find the most optimal
solution.
• The solutions may take different representations. If we
try to train an ANN by GA, the solution represents the
different weights and biases if the structure is kept
constant.
Initial Population

• One of the first steps in the algorithm is to generate an


initial population, or the starting population that
ultimately leads to the generation of newer and newer
generations.
• Mostly the initial population is generated randomly. We
know the total length of the solution’s genotype
representation.
• The standard practice is to generate random series of
0’s and 1’s to fill this solution.
Genetic Operators
Selection:
• Selection is an important step, because it decides the
parents that are responsible for the individuals being
generated
• Selection is done on the basis of the individual’s
reproductive capability, or fitness value.
• An individual having a higher fitness has a high
reproductive capability and thus is likely to be selected
numerous times.
• The weaker individuals, on the other hand, may not be
selected at all for reproduction.
• This is also prevalent in natural systems, in which a
powerful animal mates more often than does a weaker
one
Crossover:
• The next operation they need to perform is crossover, or the
genetic operator that results
• in the mixing of two parents to generate individuals of the
new population.
• Crossover is done by taking some bits from the first parent
and other bits from the other parent.
• One of the commonly used crossovers is the single-point
crossover, in which we randomly select a point in the
chromosome.
• The bits to the left of this point are taken from the first parent
and the bits to the right are taken from the other parent.
• This generates new individuals in the new population.
• Mutation:
• Crossover results in the mixing of characteristics between two
individuals.
• Many characteristics may be completely absent in the solution
pool, even if many of those missing characteristics may have
been desirable for good solutions.
• This absence may be due to the fact that these characteristics
were never generated, or that these characteristics somehow
got deleted.
• Mutation is the process by which we try to introduce random
characteristics into the population. We do this done by flipping
bits.
• A random bit in the individual is selected and is simply swapped
during mutation. Thus if it represented 1, it now represents 0,
and vice versa.
Fitness Function
• The quality of the solution or of any individual is measured by the
fitness function.
• This function decides how good the solution is. In general, a good
solution will have a high value of fitness function, whereas a bad
solution will have a low value.
• Sometimes the converse relation may also be applied.
• Using the fitness function, we may be able to rank the solutions
from good to bad, which is very helpful in the selection operator.
• The fitness function gives a quantifiable way for us to measure
the solutions and the behavior of the algorithm.
• The fitness function is hence very helpful for knowing how the
algorithm is behaving over time and over generations.
Stopping Condition
• There are numerous ways to set the stopping criterion:
• If the solutions being generated are sufficiently optimized
and further • optimizations may not be helpful, we may wish
to stop the algorithm.
• This is when the goal that was set before training has been
met.
• • If the time taken by the algorithm or the number of
generations exceeds a certain number, we may wish to stop.
• • If the improvement by subsequent generations or time is
too low and the solution seems to have converged, we may
choose to stop the algorithm.
• This is also known as stall time or stall generation.
Fitness Scaling

• Scaling is one such mechanism for effective selection. In


scaling, the individuals in the population are rescaled
according to their fitness values.
• The scaling of fitness values gives rise to the expected
value of the individuals.
• This new value will then help the selection operator to
select the parents.
• The expected value denotes the fitness of the solution
in the new scale.
Rank Scaling
• In rank scaling, the individuals in a population are
ranked according to their fitness value.
• Each individual is given a rank from 1 to N. The
expected value of any individual is on the basis of rank.
• The expected value of any solution in this method is
given by
• where ExpValue(i, t) denotes the expected value of
individual i at time t;
• Min is the minimum most expected value, or the value
for the solution with first rank;
• Max is the maximum most expected value, or the value
for the solution with rank N;
• and N is the number of individuals in the population
Proportional Scaling
Top Scaling
Selection
• Roulette Wheel Selection
• In roulette wheel selection, the probability of selecting any
individual is directly proportional to that individual’s expectation
value.
• Hence the more fit solutions have a greater chance of being
selected again and again.
• To perform selection, the roulette wheel is spun N times, where N
is the number of individuals in the population.
• After each spin, the reading of where the wheel stops is noted.
• The wheel is naturally more likely to stop at individuals whose
fitness value is large.
• For implementation purposes, the roulette wheel is implemented
by first summing up all the expectations of all individuals.
Stochastic Universal Sampling

• The roulette wheel implementation faces one problem: It is


likely that the high-fitness individuals will keep getting
selected, and the lower ones will not get selected at all.
• In such a case, the population would result in only a few
solutions being repeated over again and again, which would
kill diversity.
• To prevent this situation, we have another reimplementation of
the roulette wheel.
• In this type, there are N selectors in place of one. This makes
it possible to simultaneously select N individuals.
• The wheel is rotated only once, and the N populations are
selected. This implementation is called stochastic universal
sampling (SUS).
Rank Selection
• Rank selection is similar to that of the roulette wheel, except that
the individuals are scaled according to their ranks.
• The higher fitness solutions have a higher chance of being selected.
• However, this method removes the dominance of a few high-fitness
solutions, as might be the case with the roulette wheel.
• In roulette wheel selection, it is possible for the entire selected
population to
• consist of only a few individuals that get selected again and again.
• Using rank selection, however, even if some individual has an
exceptionally large fitness value, it would not be selected again and
• again, because the selection is on the basis of rank that are
uniformly distributed rather than fitness value.
Tournament Selection

• Tournament selection further solves the problem of a solution


being excessively selected and dominating the population.
• This method of selection is inspired by the tournament, or
the competitive method.
• In this selection, we first select any two random individuals
from the population.
• We also select a random number r between 0 and 1.
• If r is found to be greater than a predefined number k
(approximately 0.75), then the lesser fit individual is
selected; otherwise the individual with the higher fitness is
selected.
Mutation

• Mutation is the addition of new characteristics into the


population.
• With mutation, we randomly try to inject newer
characteristics into the population.
• If these characteristics are good, they will survive and
continue into the next population.
• If they are undesirable, however, they will be eliminated
in subsequent iterations.
• The mutation results in adding newer areas to the GA’s
search space.
Uniform Mutation

• Uniform mutation is the most common mutation


operation. In this operation, the value at the selected
location is simply flipped.
• Thus if a 0 is present in the location, it changes to 1,
and vice versa.
Gaussian Mutation

• Gaussian mutation happens in the case of the numeral


representation of the solution, where the solution is
represented by simple numbers.
• In this type of mutation, we add a randomly generated
number to the existing value at the selected location.
• The random number is taken from the Gaussian distribution
with a center at 0.
• This normally generates very small values of either sign,
which makes small changes to the solutions.
• Sometimes big changes are also produced, however, that
cause a big change in the solution.
Variable Mutation Rate

• The mutation rate may be changed during the running of the


algorithm.
• This is known as a variable mutation rate.
• This mutation is sometimes used to control the behavior of the
algorithm.
• A high mutation rate, as discussed earlier, is the sign of
randomness, which might be a good phenomenon at the start of
the algorithm, when we are trying to explore newer and newer
possibilities.
• At the end of the algorithm, however, the mutation rate may be
kept small to allow the algorithm to converge.
• In this manner, we may vary the mutation rate according to some
principle
Cross over
• In crossover, we mix two parents to generate a new individual by
taking some genes from the first parent and some from the other.
• The crossover operation, as discussed earlier, tries to generate
fitter solutions by combining the characeristics of the parents
• Crossover also has an associated probability called the
probability of crossover, or pc.
• This probability decides the total percentage of populations that
will go to the next generation as a result of the crossover
operation.
• This probability is usually kept high because crossover has much
less randomness in it.
• The solutions in crossover are more or less predictable and along
the lines of the parents.
• Hence this probability is kept high to allow the algorithm to
converge at the correct time.
Single-Point Cross over

• The single-point crossover is the simplest type of


crossover. We select any random number between 0
and n, where n is the length of the chromosome.
• This point is called the crossover point.
• The genes to the left of the crossover point are taken
from the first parent, while those to the right are taken
from the second parent to form the new individual.
Two-Point Cross over

• Many times the one-point crossover does not give very


good results.
• In such instances, the two-point crossover is used instead.
• In this crossover, we select two crossover points in place of
the one that was used in one-point crossover.
• The new solution is made by taking genes from between
the two
• crossover points from one parent and the rest of the genes
from the second parent to generate the new individual.
Scattered Cross over

• we first create a random vector of binary values.


• The length of this vector is the length of the individuals.
Each element of this vector is either 0 or 1, which denotes
the parent.
• If the vector contains 0 at any position, the gene
corresponding to this position is taken from the first parent,
and vice versa.
• Thus position has no relevance in this; and hence this
solution is position independent.
• This characteristic is important because of the highly
interconnected nature of the genes and the attributes in
deciding the fitness.
Intermediate Cross over
Heuristic Cross over
Other Genetic Operators
• Eliticism
• Eliticism selects some predefined proportion of individuals with
highest fitness from one generation
• and passes it straight to the next generation. This operator saves
these high-fitness individuals
• from being destroyed by crossover or mutation and makes them
available in the next generation.
Insert and Delete
• The insert operator allows the insertion of new individuals in the
population pool.
• This makes the entire algorithm flexible to accepting new
individuals. Based on the solution, at any point, we can generate
new individuals with high fitness.
• These individuals may be added to the pool by using the insert
• Similarly, the delete operator allows deletion of some
individuals from the population set.
• We may wish to delete certain individuals that have a
low fitness value.
• This operator may be used in such circumstances
Hard and Soft Mutation

• Many times the mutation operator may be split in two.


• One part, or the soft mutation, brings about small changes in
the individual. Because the changes are small, big changes
might not be expected in the behavior of these solutions.
• This operatore may be used to control the system
convergence or for general addition of new characteristics.
• The other operator, or the hard mutation, is used to carry out
big changes in the individual.
• This mutation may completely transform the individual.
• It brings major changes in the solution’s behavior. This
mutation may be used very rarely to add very new
characteristics to the system.
Repair

• Many times, the GA may generate infeasible solutions. The


repair operator may be used to repair the infeasible
solutions before they are stored in the population pool.
• This operator converts an infeasible solution into a solution
that could be feasible.
• For this, we need to study the problem constraints and
examine the individual.
• We make as slight modifications as possible in order to make
the solution feasible.
• The fitness value of this newly generated solution cannot be
guaranteed
Convergence
Diversity

• Diversity is the average distance between the individuals in a


population. This distance may be measured as the geometric,
Manhattan, or any other distance between the features of the
corresponding individuals in this n-dimensional map.
• Diversity is said to be high if the average distance between the
individuals is high.
• A high distance means that the individuals are far apart in this n-
dimensional map and cover almost the entire map.
• On the contrary, if the individuals in the population are close
together, the diversity is low, which means the individuals are
concentrated at some region of the map.
• With low distances, there might not be any individual at some
locations.
Other Optimization
Techniques
Particle Swarm Optimization

• PSO is a technique inspired by the natural process of flocking


birds, which is also known as swarm intelligence.
• It derives intelligence by studying the social or group behavior of
the animals a group of birds must search for some food.
• They all search in random directions, starting from random
positions.
• Each bird knows how close it is to the food, because the birds are
coordinated with each other.
• Hence for any bird, it would be natural for it to move toward the
bird that is closest to the food of all the birds.
• It would also be guided by its own experiences so far in the
search process
• The movement of the particles updates both their
speeds and the positions. Particle movement is
governed by the local and global planner. In PSO, this is
modeled by a set of equations. Let the speed of any
particle i at any iteration t be vi t. Let the particle be at
position xi t at this iteration. At the next iteration t + 1,
the position and the speed of the particles get updated
as given by
Ant Colony Optimizations

• The other optimization studied here is the ant colony


optimization (ACO).
• Like the PSO and GA, this algorithm is also inspired by
the natural process—in this case, the process of ants
working in their colonies.
Metaheuristic Search
• Another similar approach is the simulated annealing (SA), which derives its
analogy from the
• way in which metals are cooled and frozen into a minimum energy crystalline
structure.
• This analogy is used to prevent the algorithm from getting trapped into some
local minima.
• This algorithm makes some small changes to the current node n in order to
arrive at some other node.
• If the new node is better, then the move is executed. If, however, the selected
node is not better, the move is executed with some probability p.
• In this algorithm, each node n has an energy value given by the fitness
function f(n). Furthermore there is another parameter introduced called
temperature (T).
• The probability of the move being executed, in case it leads to a solution with
an undesirable fitness, is given by
Traveling Salesman Problem
• Problem Description
• A salesman has been given the task of selling products.
He must sell to a total of n houses. The salesman is
supposed to go to each and every house. The starting
house is given. The salesman must
• then return to the starting house at the end. In addition,
every house is reachable from every house, but the
distances between the houses are all different. The
salesman must travel in such a way that the total length
of the path traversed is minimal.
Cross over
• Mutation
• As discussed above, mutation also results in an
infeasible path. For the same reasons, we modify the
mutation operation in the same manner for this
problem.
Fitness Function

• As discussed above, for any problem, the total path traced by the
salesman is s → a1 → a2 → a3 → a4 . . . an–1 → s. The fitness
function for this problem is the sum of the geometric distance
between all sets of points. Note that the first and the last points
are constants that are given to us initially.
• Results

You might also like