| Data: Chromosome |
| Result: Mutated chromosome |
| begin |
| /*Calculate the decay rate */ |
| decayRate = 1(gen+maxGen*factor)/maxGen |
| /*Calculate the mutation rate, |
| inverse to the fitness */ |
| muP = (1-chr.Ftn/bestFtn) |
| /*Adjust the mutation rate if it is |
| below the minimum */ |
| if then |
| muP = minRate |
| end |
| /*Apply the decay to the mutation |
| rate */ |
| muP = muP * decayRate |
| /*Determine if mutation will occur |
| */ |
| if then |
| /* Randomly decide to grow or |
| shrink */ |
| growChromosome = DoCoinToss() |
| if then |
| /*Grow the chromosome by |
| adding a new gene */ |
| insertionPoint = GetRnd(0, chr.NGenes) |
| InsertGeneAt(insertionPoint) |
| else |
| /*Shrink the chromosome by |
| deleting a gene, but only |
| if we have at least two |
| genes */ |
| if then |
| deletionGene = GetRnd(1, |
| chr.NGenes) |
| DeleteGeneAt(deletionGene) |
| end |
| end |
| end |
| end |