SlideShare a Scribd company logo
Assignment on Solving Non-Linear
Programming Minimization Problem
Using Genetic Algorithm
NAME : Dilshan K.M.G.L.
INDEX NO. : 150131A
GROUP : Aeronautical I
DATE OF PER. : 2017.09.29
DATE OF SUB. : 2017.10.27
GROUP MEMBERS:
Abenayake D.H.S.
Amarathunga H.D.V.
Annasiwatta D.M.
Dilanjaya H.W.S.
Abstract
This report is an analysis of genetic algorithms and their applications. The concept of genetic
algorithms and the evolution are being used to generate solutions in cyclic operations.
We use genetic algorithm principles and functions and produce results step by step logically to find
solutions to a given equation such that it satisfies given conditions.
Introduction
Genetic Algorithms (GAs) are based on the evolutionary ideas of natural selection and genetics. The
basic techniques of the GAs are designed to simulate processes in natural systems necessary for
evolution. The difference is that all individuals try to satisfy the same task and actually this is by
means far simpler than actual evolution. GAs presumes that potential solution for any problem is an
individual and can be represented by a set of parameters. These parameters are regarded as genes and
can be represented by string values of binary form. Throughout a genetic evolution the result of the
fitness function determines the quality of the solution. In genetic operation after each cycle of
operation a subsequent generation is created from the current population. It is expected that from this
process of evolution a better subsequent generation is created.
How to solve a genetic algorithm
There is a conventional procedure which should be followed in order to solve a problem using genetic
algorithms.
Phenotype decoding
Genotype population initialization
Evaluation of the initial population
Parents selection
Crossover
Mutation
Evaluation of the off spring
Next generation selection
Condition
Stop
Start
• Genotype − Genotype is the population in the computation space. In the computation space, the
solutions are represented in a way which can be easily understood and manipulated using a
computing system.
• Phenotype − Phenotype is the population in the actual real world solution space in which
solutions are represented in a way they are represented in real world situations.
1. Genotype population initialization - genotype string is randomly generated for each
individual of the generation
2. Phenotype decoding – for each individual the value regarding the actual scenario is
generated for further operations.
3. Evaluation of the initial population – decoded phenotypes are used and the validity of
the constraints are checked. Then depending on the satisfaction of constraints a penalty
is added to the generated Z value and hence the fitness values are generated. By the
obtained final value the initial population is evaluated.
4. Parents selection – once the initial population is evaluated then 3 of the elements are
randomly taken and the best out of the 3 are selected. Likewise we choose another
random 3 elements and the best element is chosen. Then the chosen elements are taken
as parents.
Crossover
3 chromosomes are selected out of all individuals. And then 1 individual is selected which
has the highest fitness value out of these 3 chromosomes. This selected individual is named as a
parent. The same procedure is followed to select another parent. After that these 2 parents are
paired. And these 2 parents are ready to be crossed. Amount of cross over points are defined.
Here in this example 1 cross over point is taken to demonstrate. Crossover rate is defined. A
random probability is generated by the interpreter and if the random probability is less than the
cross over rate two parents will be crossed, and 2 children will be generated which are known as
offspring. This crossover rate should be relatively lower as the 2 children should have higher
percentage of their parent’s characteristics.
x = random value generated by the program between 1 & 100
if x < crossover rate then;
Two parents are crossed.
else;
Two parents are not crossed.
Children = Parents.
1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0
1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0
Parent 1
Parent 2
Offspring 1
Offspring 2
Mutation
Probability that a bit subjects to mutation is known as the mutation rate. Offspring,
which are generated in the previous step (crossover step) are subjected into the mutation step.
This step is followed for every single bit respectively. A mutation rate is defined between 1 and
56. Random values are generated for every single bit separately. An example is for the 1st bit is
as follows.
x = mutation rate
A random value is generated by the program.
if random value <= x then;
Bit is mutated.
0 1
else;
Bit is not mutated.
0 0
Evaluation of the offspring
The offspring which is generated by the previous step is divided into 8-bit sections to
observe phenotypes. If the phenotype does not satisfy the given constraint a penalty value is
added to the given phenotype. The penalty value is given depending on how the phenotype
satisfies the given constraint. If the variation is high, penalty value which is given for the
phenotype is high. Fitness function depends on the values of penalties and the function is defined
according to the problem to be solved. And it is defined to compare the suitability of the
phenotype (to select the most suitable phenotype).
Next generation selection
Next generation is created by the offspring which are generated by the crossover step and
other parents which are randomly selected at the first. All these offspring and parents are called
as the next generation.
0 1 0 1 1 0 0 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 0 1
1
PROBLEM STATEMENT
Problem
Problem3: Minimize 𝑧 = 𝑧1 + 𝑧2 where
𝑧1 = (𝑥1 − 10)2
+ 5(𝑥2 − 12)2
+ 𝑥3
4
+ 3(𝑥4 − 11)2
𝑧2 = 10𝑥5
6
+ 7𝑥6
2
+ 𝑥7
4
− 4𝑥6 𝑥7 − 10𝑥6 − 8𝑥7
Subject to,
127 − 2𝑥1
2
− 3𝑥2
4
− 𝑥3 − 4𝑥4
2
− 5𝑥5 ≥ 0
282 − 7𝑥1 − 3𝑥2 − 10𝑥4
2
− 𝑥4 + 𝑥5 ≥ 0
196 − 23𝑥1 − 𝑥2
2
− 6𝑥6
2
+ 8𝑥7 ≥ 0
−4𝑥1
2
− 𝑥2
2
+ 3𝑥1 𝑥2 − 2𝑥3
2
− 5𝑥6 + 11𝑥7 ≥ 0
• Number of individuals per generation = 60
• Number of bits per variables = 8
• Code length = 56
• Genotype to phenotype conversion = −10 + 20 ×
𝑥 𝑔
28−1
• Range of phenotype variables = −10 ≤ 𝑥𝑖 ≤ 10
• Parent selection method = Take 3 randomly selected parents from the
initial generation and take the best one from each.
• Crossover method = One point crossover with a random generated
crossover point
• Crossover method = One point crossover with a random generated
crossover point
• Crossover rate = Selected value from range 0 - 99
• Mutation = Selected value from range 1-56 (we were given
1/56 as the default mutation rate)
• Next generation selection method = 52 individuals were created using the crossover,
mutation process
• Then 8 individuals with the highest fitness value in the initial generation were added to that 52,
hence 60 individuals creating a second generation.
• Fitness function = 𝑇𝑜𝑡𝑎𝑙 𝑝𝑒𝑛𝑎𝑙𝑡𝑦 − 𝑧
•
• Total penalty = - (Constraint1 + Constraint2 + Constraint3 +
Constraint4) {constraint was added to the penalty, only if it was violated.}
• Stopping condition = 2000 iterations
• Expected change of genetic parameter that is going to be compared
= mutation rate
Programming concept
The concepts used to produce results can be explained as shown below.
I. Importing libraries to enable certain operations.
II. Genotype population initialization
Concept:
By the use of the random library, a random number between 0-255 is generated. Then this value is
stored in a list for further operations to create binary values. The reason for choosing 255 is the reason
is to have 8 bits for a randomly generated number. If the no of bits are increased then the accuracy
would have improved.
3. Phenotype decoding
Concept:
As stated in the problem we need the genotypes to be converted in to phenotypes to be in the range of -
10 to +10. We need to map the genotype range (0-255) linearly to the phenotype range. For that we use
the equation 𝑥 𝑝 = −10 + (10 − (−10))𝑥 𝑔/(28
− 1)
4. Evaluation of the initial population
Concept:
Phenotypes are substituted in the constraints and the problem equation. Then fitness values were
obtained according to the random values generated.
5. Parents selection and selecting the best pair parents.
Concept:
Out of the 60 randomly generated values 2 groups of 3 parents are picked randomly and the best out of
each group is paired with the other. Then again all the 6 parents are put back to the same list making
the probability of being selected the same throughout. 26 couples are formed. And sent to the next
generation.
6. Selecting best 8 parents
Concept:
Once the fitness values are generated then we rank them in order and select the best 8 parents. The top
8 minus values which are closer to zero were selected. Then these 8 parents were directly sent to the
next generation.
7. Crossover and mutation
Concept:
The selected 26 couples are then used to make children. Initially the user is asked to give a crossover
number. Then that value is compared with a randomly generated number which lies between (0-99). If
the randomly generated value is less than the given value by the user, then the crossover happens
between the couple and two children are produced.
Likewise, 52 offspring are generated. Mutation rate can be defined between 1-56. There are 7, 8-digit
numbers in each single offspring. This contain 56 digits. Each digit is followed through mutation process
respectively. A random value between 1 and 56 is generated for each single bit. If the random value is
less than the mutation rate bit should be mutate. Which means bit is flipped.
8. Evaluation of offspring
Concept:
As mentioned above the 52 children whom were taken after crossover and mutation with the best 8
parents and this process is called the evaluation of the offspring.
Logical error checking
• Geno to pheno conversion
After initial population is generated, the values are tabulated under these headings. This table is
part of total values
Genotype
Code x1 x2 x3 x4 x5 x6 x7
1 44 246 7 133 79 174 188
2 56 222 153 164 237 37 60
3 206 213 218 43 124 239 119
4 90 110 193 24 70 177 170
5 62 80 154 117 23 113 183
6 254 239 173 253 67 108 236
Then we have compared the pheno types that are generated through code and manually. Those
value are tabulated tables given below.
We can see that these values are same. So that code has no arithmetic errors in the conversion
of the
• Binary and decimal conversion
In another step we have to make sure that, the coding function that has use to convert
phenotype into binary values has no error. To ensure that we have done excel calculation and
compare these values. Part of the tables are shown below.
Decimal
Genotype x1 x2 x3 x4 x5 x6 x7
1 44 246 7 133 79 174 188
2 56 222 153 164 237 37 60
3 206 213 218 43 124 239 119
4 90 110 193 24 70 177 170
5 62 80 154 117 23 113 183
6 254 239 173 253 67 108 236
Decimal values that use to generate binary values
Binary (Code)
x1 x2 x3 x4 x5 x6 x7
00101100 11110110 00000111 10000101 01001111 10101110 10111100
00111000 11011110 10011001 10100100 11101101 00100101 00111100
11001110 11010101 11011010 00101011 01111100 11101111 01110111
01011010 01101110 11000001 00011000 01000110 10110001 10101010
00111110 01010000 10011010 01110101 00010111 01110001 10110111
11111110 11101111 10101101 11111101 01000011 01101100 11101100
Binary values that generated using computer program
Binary (Manual)
x1 x2 x3 x4 x5 x6 x7
00101100 11110110 00000111 10000101 01001111 10101110 10111100
00111000 11011110 10011001 10100100 11101101 00100101 00111100
11001110 11010101 11011010 00101011 01111100 11101111 01110111
01011010 01101110 11000001 00011000 01000110 10110001 10101010
00111110 01010000 10011010 01110101 00010111 01110001 10110111
11111110 11101111 10101101 11111101 01000011 01101100 11101100
Binary values that generated using excel sheet
Both values that comes under these two different tables are same. So that we can say that these
values have no error.
• Crossover checking
Another point that will cause to generate errors is crossover and mutation. We have designed
and proved using tabular method as given in the tables bellow, there are no logical or
arithmetic calculation errors in the code.
Here we have selected best fitted parent out of randomly selected 3 parents. Those values are
choose using random numbers. And then crossover them by deciding the crossover rate, that is
also a random number and that value is checked with the given crossover rate. If the condition
satisfies, these values are crossed over at a point that also randomly generated by the code.
By considering these results we can conclude that our computer program that use to solve the problem
has no any arithmetic and logical errors.
There are several ways to solve problems in the genetic algorithm. Mostly in this method, the desired
values must gain without considering the initial values that the code is generated under the conditions
that we are given. This entire procedure is done in random manner but the program itself find the best
fitted solution. That’s the beauty of genetic algorithms.
Best Parent 1
x1 x2 x3 x4 x5 x6 x7
1 74 213 216 14 155 0 56
2 151 213 154 50 122 11 195
3 44 246 7 133 79 174 188
4 161 45 173 19 104 93 117
5 206 213 218 43 124 239 119
6 5 106 0 70 98 148 205
Parent selections 1
Best parent 2
x1 x2 x3 x4 x5 x6 x7
1 44 246 7 133 79 174 188
2 64 102 192 168 200 36 239
3 51 201 26 214 213 197 22
4 92 62 25 84 80 172 114
5 163 192 67 150 88 64 79
6 192 101 69 104 131 44 118
Parent selection 2
Random Generated No Crossover Point
7 2
93 0
41 6
64 4
23 1
81 3
Crossover points
Phenotype
Codex1x2x3x4x5x6x7z1z2z1234Fitness
1-6.549029.294118-9.450980.431373-3.803923.6470594.7450988623.81330752.739376.52-22315.9-597.485218.4014-585.223-62875.1
2-5.607847.41176522.8627458.588235-7.09804-5.29412563.50940136804014244-9066.94264.7451-74.5998-336.163-4023722
36.1568636.7058827.098039-6.62745-0.274518.745098-0.666673625.451476.74164102.193-6196.83-278.684-454.77-224.558-11257
4-2.94118-1.372555.137255-8.11765-4.50983.8823533.3333332854.55884240.7687095.31-147.12146.39985197.9938-59.9031-87302.3
5-5.13725-3.725492.078431-0.82353-8.19608-1.137254.3529411903.64130317183033622-467.497278.5659327.341-17.0996-3034107
69.9215698.7450983.5686279.843137-4.7451-1.529418.509804219.1759119408.6119627.8-17983.344.37447-54.629-134.147-137800
Constraints/Penalties
Codegeneratedphenotypevalues
Phenotype
Manualx1x2x3x4x5x6x7z1z2z1234Fitness
1-6.549029.294118-9.450980.431373-3.803923.6470594.7450988623.81330752.739376.52-22315.889-597.48481218.4013841-585.22261-62875.1
2-5.6078437.41176522.8627458.588235-7.09804-5.29412563.50940136804014244-9066.9357264.745098-74.59976932-336.16301-4023722
36.15686276.7058827.098039-6.62745-0.274518.745098-0.666673625.451476.74164102.193-6196.8264-278.68435-454.7704729-224.55825-11257
4-2.941176-1.372555.137255-8.11765-4.50983.8823533.3333332854.55884240.7687095.31-147.1211846.3998462197.9938485-59.903114-87302.3
5-5.137255-3.725492.078431-0.82353-8.19608-1.137254.3529411903.64130317183033622-467.49662278.565936327.3410227-17.099577-3034107
69.92156868.7450983.5686279.843137-4.7451-1.529418.509804219.1759119408.6119627.8-17983.34344.3744714-54.62898885-134.14687-137800
Constraints/Penalties
Manuallycalculatedphenotypevalues
AfterCrossover(Offspring1)Offspring(Offspring2)
x1x2x3x4x5x6x7x1x2x3x4x5x6x7
17421371337917418814424621614155056
2151213154501221119526410219216820036239
3442467133791742235120126214213197188
416145173198017211449262258410493117
520619267150886479516321321843124239119
651060104131441186192101697098148205
Manuallycalculatedmutations
The main idea of the population is come from simply as subset of solution space. Also, we can say that
chromosomes. In a population there must be diversity, in initial condition. But after some iterations all
the population will have same value, but it is not a compulsory condition. And also, when we select
large number of population for the calculation, that will cause to slow down the converging process.
And on the other hand, when we select small number of individuals as population, the diversity of the
population is not keep. Other than that, it will not produce good mating pool for generate new
population.
Genotype population initialization
According to the problem that we have to solve using GA, we have to pay our attention to 7 variables
and 4 constraints. First of all, we have to get initial phenotype from the code. Instead of randomly
select genotype, we can manually enter genotypes (heuristic initialization). These are two different
methods. We cannot say directly what is the most efficient way among these two. To get clear picture
of the efficiency of the method, we have to run the code under both of these methods and get series of
solutions. That may pave the way to get somewhat clear understanding about the efficiency of each
method.
And also, there are some ways for population models called steady state model and generational
model. In steady state model, generate 2 off springs in each iteration and those off-springs replace one
or two individuals from the population. So that the population is constant and the change is continuous.
In generational method we generate some offspring equal to the new population number. That method
is used during the iterations. Basically, we can use combination of both those methods to generate new
population.
Phenotype decoding – mapping genotype to phenotype
When we consider about the phenotype decoding, that means we are going to map the values that
generated by the code itself. The aim is to set the variable values that suitable for the range that we are
trying get. The range is different from problem to problem, because of the type and conditions of the
problem.
We can select different mapping functions according to the problem. We can use linear mapping
functions, polynomial mapping functions, logarithmic mapping functions, exponential mapping
functions etc. When we are considering about the bias, we have to avoid linear mapping function. In
linear mapping function there is no special conditions that avoid biasing to highest values or lowest
values.
When we consider about the biasing there will be some values that generated are biased to highest
values of the inequality. On the other hand, these values can be gathered into lower value. In some
researchers we have seen that these types of values will get higher time to converge into the desired
value. And also, these values will get lower fitness with compared to the non-biased mapping values.
When we think about the mapping values that not much close to the higher merging as well as lower
merging. Then we have to define definitely nonlinear function to get the values. We can use parabolic
shape function when we have to avoid biasing to the lowest possible values. When we use hyperbolic
function that mapping function will have completely different. So that we have to select best fitting
mapping function.
In same problem there will be several mapping functions. In most problems, there is a range for each
parameter in a problem. Otherwise we have to introduce a range of possible values that the parameter
can get. In multi variable problem, we can introduce unique mapping function for each variable in
order to avoid some undesirable values or to reduce the probability to generate such values. In GA
basically use randomness. So that we have to reduce the probability that these biased values or
undesirable values are generated.
Evaluation of initial population
In initial generation there are no crossover or mutation. That is purely based on the values that the code
is generated and the mapping function we are used. After generating initial population, we have to get
the idea of the fitness value of each individual have. So that we are going to define fitness function.
This fitness function is a representation of a deviation from the most optimized value and the value
generated from the code.
Fitness function is the most crucial function that used in GA. We say that because the optimum value
that we can get from the code is based on out fitness function. To calculate the fitness there are some
methods.
Basically, programmer has to decide the function that he is going to use to optimize the solutions. To
get the variation from the actual value we introduce penalty value if the variables are violated the
constraints. These penalty values decide the eligibility of the variable. As an instance, when we think
about problem that has four constraints, we can introduce 4 penalty values, one for each. And in simple
way to optimize the fitness, the sum of the penalty values can be adding or subtract from the final
optimized value. That will help to select the next generation process to decide the fitness of each
individual.
Some of the cases the fitness function can be used as the objective function. but when we consider
about the nonlinear more complex problems cannot use the objective function as same as this.
Basically, fitness function should have fast computing method. Because slow computation of the
fitness value can be affect to slow the converting process.
Parent selection methods
After generating and evaluating initial population we have to mate selected parents to generate new
population. There are several ways of selecting parents, and we have to choose one of them for our
analysis. As we can see that parent selection method is very crucial because that will affect directly for
the fitter solution and time to converge. And also, these parent selection methods don’t use only “best”
fittest parents for the next solution. Main reason is we cannot neglect all low fitted phenotypes without
selecting them for the mutation or crossover. That will cause for reduce diversity of the population.
There will be good genes, proper genes in worst individuals and sometimes these best genes will
immerge through crossover and mutation in another population. So that maintaining good diversity in
the population in extremely crucial for the success of a GA. After sometimes population is converged
to some premature convergence and is an undesirable condition in a GA. That will be the optimum
solution.
Basically, the aim of parent selection is to select two individuals from the existing pool of individuals
and use to mate and recombine to create off-springs to next generation.
Most popular method is select parents according to the fitness value of them. According to that method
each individual has a probability values to select for the next generation. So that fitter solutions have
higher chances to participate for the mating purpose. There are several selection methods. Roulette
wheel selection method, Stochastic universal Sampling method, tournament selection method, rank
selection method, random selection method.
In roulette wheel selection method, the fitness value of the individuals is represented by the area of a
circle. Higher the fines value, higher they are represented in the circle, higher chance to select to next
generation. These values are generated by dividing the value of fitness, total sum of fitness.
In stochastic universal sampling, both parents that use to crossover are selected at the same time.
Simply these values are at the opposite side of the circle. There will be a problem with the fitness
proportionate methods will not work when the fitness values get negative.
When we consider about the tournament selection method, basically randomly selected parents are
shifted to mating process and produce children. In literature this will work even for negative fitness
values. Here select 2 or more chromosomes from the pool and among them select best chromosome. In
the second stage, repeat the process and get another chromosome until select best fit one. This method
usually uses when there are higher number of individuals in a population.
Stochastic universal sampling
Roulette wheel selection method
Then about the rank selection method, each individual has equal possibility to select for mating
processes. This method is used when population has very close fitness values.
Another thing is random selection method. It has no pressure on each individual to select as parent. So
that the strategy is usually avoided.
In our situation we select a parent within randomly selected 3. That parent has highest value among
them. By repeating that again select another one and both two send for crossover and mutation. We
can improve the selection method by getting higher number of parents and select one from them. But
when we increase the number of parents select from the population there will be a chance that same
value repeats in many of the selection points.
Another method is divide the population into equal amount of parts. Then generate children from
them. After those parents and children, select number of individuals equals to the individual count in
selected part of the population. Then remove the selected parents from the population. After that repeat
the same process. This method will cause to reduce time for the convergence to the answer. And also,
it will give best answer from that.
Tournament selection method
Random selection method
Crossover
Here the crossover is relevantly represented the biological crossover. Here in the binary string
crossover, we can select one or more points to do the crossover. In genetic algorithms, the crossover
rate is high, and it will cause to increase the diversity in the population. And also, it paves the way to
immerge the hidden strong genes to make fitter values. In basically there is a crossover rate defined in
the code.
The crossover rate must be high value. There are several ways to do crossover. One-point crossover,
two-point crossover, uniform crossover. One-point cross over it happens by one point and then the
separated parts are combined together to generate 2 children. In two-point crossover, one binary spring
is separated into three parts and then combined them together.
In uniform crossover, the binary string is not divided into segments. Here generate random possible
value and according to that value crossover each bit.
One-point crossover
Two-point crossover
Uniform crossover
Mutation
Generally, mutation is represented as a small random tweak in the chromosome, to get a new solution.
That will cause for the diversity of the population. Here it will use for the convergence of the GA
problem. And also, there are several mutation ways to do operations. As the cross over there is defined
a mutation rate, but that is smaller in value than the crossover rate. When the mutation rate is increased
the values will corrupted. And other thing is if the mutation rate is increased then sometimes it will
cause to reduce the time for convergence.
First bit flip mutation, that is used when one or more binary value is flip.
Bit flip mutation
Random resetting is another type. Here set of permissible values is assigned to a randomly chosen
gene.
In swap mutation, selected two positions of a binary sting is randomly interchanged. That is common
in permutation based ending.
Scramble Mutation
The values if a chromosome is shuffled randomly within the selected region.
Inversion Mutation
Here without shuffling as in the scramble mutation the entire substring is reversed.
There are some application areas that GA is used. Basically, in optimization, economic, neural
networks are used. In optimization, usually use in minimizing and maximizing objective function
optimization. As names parallelization, image processing is used GA functions.
Swap Mutation
Scramble Mutation
Inversion Mutation
Results and graph
We can plot 2 different graphs using the results that generated using the computer program. One graph
is best fitted value vs. number of iterations.
We can see that with few number of iterations the value is converged to some value, that we can take
this as optimal solution of our program. By converging the value into some value with less time
means, we can guess that program itself select best fitted value quickly.
With low time consuming, we can say program searched large area of the solution space and get the
optimum value from that. We are using desirable number of iterations, not much large and not too low.
By executing large number of trials, we can get the average optimum value. Other than that, we cannot
conclude, this value is the most optimized value in the solution space that satisfy all constraints.
Another graph can be plotted using average fitness value vs. number of iterations.
-1600
-1500
-1400
-1300
-1200
-1100
-1000
-900
-800
-700
-600
0 2000 4000 6000 8000 10000 12000
Bestfitnessvalue
Number of iterations
Best fitness vs Iteration
-1600000
-1400000
-1200000
-1000000
-800000
-600000
-400000
-200000
0
0 2000 4000 6000 8000 10000 12000
Axisaveragefitnessvalue
Number of iterations
Avg fitness vs Iteration
Here average value of the iterations is spread in large range, and also, we cannot get some exact range
that the average value will gather. In some cases, we can say that this will happen because of the
biased situations. When some populations fitness values are lower and also in some other cases most
of the individuals have high fitness value cause to generate lower and higher average fitness value.
Biased will cause errors sometimes because these highest or lowest points will near to the local
optimizing points. So that values will gather towards them and if the number of iterations are low, we
cannot get optimal solution from them.
In other words, to avoid such vast variation of the average fitness, we have to change the fitness
functions. Another thing is with the variation of the average fitness, sometimes will paves the way
towards the optimal solution by releasing some local optimal points.
In our analysis we are going to change the mutation rate and generate the best fitness and average
fitness values. When we consider about the variation of highest fitness values with the change of
mutation rate, that will produce a graph like as follows.
For the plot like this we have to consider about many number of iterations per one mutation rate. Then
we can get the average value of the mutation rate. Other than that, without implementing higher
number of iterations we cannot get the best fitted values. The values that based for the graph are
included in Excel sheet.
In the previous graph was plotted using single round per single mutation rate. So that these values may
change with the increment of the executing rounds. But we can get a rough idea about the change of
the highest values.
We can see that the path of the graph is increased and then gradually decreasing, after mutation rate is
about 5. We can say, with the increment of the mutation rate, the corruption of the values of the graph
will occur. So that there will be huge deviation from the optimum result.
With the conclusion, we can say that with the increment of the mutation rate, there will be deviation
from the actual value.
-820
-800
-780
-760
-740
-720
-700
-680
-660
0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40
Highestfittedvalue
Mutaition rate
Mutation rate vs highest fitted value
There are several other ways to optimize the solution of our program. As mentioned above we can
change the crossover rate and find the variation of the highest fitness value without changing any other
parameters.
In this graph we cannot get proper visible deviation with the increment of the crossover rate. Suppose
that the sample we are used to plot the graph is much smaller and that will cause for the graphical
representation. So, using that graph we cannot explain the behaviour (Genetic algorithms tutorial, n.d.)
(Chapter 2 - genetic algorithms, 2017) of the crossover rate and the highest fitness function.
Another thing is we have changed the parent selection methods and try to optimize the code. But each
method is converged in to same values, without giving any deviation from them.
When we generate the z value from various executions, there will be some deviation of the value.
These values are tabulated as follows.
635
640
645
650
655
660
665
0 2 4 6 8 10 12
maximumzvalue
execution number
maximum z values
-694
-692
-690
-688
-686
-684
-682
-680
-678
0 10 20 30 40 50 60 70 80 90 100
highestfitnessvalue
crossover rate
Crossover rate vs highest fitness value
References
Chapter 2 - genetic algorithms. (2017). In Kramer. Springer.
Genetic algorithms tutorial. (n.d.).
Results and work conducted
Index No Name Work
150023U H.D.V Amarathunga Coding
150131A K.M.G.L Dilshan Manual checking
150127R H.W.S Dilanjaya Manual checking
150031R D.M Annasiwatta Report Editing
150008E D.H.S Abenayake Report Editing

More Related Content

What's hot (20)

PDF
Existence, Uniqueness and Stability Solution of Differential Equations with B...
iosrjce
 
PPT
Calculus of variations
sauravpatkotwar
 
PPTX
Numerical analysis ppt
MalathiNagarajan20
 
PPTX
Fuzzy logic - Approximate reasoning
Dr. C.V. Suresh Babu
 
PPTX
introduction to differential equations
Emdadul Haque Milon
 
PPT
Eigen values and eigenvectors
Amit Singh
 
PPTX
Differential Equations
KrupaSuthar3
 
PDF
Csc446: Pattern Recognition
Mostafa G. M. Mostafa
 
PPTX
Practical Swarm Optimization (PSO)
khashayar Danesh Narooei
 
PPTX
Echelon and reduced echelon form & Filters
Zahid Ali
 
PDF
Gamma and betta function harsh shah
C.G.P.I.T
 
PPT
Application of derivatives 2 maxima and minima
sudersana viswanathan
 
ODP
Analysis sequences and bounded sequences
SANDEEP VISHANG DAGAR
 
DOC
Gamma & Beta functions
Selvaraj John
 
PPTX
Perceptron & Neural Networks
NAGUR SHAREEF SHAIK
 
PPT
Divergence theorem
FFMdeMul
 
PPT
electromagnetic wave equation
PanbarasiSivamayam
 
PPT
Vector calculus
raghu ram
 
DOC
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
naveen kumar
 
PPTX
Tensor analysis
University of Education
 
Existence, Uniqueness and Stability Solution of Differential Equations with B...
iosrjce
 
Calculus of variations
sauravpatkotwar
 
Numerical analysis ppt
MalathiNagarajan20
 
Fuzzy logic - Approximate reasoning
Dr. C.V. Suresh Babu
 
introduction to differential equations
Emdadul Haque Milon
 
Eigen values and eigenvectors
Amit Singh
 
Differential Equations
KrupaSuthar3
 
Csc446: Pattern Recognition
Mostafa G. M. Mostafa
 
Practical Swarm Optimization (PSO)
khashayar Danesh Narooei
 
Echelon and reduced echelon form & Filters
Zahid Ali
 
Gamma and betta function harsh shah
C.G.P.I.T
 
Application of derivatives 2 maxima and minima
sudersana viswanathan
 
Analysis sequences and bounded sequences
SANDEEP VISHANG DAGAR
 
Gamma & Beta functions
Selvaraj John
 
Perceptron & Neural Networks
NAGUR SHAREEF SHAIK
 
Divergence theorem
FFMdeMul
 
electromagnetic wave equation
PanbarasiSivamayam
 
Vector calculus
raghu ram
 
NUMERICAL METHODS MULTIPLE CHOICE QUESTIONS
naveen kumar
 
Tensor analysis
University of Education
 

Similar to Solving non linear programming minimization problem using genetic algorithm (20)

PPTX
Genetic Algorithm
Fatemeh Karimi
 
PPTX
Introduction to Genetic algorithm
HEENA GUPTA
 
PPT
0101.genetic algorithm
Ahmad Almubarrok
 
PPT
Genetic algorithm
DurgeshPratapSIngh8
 
PPTX
GA.pptx
ShujatHussainGadi
 
PPT
Genetic algorithms
guest9938738
 
PPT
Evolutionary algorithms
M S Prasad
 
PDF
Genetic Algorithms in Artificial Intelligence
ritwijkp2
 
PPTX
Genetic Algorithm
Jagadish Mohanty
 
PPT
Ga
venki249
 
PPT
Genetic algorithms
zamakhan
 
PPT
GeneticAlgorithm
guestfbf1e1
 
PPTX
Analysis of Parameter using Fuzzy Genetic Algorithm in E-learning System
Harshal Jain
 
PPT
Genetic algorithm
garima931
 
PPT
AI_PPT_Genetic-Algorithms.ppt
HotTea
 
PPT
Genetic-Algorithms forv artificial .ppt
neelamsanjeevkumar
 
PPT
Genetic-Algorithms.ppt
ssuser2e437f
 
PPT
Genetic-Algorithms.ppt
Nipun85
 
PPT
Genetic-Algorithms for machine learning and ai.ppt
neelamsanjeevkumar
 
PPT
Genetic-Algorithms-computersciencepptnew.ppt
Fitnessfreaksfam
 
Genetic Algorithm
Fatemeh Karimi
 
Introduction to Genetic algorithm
HEENA GUPTA
 
0101.genetic algorithm
Ahmad Almubarrok
 
Genetic algorithm
DurgeshPratapSIngh8
 
Genetic algorithms
guest9938738
 
Evolutionary algorithms
M S Prasad
 
Genetic Algorithms in Artificial Intelligence
ritwijkp2
 
Genetic Algorithm
Jagadish Mohanty
 
Genetic algorithms
zamakhan
 
GeneticAlgorithm
guestfbf1e1
 
Analysis of Parameter using Fuzzy Genetic Algorithm in E-learning System
Harshal Jain
 
Genetic algorithm
garima931
 
AI_PPT_Genetic-Algorithms.ppt
HotTea
 
Genetic-Algorithms forv artificial .ppt
neelamsanjeevkumar
 
Genetic-Algorithms.ppt
ssuser2e437f
 
Genetic-Algorithms.ppt
Nipun85
 
Genetic-Algorithms for machine learning and ai.ppt
neelamsanjeevkumar
 
Genetic-Algorithms-computersciencepptnew.ppt
Fitnessfreaksfam
 
Ad

More from Lahiru Dilshan (20)

PDF
"Capture" in lambda expression.
Lahiru Dilshan
 
PDF
CAD vs CAM vs CAE software.pdf
Lahiru Dilshan
 
PDF
Degeneracies in 3D modeling.pdf
Lahiru Dilshan
 
PDF
Operator overloading C++
Lahiru Dilshan
 
PDF
What does Buffer in C++ means.pdf
Lahiru Dilshan
 
PDF
Open CASCADE for your project.pdf
Lahiru Dilshan
 
PPTX
Linkage mechanisms - Presentation
Lahiru Dilshan
 
PDF
Industrial Training Experience
Lahiru Dilshan
 
PDF
Small scale business analysis
Lahiru Dilshan
 
PDF
Computational and experimental investigation of aerodynamics of flapping aero...
Lahiru Dilshan
 
PDF
Experimental and numerical stress analysis of a rectangular wing structure
Lahiru Dilshan
 
PDF
Experimental and numerical stress analysis of a rectangular wing structure
Lahiru Dilshan
 
PDF
Transient three dimensional cfd modelling of ceilng fan
Lahiru Dilshan
 
PDF
Payload safety and related human factors
Lahiru Dilshan
 
PDF
Human factors consideration in emergency evacuation for commercial aircaft
Lahiru Dilshan
 
PDF
Human factors in payload safety of fighter aircrafts
Lahiru Dilshan
 
PDF
HUMAN FACTOR CONSIDERATIONS IN MILITARY AIRCRAFT MAINTENANCE AND INSPECTIONS
Lahiru Dilshan
 
PDF
Human factors - Maintenance and inspection
Lahiru Dilshan
 
PDF
Fire safety of passenger aircraft
Lahiru Dilshan
 
PDF
Displays and controls arrangement of military aircraft
Lahiru Dilshan
 
"Capture" in lambda expression.
Lahiru Dilshan
 
CAD vs CAM vs CAE software.pdf
Lahiru Dilshan
 
Degeneracies in 3D modeling.pdf
Lahiru Dilshan
 
Operator overloading C++
Lahiru Dilshan
 
What does Buffer in C++ means.pdf
Lahiru Dilshan
 
Open CASCADE for your project.pdf
Lahiru Dilshan
 
Linkage mechanisms - Presentation
Lahiru Dilshan
 
Industrial Training Experience
Lahiru Dilshan
 
Small scale business analysis
Lahiru Dilshan
 
Computational and experimental investigation of aerodynamics of flapping aero...
Lahiru Dilshan
 
Experimental and numerical stress analysis of a rectangular wing structure
Lahiru Dilshan
 
Experimental and numerical stress analysis of a rectangular wing structure
Lahiru Dilshan
 
Transient three dimensional cfd modelling of ceilng fan
Lahiru Dilshan
 
Payload safety and related human factors
Lahiru Dilshan
 
Human factors consideration in emergency evacuation for commercial aircaft
Lahiru Dilshan
 
Human factors in payload safety of fighter aircrafts
Lahiru Dilshan
 
HUMAN FACTOR CONSIDERATIONS IN MILITARY AIRCRAFT MAINTENANCE AND INSPECTIONS
Lahiru Dilshan
 
Human factors - Maintenance and inspection
Lahiru Dilshan
 
Fire safety of passenger aircraft
Lahiru Dilshan
 
Displays and controls arrangement of military aircraft
Lahiru Dilshan
 
Ad

Recently uploaded (20)

PPTX
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
PPTX
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PDF
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
PDF
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PPTX
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PDF
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
DOCX
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
PPTX
darshai cross section and river section analysis
muk7971
 
PDF
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
William Stallings - Foundations of Modern Networking_ SDN, NFV, QoE, IoT, and...
lavanya896395
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
Functions in Python Programming Language
BeulahS2
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
darshai cross section and river section analysis
muk7971
 
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 

Solving non linear programming minimization problem using genetic algorithm

  • 1. Assignment on Solving Non-Linear Programming Minimization Problem Using Genetic Algorithm NAME : Dilshan K.M.G.L. INDEX NO. : 150131A GROUP : Aeronautical I DATE OF PER. : 2017.09.29 DATE OF SUB. : 2017.10.27 GROUP MEMBERS: Abenayake D.H.S. Amarathunga H.D.V. Annasiwatta D.M. Dilanjaya H.W.S.
  • 2. Abstract This report is an analysis of genetic algorithms and their applications. The concept of genetic algorithms and the evolution are being used to generate solutions in cyclic operations. We use genetic algorithm principles and functions and produce results step by step logically to find solutions to a given equation such that it satisfies given conditions. Introduction Genetic Algorithms (GAs) are based on the evolutionary ideas of natural selection and genetics. The basic techniques of the GAs are designed to simulate processes in natural systems necessary for evolution. The difference is that all individuals try to satisfy the same task and actually this is by means far simpler than actual evolution. GAs presumes that potential solution for any problem is an individual and can be represented by a set of parameters. These parameters are regarded as genes and can be represented by string values of binary form. Throughout a genetic evolution the result of the fitness function determines the quality of the solution. In genetic operation after each cycle of operation a subsequent generation is created from the current population. It is expected that from this process of evolution a better subsequent generation is created.
  • 3. How to solve a genetic algorithm There is a conventional procedure which should be followed in order to solve a problem using genetic algorithms. Phenotype decoding Genotype population initialization Evaluation of the initial population Parents selection Crossover Mutation Evaluation of the off spring Next generation selection Condition Stop Start
  • 4. • Genotype − Genotype is the population in the computation space. In the computation space, the solutions are represented in a way which can be easily understood and manipulated using a computing system. • Phenotype − Phenotype is the population in the actual real world solution space in which solutions are represented in a way they are represented in real world situations. 1. Genotype population initialization - genotype string is randomly generated for each individual of the generation 2. Phenotype decoding – for each individual the value regarding the actual scenario is generated for further operations. 3. Evaluation of the initial population – decoded phenotypes are used and the validity of the constraints are checked. Then depending on the satisfaction of constraints a penalty is added to the generated Z value and hence the fitness values are generated. By the obtained final value the initial population is evaluated. 4. Parents selection – once the initial population is evaluated then 3 of the elements are randomly taken and the best out of the 3 are selected. Likewise we choose another random 3 elements and the best element is chosen. Then the chosen elements are taken as parents.
  • 5. Crossover 3 chromosomes are selected out of all individuals. And then 1 individual is selected which has the highest fitness value out of these 3 chromosomes. This selected individual is named as a parent. The same procedure is followed to select another parent. After that these 2 parents are paired. And these 2 parents are ready to be crossed. Amount of cross over points are defined. Here in this example 1 cross over point is taken to demonstrate. Crossover rate is defined. A random probability is generated by the interpreter and if the random probability is less than the cross over rate two parents will be crossed, and 2 children will be generated which are known as offspring. This crossover rate should be relatively lower as the 2 children should have higher percentage of their parent’s characteristics. x = random value generated by the program between 1 & 100 if x < crossover rate then; Two parents are crossed. else; Two parents are not crossed. Children = Parents. 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 Parent 1 Parent 2 Offspring 1 Offspring 2
  • 6. Mutation Probability that a bit subjects to mutation is known as the mutation rate. Offspring, which are generated in the previous step (crossover step) are subjected into the mutation step. This step is followed for every single bit respectively. A mutation rate is defined between 1 and 56. Random values are generated for every single bit separately. An example is for the 1st bit is as follows. x = mutation rate A random value is generated by the program. if random value <= x then; Bit is mutated. 0 1 else; Bit is not mutated. 0 0 Evaluation of the offspring The offspring which is generated by the previous step is divided into 8-bit sections to observe phenotypes. If the phenotype does not satisfy the given constraint a penalty value is added to the given phenotype. The penalty value is given depending on how the phenotype satisfies the given constraint. If the variation is high, penalty value which is given for the phenotype is high. Fitness function depends on the values of penalties and the function is defined according to the problem to be solved. And it is defined to compare the suitability of the phenotype (to select the most suitable phenotype). Next generation selection Next generation is created by the offspring which are generated by the crossover step and other parents which are randomly selected at the first. All these offspring and parents are called as the next generation. 0 1 0 1 1 0 0 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 0 1 1
  • 7. PROBLEM STATEMENT Problem Problem3: Minimize 𝑧 = 𝑧1 + 𝑧2 where 𝑧1 = (𝑥1 − 10)2 + 5(𝑥2 − 12)2 + 𝑥3 4 + 3(𝑥4 − 11)2 𝑧2 = 10𝑥5 6 + 7𝑥6 2 + 𝑥7 4 − 4𝑥6 𝑥7 − 10𝑥6 − 8𝑥7 Subject to, 127 − 2𝑥1 2 − 3𝑥2 4 − 𝑥3 − 4𝑥4 2 − 5𝑥5 ≥ 0 282 − 7𝑥1 − 3𝑥2 − 10𝑥4 2 − 𝑥4 + 𝑥5 ≥ 0 196 − 23𝑥1 − 𝑥2 2 − 6𝑥6 2 + 8𝑥7 ≥ 0 −4𝑥1 2 − 𝑥2 2 + 3𝑥1 𝑥2 − 2𝑥3 2 − 5𝑥6 + 11𝑥7 ≥ 0 • Number of individuals per generation = 60 • Number of bits per variables = 8 • Code length = 56 • Genotype to phenotype conversion = −10 + 20 × 𝑥 𝑔 28−1 • Range of phenotype variables = −10 ≤ 𝑥𝑖 ≤ 10 • Parent selection method = Take 3 randomly selected parents from the initial generation and take the best one from each. • Crossover method = One point crossover with a random generated crossover point • Crossover method = One point crossover with a random generated crossover point • Crossover rate = Selected value from range 0 - 99 • Mutation = Selected value from range 1-56 (we were given 1/56 as the default mutation rate) • Next generation selection method = 52 individuals were created using the crossover, mutation process • Then 8 individuals with the highest fitness value in the initial generation were added to that 52, hence 60 individuals creating a second generation. • Fitness function = 𝑇𝑜𝑡𝑎𝑙 𝑝𝑒𝑛𝑎𝑙𝑡𝑦 − 𝑧 •
  • 8. • Total penalty = - (Constraint1 + Constraint2 + Constraint3 + Constraint4) {constraint was added to the penalty, only if it was violated.} • Stopping condition = 2000 iterations • Expected change of genetic parameter that is going to be compared = mutation rate
  • 9. Programming concept The concepts used to produce results can be explained as shown below. I. Importing libraries to enable certain operations. II. Genotype population initialization Concept: By the use of the random library, a random number between 0-255 is generated. Then this value is stored in a list for further operations to create binary values. The reason for choosing 255 is the reason is to have 8 bits for a randomly generated number. If the no of bits are increased then the accuracy would have improved. 3. Phenotype decoding
  • 10. Concept: As stated in the problem we need the genotypes to be converted in to phenotypes to be in the range of - 10 to +10. We need to map the genotype range (0-255) linearly to the phenotype range. For that we use the equation 𝑥 𝑝 = −10 + (10 − (−10))𝑥 𝑔/(28 − 1) 4. Evaluation of the initial population Concept: Phenotypes are substituted in the constraints and the problem equation. Then fitness values were obtained according to the random values generated.
  • 11. 5. Parents selection and selecting the best pair parents. Concept: Out of the 60 randomly generated values 2 groups of 3 parents are picked randomly and the best out of each group is paired with the other. Then again all the 6 parents are put back to the same list making the probability of being selected the same throughout. 26 couples are formed. And sent to the next generation.
  • 12. 6. Selecting best 8 parents
  • 13. Concept: Once the fitness values are generated then we rank them in order and select the best 8 parents. The top 8 minus values which are closer to zero were selected. Then these 8 parents were directly sent to the next generation. 7. Crossover and mutation
  • 14. Concept: The selected 26 couples are then used to make children. Initially the user is asked to give a crossover number. Then that value is compared with a randomly generated number which lies between (0-99). If the randomly generated value is less than the given value by the user, then the crossover happens between the couple and two children are produced. Likewise, 52 offspring are generated. Mutation rate can be defined between 1-56. There are 7, 8-digit numbers in each single offspring. This contain 56 digits. Each digit is followed through mutation process respectively. A random value between 1 and 56 is generated for each single bit. If the random value is less than the mutation rate bit should be mutate. Which means bit is flipped. 8. Evaluation of offspring Concept: As mentioned above the 52 children whom were taken after crossover and mutation with the best 8 parents and this process is called the evaluation of the offspring.
  • 15. Logical error checking • Geno to pheno conversion After initial population is generated, the values are tabulated under these headings. This table is part of total values Genotype Code x1 x2 x3 x4 x5 x6 x7 1 44 246 7 133 79 174 188 2 56 222 153 164 237 37 60 3 206 213 218 43 124 239 119 4 90 110 193 24 70 177 170 5 62 80 154 117 23 113 183 6 254 239 173 253 67 108 236 Then we have compared the pheno types that are generated through code and manually. Those value are tabulated tables given below. We can see that these values are same. So that code has no arithmetic errors in the conversion of the • Binary and decimal conversion In another step we have to make sure that, the coding function that has use to convert phenotype into binary values has no error. To ensure that we have done excel calculation and compare these values. Part of the tables are shown below. Decimal Genotype x1 x2 x3 x4 x5 x6 x7 1 44 246 7 133 79 174 188 2 56 222 153 164 237 37 60 3 206 213 218 43 124 239 119 4 90 110 193 24 70 177 170 5 62 80 154 117 23 113 183 6 254 239 173 253 67 108 236 Decimal values that use to generate binary values Binary (Code) x1 x2 x3 x4 x5 x6 x7 00101100 11110110 00000111 10000101 01001111 10101110 10111100 00111000 11011110 10011001 10100100 11101101 00100101 00111100 11001110 11010101 11011010 00101011 01111100 11101111 01110111 01011010 01101110 11000001 00011000 01000110 10110001 10101010 00111110 01010000 10011010 01110101 00010111 01110001 10110111 11111110 11101111 10101101 11111101 01000011 01101100 11101100 Binary values that generated using computer program Binary (Manual) x1 x2 x3 x4 x5 x6 x7 00101100 11110110 00000111 10000101 01001111 10101110 10111100 00111000 11011110 10011001 10100100 11101101 00100101 00111100 11001110 11010101 11011010 00101011 01111100 11101111 01110111 01011010 01101110 11000001 00011000 01000110 10110001 10101010 00111110 01010000 10011010 01110101 00010111 01110001 10110111 11111110 11101111 10101101 11111101 01000011 01101100 11101100 Binary values that generated using excel sheet
  • 16. Both values that comes under these two different tables are same. So that we can say that these values have no error. • Crossover checking Another point that will cause to generate errors is crossover and mutation. We have designed and proved using tabular method as given in the tables bellow, there are no logical or arithmetic calculation errors in the code. Here we have selected best fitted parent out of randomly selected 3 parents. Those values are choose using random numbers. And then crossover them by deciding the crossover rate, that is also a random number and that value is checked with the given crossover rate. If the condition satisfies, these values are crossed over at a point that also randomly generated by the code. By considering these results we can conclude that our computer program that use to solve the problem has no any arithmetic and logical errors. There are several ways to solve problems in the genetic algorithm. Mostly in this method, the desired values must gain without considering the initial values that the code is generated under the conditions that we are given. This entire procedure is done in random manner but the program itself find the best fitted solution. That’s the beauty of genetic algorithms. Best Parent 1 x1 x2 x3 x4 x5 x6 x7 1 74 213 216 14 155 0 56 2 151 213 154 50 122 11 195 3 44 246 7 133 79 174 188 4 161 45 173 19 104 93 117 5 206 213 218 43 124 239 119 6 5 106 0 70 98 148 205 Parent selections 1 Best parent 2 x1 x2 x3 x4 x5 x6 x7 1 44 246 7 133 79 174 188 2 64 102 192 168 200 36 239 3 51 201 26 214 213 197 22 4 92 62 25 84 80 172 114 5 163 192 67 150 88 64 79 6 192 101 69 104 131 44 118 Parent selection 2 Random Generated No Crossover Point 7 2 93 0 41 6 64 4 23 1 81 3 Crossover points
  • 17. Phenotype Codex1x2x3x4x5x6x7z1z2z1234Fitness 1-6.549029.294118-9.450980.431373-3.803923.6470594.7450988623.81330752.739376.52-22315.9-597.485218.4014-585.223-62875.1 2-5.607847.41176522.8627458.588235-7.09804-5.29412563.50940136804014244-9066.94264.7451-74.5998-336.163-4023722 36.1568636.7058827.098039-6.62745-0.274518.745098-0.666673625.451476.74164102.193-6196.83-278.684-454.77-224.558-11257 4-2.94118-1.372555.137255-8.11765-4.50983.8823533.3333332854.55884240.7687095.31-147.12146.39985197.9938-59.9031-87302.3 5-5.13725-3.725492.078431-0.82353-8.19608-1.137254.3529411903.64130317183033622-467.497278.5659327.341-17.0996-3034107 69.9215698.7450983.5686279.843137-4.7451-1.529418.509804219.1759119408.6119627.8-17983.344.37447-54.629-134.147-137800 Constraints/Penalties Codegeneratedphenotypevalues Phenotype Manualx1x2x3x4x5x6x7z1z2z1234Fitness 1-6.549029.294118-9.450980.431373-3.803923.6470594.7450988623.81330752.739376.52-22315.889-597.48481218.4013841-585.22261-62875.1 2-5.6078437.41176522.8627458.588235-7.09804-5.29412563.50940136804014244-9066.9357264.745098-74.59976932-336.16301-4023722 36.15686276.7058827.098039-6.62745-0.274518.745098-0.666673625.451476.74164102.193-6196.8264-278.68435-454.7704729-224.55825-11257 4-2.941176-1.372555.137255-8.11765-4.50983.8823533.3333332854.55884240.7687095.31-147.1211846.3998462197.9938485-59.903114-87302.3 5-5.137255-3.725492.078431-0.82353-8.19608-1.137254.3529411903.64130317183033622-467.49662278.565936327.3410227-17.099577-3034107 69.92156868.7450983.5686279.843137-4.7451-1.529418.509804219.1759119408.6119627.8-17983.34344.3744714-54.62898885-134.14687-137800 Constraints/Penalties Manuallycalculatedphenotypevalues AfterCrossover(Offspring1)Offspring(Offspring2) x1x2x3x4x5x6x7x1x2x3x4x5x6x7 17421371337917418814424621614155056 2151213154501221119526410219216820036239 3442467133791742235120126214213197188 416145173198017211449262258410493117 520619267150886479516321321843124239119 651060104131441186192101697098148205 Manuallycalculatedmutations
  • 18. The main idea of the population is come from simply as subset of solution space. Also, we can say that chromosomes. In a population there must be diversity, in initial condition. But after some iterations all the population will have same value, but it is not a compulsory condition. And also, when we select large number of population for the calculation, that will cause to slow down the converging process. And on the other hand, when we select small number of individuals as population, the diversity of the population is not keep. Other than that, it will not produce good mating pool for generate new population. Genotype population initialization According to the problem that we have to solve using GA, we have to pay our attention to 7 variables and 4 constraints. First of all, we have to get initial phenotype from the code. Instead of randomly select genotype, we can manually enter genotypes (heuristic initialization). These are two different methods. We cannot say directly what is the most efficient way among these two. To get clear picture of the efficiency of the method, we have to run the code under both of these methods and get series of solutions. That may pave the way to get somewhat clear understanding about the efficiency of each method. And also, there are some ways for population models called steady state model and generational model. In steady state model, generate 2 off springs in each iteration and those off-springs replace one or two individuals from the population. So that the population is constant and the change is continuous. In generational method we generate some offspring equal to the new population number. That method is used during the iterations. Basically, we can use combination of both those methods to generate new population. Phenotype decoding – mapping genotype to phenotype When we consider about the phenotype decoding, that means we are going to map the values that generated by the code itself. The aim is to set the variable values that suitable for the range that we are trying get. The range is different from problem to problem, because of the type and conditions of the problem. We can select different mapping functions according to the problem. We can use linear mapping functions, polynomial mapping functions, logarithmic mapping functions, exponential mapping functions etc. When we are considering about the bias, we have to avoid linear mapping function. In linear mapping function there is no special conditions that avoid biasing to highest values or lowest values. When we consider about the biasing there will be some values that generated are biased to highest values of the inequality. On the other hand, these values can be gathered into lower value. In some researchers we have seen that these types of values will get higher time to converge into the desired value. And also, these values will get lower fitness with compared to the non-biased mapping values. When we think about the mapping values that not much close to the higher merging as well as lower merging. Then we have to define definitely nonlinear function to get the values. We can use parabolic shape function when we have to avoid biasing to the lowest possible values. When we use hyperbolic function that mapping function will have completely different. So that we have to select best fitting mapping function. In same problem there will be several mapping functions. In most problems, there is a range for each parameter in a problem. Otherwise we have to introduce a range of possible values that the parameter can get. In multi variable problem, we can introduce unique mapping function for each variable in order to avoid some undesirable values or to reduce the probability to generate such values. In GA basically use randomness. So that we have to reduce the probability that these biased values or undesirable values are generated.
  • 19. Evaluation of initial population In initial generation there are no crossover or mutation. That is purely based on the values that the code is generated and the mapping function we are used. After generating initial population, we have to get the idea of the fitness value of each individual have. So that we are going to define fitness function. This fitness function is a representation of a deviation from the most optimized value and the value generated from the code. Fitness function is the most crucial function that used in GA. We say that because the optimum value that we can get from the code is based on out fitness function. To calculate the fitness there are some methods. Basically, programmer has to decide the function that he is going to use to optimize the solutions. To get the variation from the actual value we introduce penalty value if the variables are violated the constraints. These penalty values decide the eligibility of the variable. As an instance, when we think about problem that has four constraints, we can introduce 4 penalty values, one for each. And in simple way to optimize the fitness, the sum of the penalty values can be adding or subtract from the final optimized value. That will help to select the next generation process to decide the fitness of each individual. Some of the cases the fitness function can be used as the objective function. but when we consider about the nonlinear more complex problems cannot use the objective function as same as this. Basically, fitness function should have fast computing method. Because slow computation of the fitness value can be affect to slow the converting process. Parent selection methods After generating and evaluating initial population we have to mate selected parents to generate new population. There are several ways of selecting parents, and we have to choose one of them for our analysis. As we can see that parent selection method is very crucial because that will affect directly for the fitter solution and time to converge. And also, these parent selection methods don’t use only “best” fittest parents for the next solution. Main reason is we cannot neglect all low fitted phenotypes without selecting them for the mutation or crossover. That will cause for reduce diversity of the population. There will be good genes, proper genes in worst individuals and sometimes these best genes will immerge through crossover and mutation in another population. So that maintaining good diversity in the population in extremely crucial for the success of a GA. After sometimes population is converged to some premature convergence and is an undesirable condition in a GA. That will be the optimum solution. Basically, the aim of parent selection is to select two individuals from the existing pool of individuals and use to mate and recombine to create off-springs to next generation. Most popular method is select parents according to the fitness value of them. According to that method each individual has a probability values to select for the next generation. So that fitter solutions have higher chances to participate for the mating purpose. There are several selection methods. Roulette wheel selection method, Stochastic universal Sampling method, tournament selection method, rank selection method, random selection method. In roulette wheel selection method, the fitness value of the individuals is represented by the area of a circle. Higher the fines value, higher they are represented in the circle, higher chance to select to next generation. These values are generated by dividing the value of fitness, total sum of fitness.
  • 20. In stochastic universal sampling, both parents that use to crossover are selected at the same time. Simply these values are at the opposite side of the circle. There will be a problem with the fitness proportionate methods will not work when the fitness values get negative. When we consider about the tournament selection method, basically randomly selected parents are shifted to mating process and produce children. In literature this will work even for negative fitness values. Here select 2 or more chromosomes from the pool and among them select best chromosome. In the second stage, repeat the process and get another chromosome until select best fit one. This method usually uses when there are higher number of individuals in a population. Stochastic universal sampling Roulette wheel selection method
  • 21. Then about the rank selection method, each individual has equal possibility to select for mating processes. This method is used when population has very close fitness values. Another thing is random selection method. It has no pressure on each individual to select as parent. So that the strategy is usually avoided. In our situation we select a parent within randomly selected 3. That parent has highest value among them. By repeating that again select another one and both two send for crossover and mutation. We can improve the selection method by getting higher number of parents and select one from them. But when we increase the number of parents select from the population there will be a chance that same value repeats in many of the selection points. Another method is divide the population into equal amount of parts. Then generate children from them. After those parents and children, select number of individuals equals to the individual count in selected part of the population. Then remove the selected parents from the population. After that repeat the same process. This method will cause to reduce time for the convergence to the answer. And also, it will give best answer from that. Tournament selection method Random selection method
  • 22. Crossover Here the crossover is relevantly represented the biological crossover. Here in the binary string crossover, we can select one or more points to do the crossover. In genetic algorithms, the crossover rate is high, and it will cause to increase the diversity in the population. And also, it paves the way to immerge the hidden strong genes to make fitter values. In basically there is a crossover rate defined in the code. The crossover rate must be high value. There are several ways to do crossover. One-point crossover, two-point crossover, uniform crossover. One-point cross over it happens by one point and then the separated parts are combined together to generate 2 children. In two-point crossover, one binary spring is separated into three parts and then combined them together. In uniform crossover, the binary string is not divided into segments. Here generate random possible value and according to that value crossover each bit. One-point crossover Two-point crossover Uniform crossover
  • 23. Mutation Generally, mutation is represented as a small random tweak in the chromosome, to get a new solution. That will cause for the diversity of the population. Here it will use for the convergence of the GA problem. And also, there are several mutation ways to do operations. As the cross over there is defined a mutation rate, but that is smaller in value than the crossover rate. When the mutation rate is increased the values will corrupted. And other thing is if the mutation rate is increased then sometimes it will cause to reduce the time for convergence. First bit flip mutation, that is used when one or more binary value is flip. Bit flip mutation Random resetting is another type. Here set of permissible values is assigned to a randomly chosen gene. In swap mutation, selected two positions of a binary sting is randomly interchanged. That is common in permutation based ending. Scramble Mutation The values if a chromosome is shuffled randomly within the selected region. Inversion Mutation Here without shuffling as in the scramble mutation the entire substring is reversed. There are some application areas that GA is used. Basically, in optimization, economic, neural networks are used. In optimization, usually use in minimizing and maximizing objective function optimization. As names parallelization, image processing is used GA functions. Swap Mutation Scramble Mutation Inversion Mutation
  • 24. Results and graph We can plot 2 different graphs using the results that generated using the computer program. One graph is best fitted value vs. number of iterations. We can see that with few number of iterations the value is converged to some value, that we can take this as optimal solution of our program. By converging the value into some value with less time means, we can guess that program itself select best fitted value quickly. With low time consuming, we can say program searched large area of the solution space and get the optimum value from that. We are using desirable number of iterations, not much large and not too low. By executing large number of trials, we can get the average optimum value. Other than that, we cannot conclude, this value is the most optimized value in the solution space that satisfy all constraints. Another graph can be plotted using average fitness value vs. number of iterations. -1600 -1500 -1400 -1300 -1200 -1100 -1000 -900 -800 -700 -600 0 2000 4000 6000 8000 10000 12000 Bestfitnessvalue Number of iterations Best fitness vs Iteration -1600000 -1400000 -1200000 -1000000 -800000 -600000 -400000 -200000 0 0 2000 4000 6000 8000 10000 12000 Axisaveragefitnessvalue Number of iterations Avg fitness vs Iteration
  • 25. Here average value of the iterations is spread in large range, and also, we cannot get some exact range that the average value will gather. In some cases, we can say that this will happen because of the biased situations. When some populations fitness values are lower and also in some other cases most of the individuals have high fitness value cause to generate lower and higher average fitness value. Biased will cause errors sometimes because these highest or lowest points will near to the local optimizing points. So that values will gather towards them and if the number of iterations are low, we cannot get optimal solution from them. In other words, to avoid such vast variation of the average fitness, we have to change the fitness functions. Another thing is with the variation of the average fitness, sometimes will paves the way towards the optimal solution by releasing some local optimal points. In our analysis we are going to change the mutation rate and generate the best fitness and average fitness values. When we consider about the variation of highest fitness values with the change of mutation rate, that will produce a graph like as follows. For the plot like this we have to consider about many number of iterations per one mutation rate. Then we can get the average value of the mutation rate. Other than that, without implementing higher number of iterations we cannot get the best fitted values. The values that based for the graph are included in Excel sheet. In the previous graph was plotted using single round per single mutation rate. So that these values may change with the increment of the executing rounds. But we can get a rough idea about the change of the highest values. We can see that the path of the graph is increased and then gradually decreasing, after mutation rate is about 5. We can say, with the increment of the mutation rate, the corruption of the values of the graph will occur. So that there will be huge deviation from the optimum result. With the conclusion, we can say that with the increment of the mutation rate, there will be deviation from the actual value. -820 -800 -780 -760 -740 -720 -700 -680 -660 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 Highestfittedvalue Mutaition rate Mutation rate vs highest fitted value
  • 26. There are several other ways to optimize the solution of our program. As mentioned above we can change the crossover rate and find the variation of the highest fitness value without changing any other parameters. In this graph we cannot get proper visible deviation with the increment of the crossover rate. Suppose that the sample we are used to plot the graph is much smaller and that will cause for the graphical representation. So, using that graph we cannot explain the behaviour (Genetic algorithms tutorial, n.d.) (Chapter 2 - genetic algorithms, 2017) of the crossover rate and the highest fitness function. Another thing is we have changed the parent selection methods and try to optimize the code. But each method is converged in to same values, without giving any deviation from them. When we generate the z value from various executions, there will be some deviation of the value. These values are tabulated as follows. 635 640 645 650 655 660 665 0 2 4 6 8 10 12 maximumzvalue execution number maximum z values -694 -692 -690 -688 -686 -684 -682 -680 -678 0 10 20 30 40 50 60 70 80 90 100 highestfitnessvalue crossover rate Crossover rate vs highest fitness value
  • 27. References Chapter 2 - genetic algorithms. (2017). In Kramer. Springer. Genetic algorithms tutorial. (n.d.). Results and work conducted Index No Name Work 150023U H.D.V Amarathunga Coding 150131A K.M.G.L Dilshan Manual checking 150127R H.W.S Dilanjaya Manual checking 150031R D.M Annasiwatta Report Editing 150008E D.H.S Abenayake Report Editing