{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

GeneticAlgorithm

# GeneticAlgorithm - A Simple Genetic Algorithm A L TEX le...

This preview shows pages 1–2. Sign up to view the full content.

A Simple Genetic Algorithm L A T E X file: ga-nb-all — Daniel A. Graham <[email protected]>, June 30, 2005 For the objective function to be maximized, take a quadratic with one local and one global maximum in the interval [0,31] In: objective = (x - 14 ) 2; In: Plot [ objective , { x, 0 , 31 } ] ; 5 10 15 20 25 30 50 100 150 200 250 Call the binary form of the objective function " Fitness " : In: Fitness [ a_ ] := ( a [[ 1 ]] 2 4 + a [[ 2 ]] 2 3 + a [[ 3 ]] 2 2 + a [[ 4 ]] 2 + a [[ 5 ]] - 14 ) 2 Check the values of Fitness at 00000 (0), 01110 (14) and 11111 (31): In: { Fitness [ { 0 , 0 , 0 , 0 , 0 } ] , Fitness [ { 0 , 1 , 1 , 1 , 0 } ] , Fitness [ { 1 , 1 , 1 , 1 , 1 } ] } Out: { 196 , 0 , 289 } The initial population Given n, randomly determine an initial population of 2n 5-digit binary strings: In: InitPop [ n_ ] :=Table Random [ Integer ] , { i, 1 , 2 n } , j, 1 , 5 Reproduction Reproduction must take an initial population, determine the fitness of each member, select a new population from the initial randomly with probabilities proportional to fitness, randomly select pairs from this new population and then, for each pair, randomly determine a crossover point in their 5 digit strings and switch the portions of the string that follow this point.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

GeneticAlgorithm - A Simple Genetic Algorithm A L TEX le...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online