Ralph Vince - Portfolio Mathematics

(Brent) #1

320 THE HANDBOOK OF PORTFOLIO MATHEMATICS


until you have reachedXunimproved generations, that is,Xgenerations
where the best objective function value has not been exceeded. You then
quit, at that point, and use the gene corresponding to that best objective
function value as your solution set.
For an example of implementing the genetic algorithm, suppose our
objective function is one of the form:


Y= 1500 −(X−15)^2

For the sake of simplicity in illustration, we will have only a single
variable; thus, each population member carries only the binary code for
that one variable.
Upon inspection, we can see that the optimal value forXis 15, which
would result in aYvalue of 1500. However, rarely will we know what the
optimal values for the variables are, but for the sake of this simple illustra-
tion, it will help if we know the optimal so that we can see how the algorithm
takes us there.
Assume a starting population of three members, each with the variable
values encoded in five-bit strings, and each initially random:


First Generation

Individual # X BinaryXY Fitness Score


1 10 01010 1475 .4751
2 0 00000 1275 0
3 13 01101 1496 .5249


Now, through random selection based on fitness, Individual 1 for the
second generation draws Parents 1 and 3 from the first generation (note
that Parent 2, with a fitness of 0, has died and will not pass on its genetic
characteristics). Assume that random crossover occurs after the fourth bit,
so that Individual 1 in the second generation inherits the first four bits from
Individual 1 of the first generation, and the last bit from Individual 3 of the
first generation, producing 01011 for Individual 1 of the second generation.
Assume Individual 2 for the second generation also draws the same
parents; crossover occurs only after the first and third bits. Thus, it inherits
bit 0 from Individual 1 in the first generation, bit 11 as the second and
third bits from the third individual in the first generation, and the last two
bits from the first individual of the first generation, producing 01110 as the
genetic code for the second individual in the second generation.
Now, assume that the third individual of the second generation draws
Individual 1 as its first parent as well as its second. Thus, the third individual

Free download pdf