Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
14 views36 pages

Genetic Algorithms - Lecture Notes

The document provides an overview of genetic algorithms (GAs) and their applications in solving optimization problems, highlighting the importance of crossover and mutation techniques. It discusses the structure of evolutionary algorithms, including components like fitness functions and selection operators, and outlines the steps involved in a GA process. Additionally, it covers various evolutionary computing paradigms and representation methods for candidate solutions.

Uploaded by

ftwaha2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views36 pages

Genetic Algorithms - Lecture Notes

The document provides an overview of genetic algorithms (GAs) and their applications in solving optimization problems, highlighting the importance of crossover and mutation techniques. It discusses the structure of evolutionary algorithms, including components like fitness functions and selection operators, and outlines the steps involved in a GA process. Additionally, it covers various evolutionary computing paradigms and representation methods for candidate solutions.

Uploaded by

ftwaha2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

GENETIC

ALGORITHMS
NOTES

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


RECAP
So far we have used simple genetic algorithms to solve the
following problems:
• Guess a target password
• Generate a random sorted array of numbers
• The 8 queens problem

This provided us with a good opportunity to:


• Appreciate the performance and structure of a genetic
algorithm vs. a brute-force one
• To improve our Python programming skills

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


MOVING FORWARD
Characteristics of the GA we programmed so far:
• We only used one parent
• The generation of offspring's consisted of only one gene-
mutation

We need to look at other techniques for crossover (e.g.,


using two parents or more)
We also need to consider other ways of performing mutation
These can lead to an improvement in the GA for solving hard
optimisation problems

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


RESOURCES
We are using the textbook Ch 9

Section 9.2 on Crossover and 9.2.1

Section 9.3 on Mutation

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


GENETIC ALGORITHMS
Evolutionary Computation = Computation procedures
patterned after biological evolution

Evolutionary Computation = Search procedures that


probabilistically applies search operators to a set of points in
the search space

GA algorithms can be thought of as a search through the


space of possible chromosome values.
= is a stochastic search for an optimal solution to a given
problem.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


GENETIC ALGORITHMS

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


GENETIC ALGORITHMS
Inventors

● John Holland “Adaptation in Natural


and Artificial Systems”, University of
Michigan Press (1975)- Genetic
Algorithms
● Lawrence Fogel, M. Evans, M. Walsh
“Artificial Intelligence through Simulated
Evolution”, Wiley, 1966 - Evolutionary
programming
● Ingo Rechenburg, 1965 - Evolutionary
Strategies
ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017
ML and GA
•Most Machine Learning is concerned
with constructing a hypothesis from
examples that generalises well
–fast but very biased
•GA is a discovery-search over
hypotheses
–slow and unbiased
GENETIC ALGORITHMS
Components of a EA (Evolutionary algorithm):
An encoding of solutions to the problem as a chromosome;
a function to evaluate the fitness, or survival strength of
individuals;
initialization of the initial population;
Selection operators; and
reproduction operators.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


The GA Steps in
Pseudocode
1. Create a population of encoded potential
solutions (chromosomes)
2. Evaluate the fitness of all the
chromosomes
3. Select fitter chromosomes to form new
candidate population
4. Form new candidate population by
recombining genes from candidate
population
5. Mutate
6. Until satisfied go to 2
ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017
EVOLUTIONARY
COMPUTING PARADIGMS
Genetic algorithms (GAs), which model genetic evolution.
Genetic programming (GP), which is based on genetic algorithms, but
individuals are programs (represented as trees).
Evolutionary programming (EP), which is derived from the simulation of
adaptive behavior in evolution (i.e.phenotypic evolution).
Evolution strategies (ESs), which are geared toward modeling the strategic
parameters that control variation in evolution, i.e. the evolution of evolution.
Differential evolution (DE), which is similar to genetic algorithms, differing
in the reproduction mechanism used.
Cultural evolution (CE), which models the evolution of culture of a
population and how the culture influences the genetic and phenotypic
evolution of individuals.
Co-evolution (CoE), where initially “dumb” individuals evolve through
cooperation, or in competition with one another, acquiring the necessary
characteristics to survive.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


THE REPRESENTATION -
1
Chromosomes containing genes (a gene is the unit of
heredity)
Each individual has a unique sequence of genes
In EC, each individual is a candidate solution to an
optimisation problem
The characteristics of an individual is represented by a
chromosome (= a genome)

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


THE REPRESENTATION -
2
Characteristics of an individual can be divided in two
classes:
• A genotype: the genetic composition of an individual as
inherited from its parents (which alternate forms of genes, i.e.,
alele, does the individual poses)

• A phenotype: the behavioural traits of an individual in a


specific environment: what the individual looks like

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


THE REPRESENTATION -
3
An important step in the design of an EA is to find an
appropriate representation of candidate solutions (i.e.
chromosomes).
The efficiency and complexity of the search algorithm greatly
depends on the representation scheme.
The classical representation scheme for GAs is binary
vectors of fixed length.
Other representations include: integer representations,
permutations, finite-state representation, tree
representations, mixed-integer representations.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


Example of
representing hypothesis
E.g.
Outlook{Sunny, Overcast, Rain},
Wind {Strong, Week}
PlayTennis {Yes, No}
Represent
‘(Overcast V Rain)(Wind=Strong)’ by
011 10
Represent
‘IF Wind=Strong THEN PlayTennis=yes’ by
111 10 10 or
111 10 1
Can you figure out the rationale?
INITIAL POPULATION - 1
Evolutionary algorithms are stochastic, population-based
search algorithms.
Each EA therefore maintains a population of candidate
solutions.
The first step in applying an EA to solve an optimization
problem is to generate an initial population.
The standard way of generating an initial population is to
assign a random value from the allowed domain to each of
the genes of each chromosome.
The goal of random selection is to ensure that the initial
population is a uniform representation of the entire search
space.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


INITIAL POPULATION -2
The larger the size of the initial population, the higher the
computational complexity of the search per generation
It could be the case the fewer generations are sufficient to
locate an acceptable solution
A small population may need more generations to converge
than a large population.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


THE FITNESS FUNCTION
The idea: “individual with best characteristics have the best
chance to survive and to reproduce”.
The fitness function assigns a scalar value to a chromosome
The fitness function represents the function that describes
the optimization problem
Usually the fitness function provides an absolute measure of
fitness: i.e., the chromosome is directly evaluated using the
fitness function

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


TYPES OF OPTIMISATION
PROBLEMS
Unconstrained optimization problem
Constrained optimization problems
Multi-objective optimization problems
Dynamic and noisy problems where function values of
solutions change over time

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


SELECTION (SECTION 8.5)
The main objective of selection operators is to emphasize better
solutions. This is achieved in two of the main steps of an EA:

Selection of the new population: A new population of candidate


solutions is selected at the end of each generation to serve as the
population of the next generation. The new population can be
selected from only the offspring, or from both the parents and the
offspring. The selection operator should ensure that good
individuals do survive to next generations.

Reproduction: Offspring are created through the application of


crossover and/or mutation operators. In terms of crossover,
“superior” individuals should have more opportunities to
reproduce to ensure that offspring contain genetic material of the
best individuals.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


SELECTION - 2
Types of selection:
• Selective Pressure
• Random Selection
• Proportional Selection
• Tournament Selection
• Rank-based Selection
• Boltzmann Selection
• Elitism
• Hall of Fame

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


REPRODUCTION
OPERATORS
Crossover: process of creating one or more individuals
through the combination of the genetic material randomly
selected from two or more parents
Mutation: process of randomly changing the values of genes
in a chromosome, the main purpose being to introduce new
genetic material into the population.
Mutation should be applied with care not to distort the good
genetic material in highly fit individuals.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


STOPPING CONDITIONS
Terminate when no improvement is observed over a number
of consecutive generations. This can be detected by
monitoring the fitness of the best individual. If there is no
significant improvement over a given time window, the EA
can be stopped.
Terminate when there is no change in the population. If, over
a number of consecutive generations, the average change in
genotypic information is too small, the EA can be stopped.
Terminate when an acceptable solution has been found.
Terminate when the objective function slope is approximately
zero.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


QUESTIONS
1. What is the structure of a EA?
2. Discuss the importance of the fitness function in EC.
3. In the case of a small population size, how can we
ensure that a large part of the search space is covered?
4. Identify disadvantages of fitness-based selection
operators.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CANONICAL GENETIC
ALGORITHM
Holland
A bitstring representation was used.
Proportional selection was used to select parents for
recombination.
One-point crossover (refer to Section 9.2) was used as the
primary method to produce offspring.
Uniform mutation (refer to Section 9.3) was proposed as a
background operator of little importance.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CROSSOVER
Crossover = Parent Selection + Recombination process +
Replacement policy

asexual, where an offspring is generated from one parent.


sexual, where two parents are used to produce one or two
offspring.
multi-recombination, where more than two parents are used
to produce one or more offspring.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CROSSOVER
Replacement Policy – typical one is:
If one offspring is generated, the offspring may replace the
worst parent.
Such replacement can be based on the restriction that the
offspring must be more fit than the worst parent, or it may be
forced.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CROSSOVER
OPERATORS - 1
One-point Crossover: A one-point
crossover operator was developed
that randomly selects a crossover
point, and the bitstrings after that
point are swapped between the two
parents.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CROSSOVER
OPERATORS - 2
Two-point crossover: In this case
two bit positions are randomly
selected, and the bitstrings
between these points are swapped

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CROSSOVER
OPERATORS - 3
Uniform crossover: The nx-
dimensional mask is created
randomly
Here, px is the bit-swapping
probability. If px=0.5, then each bit
has an equal chance to be
swapped.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


MUTATION
The aim of mutation is to introduce new genetic material into
an existing individual
Mutation is used in support of crossover to ensure that the
full range of allele is accessible for each gene
Mutation is applied at a certain probability, pm, to each gene
of the offspring, to produce the mutated offspring

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


MUTATIONS FOR BINARY
REPRESENTATIONS
Uniform (random) mutation
where bit positions are
chosen randomly and the
corresponding bit values
negated as illustrated

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


MUTATIONS FOR BINARY
REPRESENTATIONS
Inorder mutation where two
mutation points are randomly
selected and only the bits
between these mutation
points undergo random
mutation.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


CONTROL PARAMETERS
IN A GA
Crossover Rate: recombination is applied probabilistically.
Each pair (or group) of parents have a probability of
producing offspring (= the crossover rate)
Mutation rate: the probability used to mutate a gene. A large
initial mutation rate favors exploration in the initial steps of
the search, and with a decrease in mutation rate as the
generation number increases.
• A good strategy is to base the probability of being
mutated on the fitness of the individual: the more fit the
individual is, the lower the probability that its genes will be
mutated; the more unfit the individual, the higher the
probability of mutation.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017


QUESTIONS
1. Discuss the importance of the crossover rate, by
considering the effect of different values in the range
[0,1].

2. Compare the following replacement strategies for


crossover operators that produce only one offspring:
(a) The offspring always replaces the worst parent.
(b) The offspring replaces the worst parent only when its
fitness is better than the worst parent.
(c) The offspring always replaces the worst individual in the
population.

ATAYLOR - COMPUTATIONAL INTELLIGENCE 2017

You might also like