Upload
lamhanh
View
227
Download
3
Embed Size (px)
Citation preview
1
Evolutionary Algorithms
2
Evolutionary Algorithms
Evolutionary algorithms are iterative and stochastic search
methods that mimic the natural biological evolution and/or
the social behavior of species
Such algorithms have been developed to arrive at near-
optimum solutions to large-scale optimization problems, for
which traditional mathematical techniques may fail
EAs operate on a set of individuals (population)
Each individual represents a potential solution to the
problem being solved
What is Evolutionary Algorithms (EAs)?
2
3
Evolutionary Algorithms
Initially, the population is randomly generated
Every individual in the population is assigned a measure of
its goodness with respect to the problem under
consideration (fitness function)
This value is the quantitative information the algorithm uses
to guide the search
Examples include: Genetic Algorithms, Memetic Algorithms,
Swarm Optimization, Ant Colony, …….
What is Evolutionary Algorithms (EAs)?
4
Evolutionary Algorithms
EAs share a common approach for their application to a
given problem
The problem first requires some representation to suit each
method. Then, the evolutionary search algorithm is applied
iteratively to arrive at a near-optimum solution
What is Evolutionary Algorithms (EAs)?
3
5
Evolutionary Algorithms
EAs apply the principle of survival of the fittest to produce
better and better approximations to a solution
EAs model natural processes, such as selection,
recombination, and mutation
What is Evolutionary Algorithms (EAs)?
Structure
of an EA
6
Evolutionary Algorithms
EAs search a population of points in parallel, not just a single point
EAs do not require derivative information or other auxiliary knowledge; only the objective function and corresponding fitness levels influence the directions of search
EAs use probabilistic transition rules, not deterministic ones
EAs are generally more straightforward to apply, because no restrictions for the definition of the objective function exist
EAs can provide a number of potential solutions to a given problem, the final choice is left to the user
Difference between EAs and other traditional search and optimization methods
4
7
Evolutionary Algorithms
EAs are blind, they need only an objective function and
decision variables. No derivatives are needed
EAs are random, all possible options are open
Regardless of their blindness and randomness, they use
guided search system
They can work with continuous, discrete, integer, and mixed
decision parameters
EAs can solve a wide class of real-life problems
Difference between EAs and other traditional search and optimization methods
8
Evolutionary Algorithms
Selection (Reproduction):
The selection mechanism simulates the survival of the fittest principle
Recombination
Recombination produces new individuals by combining the information contained in the parents
Mutation
Individual variables are then mutated with low probability
Reinsertion
After producing offspring they must be inserted into the population
Main Steps of EAs
5
9
Genetic Algorithms
6
11
Genetic Algorithms
The genetic algorithms (GAs) are the most extended group
of methods representing the application of evolutionary
Algorithms
A solution to a given problem is represented in the form of a
string, called “chromosome”, consisting of a set of elements,
called “genes”, that hold a set of values for the optimization
variables
The fitness of each chromosome is determined by evaluating
it against an objective function
12
Genetic Algorithms
The chromosome represents a feasible solution for the
problem under study
The length of the chromosome equals the number of
variables
Gene values can be either binary coding (0 or 1 values) or
real coding (actual values)
1 2 3 . . . . . . . . . . . . . . . . . N
Variable value
Number of variables
78 18 52 2 61. . . .97 36 30 44 3
Chromosomes
7
13
Genetic Algorithms
Any number can be represented in a binary code (0, 1 values)
For example: 230 represented in 0-1 format as follow:
11100110
11100110 = 1 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22
+ 1 x 21 + 0 x 20 = 128 + 64 + 32 + 4 + 2 = 230
The binary code could be created by dividing the given
number by 2 with the reminder either 0 or 1, then divide the
quotient by 2 with the reminder either 0 or 1 and so on
The reminders will represent the binary coding of the
number
Binary Versus Real Coding
14
Genetic Algorithms
Example
Determine the binary number that represents 230.
230/2 = 115 reminder = 0; 115/2 = 57 reminder = 1
57/2 = 28 reminder = 1; 28/2 = 14 reminder = 0
14/2 = 7 reminder = 0; 7/2 = 3 reminder = 1
3/2 = 1 reminder = 1; 1/2 = 0 reminder = 1
Then, the binary number is: 11100110
Binary Versus Real Coding
8
15
Genetic Algorithms
This example illustrates the binary coding for a set of
variables
Example
16
Genetic Algorithms
Create population at random
Calculate the fitness of each chromosome
Calculate the relative fitness of each chromosome
Apply the GA operators
Reproduction
Crossover
Mutation
Standard GAs Steps
9
17
Genetic Algorithms
Determine the maximum value for the function
y = -0.005 x2 + 1.5 x + 10
where 0 < x < 255
Example
18
Genetic Algorithms
Start with randomized population of solutions
Assume the population equals 10
Calculate the value of y for each chromosome (this
represents the objective functions we are looking for the
maximum y)
Then, calculate the relative fitness for each chromosome
Then apply the selection process (reproduction process)
using the roulette wheel
Example
10
19
Example
GAs: Ranking
20
GAs: Ranking
In this method each individual has a rank based on its
objective function values in relative to the sum of the
objective function values for the whole population
For example having 3 individuals with objective function
equal: 5, 10, 25
Then the relative fitness of the first is 5/40 = 0.125, the
second is 10/40 = 0.25, and the third is 25/40 = 0.625
Fitness Ranking: Proportional Ranking
11
21
As seen previously, individuals with higher objective function
values have a higher proportional fitness
Accordingly, proportional ranking may lead premature
convergence
This might happen when the population contains few
chromosomes have higher fitness values compared to the
reminder of the population
These chromosome will have a higher probability of selection
Fitness Ranking: Proportional Ranking
GAs: Ranking
22
To overcome the problem of proportional ranking, linear
ranking is used
Instead of using the relative fitness, chromosomes are
ranked according to their fitness
The worst chromosome will have a rank of one and the
second worst two
The best chromosome will have a rank N
Fitness Ranking: Linear Ranking
GAs: Ranking
12
23
Consider the following six chromosomes
Linear Ranking: Example
180 21
GAs: Ranking
24
Linear ranking allows for more divergence in the population
Fitness Ranking: Example
GAs: Ranking
13
25
Also called stochastic sampling
In this process, a random number is generate and the
individual whose segment spans the random number is
selected
The process is repeated with a number equals the total
number of the individuals (population)
Assume the following example
Roulette Wheel Selection
GAs: Selection
26
Assume six random numbers are: 0.81, 0.32, 0.96, 0.01, 0.65, 0.42
Roulette Wheel Selection: Example
0.00.020.030.060.070.090.110.130.150.160.18selection probability
0.00.20.40.60.81.01.21.41.61.82.0fitness value
1110987654321Number of individual
Selected individuals: 1, 2, 3, 5, 6, 9
GAs: Selection
14
27
In this process, fit individuals can be produced more
than one
Unfit individuals are expected to leave the pool
(population)
Number on population will always remain fixed
The roulette wheel selection provides no bias but does
not guarantee a minimum spread
Roulette Wheel Selection
GAs: Selection
28
This method provides n bias and allows for minimum
spread
The individuals are mapped to continuous segments of a
line, such that each individual's segment is equal in size
to its fitness exactly as in roulette-wheel selection
Equally spaced pointers (1/no of selection) are placed
over the line as the number of individuals to be selected
The first pointer is selected randomly between 0 and
1/no of selections
Stochastic Universal Selection
GAs: Selection
15
29
As the previous example, consider six individuals to be
selected
The distance between the pointers is 1/6 = 0.167
The first pointer is selected randomly between 0 and 0.167,
assume 0.1
Stochastic Universal Selection: Example
Selected individuals: 1, 2, 3, 4, 6, 8
GAs: Selection
30
Recombination performs an exchange of variable values
between the individuals
These individuals are called parents and the resulted
individual called offspring
Each individual has equal probability of being selected
The position at which the parent contributes its variable to
the offspring is chosen randomly
Recombination: Crossover
GAs: Recombination
16
31
Crossover (marriage) is a more common process
A crossover probability (Pc) is applied with the range
between 0.6 and 1
Pc provides probability that Pc * n chromosomes undergo
crossover operation
One or multiple points crossover may be selected
There are other examples of crossover such as: uniform
crossover and shuffle crossover
The two child (offspring chromosomes) replace their
parents so that the population size remain constant
Crossover
GAs: Recombination
32
For each chromosome, a random number r between (0, 1) is
generated. If r < Pc, then this string is selected for
crossover
For each couple of chromosomes, two random numbers are
generated between [1 and m-1], where m is the length of
the chromosome and the portions of the strings between
the two randomly selected locations are exchanged
Reproduction and crossover together give GA most of their
searching power
Crossover
GAs: Recombination
17
33
GAs: Recombination
Parent gene (B)
A2 B3 B4 B5 A6 AQ. . .A1
B2 B3 B4 B5 B6 BQ. . .B1
A2 A3 A4 A5 A6 AQ. . .A1Parent gene (A)
Generate random point (e.g., 3)
Single Point Crossover
B2 A3 A4 A5 A6 AQ. . .B1
Offspring (child) (A)
Offspring (child) (B)
34
GAs: Recombination
Parent gene (B)
A2 B3 B4 B5 A6 AQ. . .A1
B2 B3 B4 B5 B6 BQ. . .B1
A2 A3 A4 A5 A6 AQ. . .A1Parent gene (A)
Generate random range (e.g., 3 – 5)
Crossover range
Two Point Crossover
Offspring (child) (A)
Offspring (child) (B) B2 A3 A4 A5 B6 BQ. . .B1
18
35
As opposed to crossover, which resembles the main natural
method of reproduction , mutation is a rare process that
resembles the process of a sudden generation of an
offspring that turns to be a genius
The benefit of the mutation process is that it breaks any
stagnation in the evolutionary process, avoiding local
minimums
If one important information is missing, crossover will not
be able to alleviate, mutation may introduce this missed
information
Mutation
GAs: Mutation
36
Mutation, as it does in nature, takes place very rarely, on
the order of once in a thousand bit string locations
Mutation probability (Pm) is usually chosen less than 0.05
bit/generation
The mutation probability (Pm) gives the expected number
of mutated bits as Pm x number of genes x number of
chromosomes
A random number " r " between [0, 1] is generated, if r is
smaller than Pm then mutate the bit, otherwise, go to
another bit
Mutation
GAs: Mutation
19
37
BAsicGA FlowChart
GAs: Mutation
Yes
- Select two individuals
- Perform crossover
Insert two offspring chromosomes into
new population
Insert mutated chromosome into new population
Copy into new population
Genetic operations
Evaluate fitness
Generate initial random population
End
Start
Termination Criterion satisfied?
Yes
No
i = 0
i = MGen = Gen +1
No
Crossover
- Select one individual
- Perform reproduction
- Select one individual
- Perform mutation
i = i+ 1
MutationReproduction
38
It is needed to determine the cross sectional area of the 10
members so as to minimize the cost of the truss to support
the load, stress and strain constraints must be satisfied
10-memebr Truss Problem
GAs: Example
20
39
A binary representation of the cross sectional area is used of
4-bits element (0 0 0 0)
For example (0 1 1 1) a 7-inch cross section
Chromosome structure
10-memebr Truss Problem
GAs: Example
Compute the weight of the truss and determine the cost
Stresses are computed using appropriate methods of
structural analysis
40
Penalize violations of stress constraints
For example, increase the cost of that solution in order to
decrease its fitness
The smaller the total cost is the better
Set population size
Number of generations
Crossover probability
Mutation probability
Termination criteria
10-memebr Truss Problem
GAs: Example
21
41
In the steady-state approach only one chromosome is
replaced at a time, rather than an entire "generation" being
replaced
The reproduction process takes place by either crossover or
mutation
In crossover two members of the population are chosen
randomly in such a way that its probability of being selected
is proportional to its relative merit to produce a single child
This ensures that best chromosomes have higher likelihood
of being selected
Steady State GAs
42
Also, the mutation process can be done by randomly
selecting one chromosome from the population and then
arbitrarily changing some of its information
Once an offspring is generated by either method, it is
evaluated in turn and can be retained only if its fitness is
higher than that of others in the population
Throughout the process, the entire population soon improves
since more fit offspring chromosomes replace unfit parents
In this case, the number of generations equals the number of
individual trials divided by the size of the population
Steady State GAs
22
43
Steady State GA
Steady State GAs
Yes
Evaluate relative merits and determine the worst population chromosome
Determine if crossover or mutation applies and generate an offspring
Determine the fitness of the offspring chromosome
Is offspring better than the worst
chromosome in the population?
Replace the worst chromosome
Discard the offspring
No Yes
Last offspring?
Last offspring?
Yes
- Generate one chromosome at random.
- Calculate its objective function.
No
End End
Start
All Population generated?
No
YesNo
44
A square construction site is divided into 9 grid units
We need to use GAs to determine the best location of two
temporary facilities A and B, so that:
Facility A is as close as possible to facility B
Facility A is as close as possible to the fixed facility F
Facility B is as far as possible to the fixed facility F
Let’s consider the closeness weights (W) as follows:
WAB = 100 (positive means A & B close to each other)
WAF = 100 (A & F close to each other)
WBF = -100 (negative means B & F far from each other)
Steady State GAs: Example
23
45
Steady State GAs: ExampleStep 1: Problem Representation
First of all, determine the way how the problem will be
represented
46
Steady State GAs: ExampleStep 2: Chromosome Structure
The variables are the locations of the facilities A and B
The chromosome structure of each option presented in step 1
is presented
Note that the chromosome length equal the number of
variables
24
47
Steady State GAs: ExampleStep 3: Generate Population
50 to 100 is reasonable number for diversity and processing
time
Let’s consider option 1 and population of 3
48
Steady State GAs: ExampleStep 4: Evaluate the Population
Objective function, minimize site score = Σwi di
WAB = 100, WAF = 100, and WBF = -100
Distance between facilities are represented as the number of
horizontal and vertical blocks between them
25
49
Steady State GAs: ExampleStep 5: Calculate the Merits of Population Members
Notice that smaller score gives higher merit because we are
interested in minimization. In case of maximization, we use
the inverse of the merit calculation.
50
Steady State GAs: ExampleStep 6: Calculate the Relative Merits of Population
Members
Step 7: Select Crossover and Mutation OperatorsCrossover rate = 96% (marriage is the main avenue for evolution) Mutation rate = 4% (genius people are very rare) To select which operator to use in current cycle, we generate a random number (from 0 to 100). If the value is between 0 to 96, then crossover, otherwise, mutation.
26
51
Steady State GAs: ExampleStep 8: Use the Selected Operator (assume crossover)
Randomly select two parents according to their relative merits of Step 6Assume two random numbers of 76 and 39Then P3 and P2 is picked Then, apply crossover to generate offspring
52
Steady State GAs: ExampleStep 9: Evaluate the Offspring
Notice that Offspring 2 is invalid because both facilities A & B
are at same coordinates (x = 2 and Y = 3) and this is not
allowed
27
53
Steady State GAs: ExampleStep 9: Evolve the Population
Compare the offspring with population
Since the offspring score = 200 is better than the worst member (P1 has a score of 600), then the offspring survives and P1 dies (will be replaced by the offspring)
Continue, GOTO STEP 4 , repeating the process thousands of times until the best solution is determined One of the top solutions