You are on page 1of 5

Using Genetic Algorithm to do Quality Control Aniket Bera, Puneet Bajaj

Many a times to measure quality we need to see a combined understanding of all the parameters. Lets assume that quality is a sum of many functions which may or may not be dependent of each other. Quality = f1() + f2() +f3() +.. One quality may measure the kurtosis, one may measure the skewness, one may measure the degree of marginal change of some output. Mathematically let f1(x) = ax + bx2 + cx3 + (till nth Degree) f2(y) = ay + by2 + cy3 + (till mth Degree) So on and so forth. We can see that it is a highly complex multi-variable equation and each equation might have its own boundary conditions. Note a,b,c.,a,b,c etc. are the coefficient weights (Relative).

For a large search-space it is computationally impossible to calculate the quality quotient to get a better understanding of the overall quality status. For testing purposes we have taken a 3 variable equation with sinusoidal curves to justify complexity.

Equation - (15*x*y*(1-x)*(1-y)*sin(9*3.14*x)*sin(9*3.14*y))^2

Graph of the Equation

Algorithm
About GA Genetic Algorithms (GAs) are adaptive heuristic search algorithm premised on the evolutionary ideas of natural selection and genetic. The basic concept of GAs is designed to simulate processes in natural system necessary for evolution, specifically those that follow the principles first laid down by Charles Darwin of survival of the fittest. As such they represent an intelligent exploitation of a random search within a defined search space to solve a problem.

Few Important Terms


Individual - Any possible solution Population - Group of all individuals

Search Space - All possible solutions to the problem Chromosome - Blueprint for an individual Genome - Collection of all chromosomes for an individual

Selection
for all members of population sum += fitness of this individual end for for all members of population probability = sum of probabilities + (fitness / sum) sum of probabilities += probability end for loop until new population is full do this twice number = Random between 0 and 1 for all members of population if number > probability but less than next probability then you have been selected end for end create offspring end loop

Crossover
So now you have selected your individuals, and you know that you are supposed to somehow produce offspring with them, but how should you go about doing it? The most common solution is something called crossover, and while there are many different kinds of crossover, the most common type is single point crossover. In single point crossover, you choose a locus at which you swap the remaining alleles from on parent to the other. This is complex and is best understood visually.

As you can see, the children take one section of the chromosome from each parent. The point at which the chromosome is broken depends on the randomly selected crossover point. This particular method is called single point crossover because only one crossover point exists. Sometimes only child 1 or child 2 is created, but oftentimes both offspring are created and

put into the new population. Crossover does not always occur, however. Sometimes, based on a set probability, no crossover occurs and the parents are copied directly to the new population. The probability of crossover occurring is usually 60% to 70%.

Mutation
After selection and crossover, you now have a new population full of individuals. Some are directly copied, and others are produced by crossover. In order to ensure that the individuals are not all exactly the same, you allow for a small chance of mutation. You loop through all the alleles of all the individuals, and if that allele is selected for mutation, you can either change it by a small amount or replace it with a new value. The probability of mutation is usually between 1 and 2 tenths of a percent. A visual for mutation is shown below.

As you can easily see, mutation is fairly simple. You just change the selected alleles based on what you feel is necessary and move on. Mutation is, however, vital to ensuring genetic diversity within the population.

Output
Best (0.878905776751267): 0.500013456729 0.50002204044723 Worst (0.00656697293106702): 0.447539588831787 0.50002204044723

You might also like