Mating forms the basis for evolution. Two individuals exchange genetic material, thus passing on some of the capabilities of the mother and some from the father to the child. The child is thus a blend of the characteristics of both the mother and father. If two very fit individuals mate, the child is also likely to be fit. However it will not be the same fitness as the parents - it cannot be - because the parents are not identical themselves. It will be a random blend of the parents and so sometimes be less fit and sometimes more fit.
The process of mating uses two primary operations:
Crossover
Crossover is the process of combining the genes of a chromosome from each parent to create the corresponding chromosome for the child. This is done by selecting a split point at random and using half of the genetic material from the mother and the other half from the father.
Using the chromosomes from the table in the previous topic, and the two individuals shown below, the first chromosome can have only one split point - at the 2nd gene. If we randomly select the split point for chromosome 2 at the 4th gene, we obtain a child as show below.
Chromosome
|
Genes
|
Mother
|
Father
|
Child
|
1
|
SlowLength
|
50
|
45
|
50
|
1
|
FastLength
|
60
|
35
|
35
|
2
|
ProfitTargetAmt
|
500
|
600
|
500
|
2
|
StopLossAmt
|
100
|
50
|
100
|
2
|
BreakevenFloorAmt
|
75
|
50
|
75
|
2
|
DollarTrailingAmt
|
50
|
60
|
50
|
2
|
PctTrailingFloorAmt
|
100
|
120
|
120
|
2
|
PctTrailingPct
|
2
|
5
|
5
|
2
|
ExitOnClose
|
0
|
1
|
1
|
Split points are chosen at random, and whether the first half is copied from the mother's or the father's genes is also random. If the mother's genes are used for the first half, then the father's are used for the second, and vice versa.
If you had used only a single chromosome for all of these inputs there would have been only one split point and one crossover operation. With this you can see why combining related inputs into separate chromosomes improves the efficiency of the algorithm. You get multiple-point crossover with each mating, and each crossover mixes only the genes that relate to each other. This increases the speed with which the algorithm can search and the quality of the search.
Mutation
Sometimes, during mating, a gene will mutate and receive a value that is neither in the mother nor the father. Mutation is nature's way of increasing diversity in the gene pool. Some mutations are beneficial, while others are detrimental to fitness.
The probability of mutation is low in nature; generally only a very small percentage of the total number of genes making up an individual mutate. If many mutations occur in a single individual the result is usually chaotic, and the individual is likely to be less fit because of it. However, a small amount of mutation can be good.
In Optimax, genes will mutate at random with a probability that you control. The value given to a gene during mutation will be within the optimization range for the input and a multiple of the incremental value.
For example, in the table below, one mutation has occurred and is shown in red.
Chromosome
|
Genes
|
Min
|
Max
|
Inc
|
Mother
|
Father
|
Child
|
1
|
SlowLength
|
45
|
80
|
5
|
50
|
45
|
50
|
1
|
FastLength
|
20
|
60
|
5
|
60
|
35
|
35
|
2
|
ProfitTargetAmt
|
100
|
1000
|
100
|
500
|
600
|
500
|
2
|
StopLossAmt
|
50
|
250
|
50
|
100
|
50
|
200
|
2
|
BreakevenFloorAmt
|
25
|
100
|
25
|
75
|
50
|
75
|
2
|
DollarTrailingAmt
|
20
|
100
|
10
|
50
|
60
|
50
|
2
|
PctTrailingFloorAmt
|
80
|
150
|
10
|
100
|
120
|
120
|
2
|
PctTrailingPct
|
1
|
10
|
1
|
2
|
8
|
8
|
2
|
ExitOnClose
|
0
|
1
|
1
|
0
|
1
|
1
|
The StopLossAmt for the child does not exist in either the mother or father. It is within the range from 50 to 250, and is a multiple of 50.
Genetic Complements
Using genetic programming, we can do something that nature can't, we can create the opposite of an individual. This is call the genetic complement of an individual.
Genetic Complement - the theoretical genetic opposite of an individual.
Complements are useful for increasing the diversity of the gene pool in a way that is very different from mutation. By taking the complement of an unfit individual, there is the possibility of creating a fit individual. To determine the compliment, first imagine each input range wrapping around and creating a continuum on a circle. For example, if Min = 20, Max = 50 and Inc = 10, then the continuum would be the series 20, 30, 40, 50, 20, 30, etc, imagined as follows:
For example, if an individual's gene has the value 30, the complement would be 50 - the value that is opposite to it on the continuum circle.
To create the complement of an entire individual, the complementary value of each gene would be taken to create a new individual, as shown in the following example.
Chromosome
|
Genes
|
Min
|
Max
|
Inc
|
Individual
|
Complement
|
1
|
SlowLength
|
45
|
80
|
5
|
50
|
70
|
1
|
FastLength
|
20
|
60
|
5
|
35
|
55
|
2
|
ProfitTargetAmt
|
100
|
1000
|
100
|
500
|
1000
|
2
|
StopLossAmt
|
50
|
250
|
50
|
200
|
50
|
2
|
BreakevenFloorAmt
|
25
|
100
|
25
|
75
|
25
|
2
|
DollarTrailingAmt
|
20
|
100
|
10
|
50
|
90
|
2
|
PctTrailingFloorAmt
|
80
|
150
|
10
|
120
|
80
|
2
|
PctTrailingPct
|
1
|
10
|
1
|
8
|
3
|
2
|
ExitOnClose
|
0
|
1
|
1
|
1
|
0
|
Because of their complexity, very few genetic algorithms implement complements. We make them available to you in Optimax, and you can control their behaviour from the optimization settings screen alongside all of the other options.