Crossover and Mutation Probability
There are two basic parameters of GA - crossover probability and mutation probability.
Crossover probability: how often crossover will be performed.
If there is no crossover, offspring are exact copies of parents. If there is
crossover, offspring are made from parts of both parent's chromosome. If crossover
probability is 100%, then all offspring are made by crossover. If it
is 0%, whole new generation is made from exact copies of chromosomes
from old population (but this does not mean that the new generation is the
same!).
Crossover is made in hope that new chromosomes will contain good parts of old
chromosomes and therefore the new chromosomes will be better. However, it is good
to leave some part of old population survive to next generation.
Mutation probability: how often parts of chromosome will be mutated.
If there is no mutation, offspring are generated immediately after crossover
(or directly copied) without any change. If mutation is performed,
one or more parts of a chromosome are changed. If mutation
probability is 100%, whole chromosome is changed, if it is 0%,
nothing is changed.
Mutation generally prevents the GA from falling into local extremes.
Mutation should not occur very often, because then GA will in fact change to random
search.
Other Parameters
There are also some other parameters of GA. One another particularly important parameter is population size.
Population size: how many chromosomes are in population (in one generation). If there are too few chromosomes, GA have few possibilities to perform crossover and only a small part of search space is explored. On the other hand, if there are too many chromosomes, GA slows down. Research shows that after some limit (which depends mainly on encoding and the problem) it is not useful to use very large populations because it does not solve the problem faster than moderate sized populations.
Some recommendations for all parameters can be found in one of the following chapters.
Example
Here you can see example similar to previous one. But here you can try to change crossover and mutation probability. You can also control elitism.
On the graph below you can see performance of GA. Red is the best solution, blue is average value (fitness) of all population.
Try to change parameters and look how GA behaves.
Question: If you try to increase mutation probability to 100%, GA will start to behave very strange, nearly like if the mutation probability is 0%. Do you know why? You can use a hint and if you still do not know, look at solution!