Professional Documents
Culture Documents
6 Genetic Algo
6 Genetic Algo
Genetic Algorithms
31
The genetic algorithm is a probabilistic search algorithm that iteratively transforms a set (called a population) within search space, each with an associated fitness value, into a new population of offspring objects using the Darwinian principle of natural selection as shown in fig 4.1 and using operations that are survived after genetic operations, such as crossover and mutation.
Reproduction
Competition
Survive
Fig4.1: Darwinian Paradigm
Selection
Genetic Algorithms
32
Search Space
A population of individuals is maintained within search space for a GA, each representing a possible solution to a given problem. Each individual is coded as a finite length vector of components, or variables, in terms of some alphabet, usually the binary alphabet . To continue the genetic analogy these individuals are
likened to chromosomes and the variables are analogous to genes. Thus a chromosome (solution) is composed of several genes (variables) as shown in figure 4.2.
1 0 1 0 0 0 1 1 1 0 1 1 0 1
GENE
1 0 1 0 0 0 1 1 1 0 1 1 0 1
Chromosome
Fig4.2: Chromosome representation
The GA maintains a population of n chromosomes (solutions) with associated fitness values. Parents are selected to mate, on the basis of their fitness, producing offspring via a reproductive plan. Consequently highly fit solutions are given more opportunities to reproduce, so that offspring inherit characteristics from each parent (Melanie Mitchell, 1998).
POPULATION
Genetic Algorithms
33
Fitness Function The most important element of GA is Fitness function. In GA, the fitness function assigns a score to each chromosome in current population. The fitness of a chromosome depends on how well that chromosome solves the problem at hand. e.g. (11)
Here the solutions are values of , which can be encoded as bit of strings representing real numbers. The fitness calculation translate a given bit string into real number y and then evaluates the function at that value. The fitness of the string is the function value at that point (Melanie Mitchell, 1998). GA Operators After an initial population is generated randomly, the algorithm evolves the through three operators (Melanie Mitchell, 1998): Selection which equates to survival of the fittest in this we give preference to better individuals, allowing them to pass on their gene to the next generation. Crossover which represents mating between the individuals. In this two individuals are chosen from the population using selection operator and a crossover site along the bit is chosen as shown in figure 4.3. e.g. P1= 000000000000000 and P2=11111111111111 and the crossover point is 4 then P1= 111100000000000 and P2=00001111111111. This is the next generation of the population (Mitsuo Gen et al., 2000).
Genetic Algorithms
34
Parent 1
Parent 2
Child 1
Child 2
Mutation which introduces random modifications. In this the bits of an individual are flipped with some low probability as shown in figure 4.4.
Before Mutation
After Mutation
Genetic Algorithms
35
4.1.2 1. 2. 3.
Basic Genetic Algorithm START : Create random population of n chromosomes FITNESS : Evaluate fitness f(y) of each chromosome in the population NEW POPULATION i. ii. iii. iv. SELECTION : Based on f(y)
4. 5. 6.
REPLACE : Replace old with new population: the new generation TEST LOOP : Test problem criterium : Continue step 1 4 until criterium is satisfied
Genetic Algorithms
36
Start
Take the initial population and assign the score to each member of population by computing their fitness
No
>=Fitness Limit
Reproduction
No
< Generation Limit
Yes No
< Time Limit
Yes
Stop
Fig4.5: Flow of Genetic Algorithm