Function PGARealMutation
Defined in File real.c
Function Documentation
-
int PGARealMutation(PGAContext *ctx, int p, int pop, double mr)
Randomly mutates a floating point string with probability mr.
Description
Three of the four mutation operators are of the form \(v = v +- p \cdot v\). That is, the new value of \(v\) (allele \(i\)) is the old value + or - a percentage, \(p\), of the old value. There are three possibilities for choosing \(p\): (1) constant value (0.01 by default), (2) selected uniformly on \((0,\text{UB})\) (UB is .1 by default), and (3) selected from a Gaussian distribution (with mean 0 and standard deviation .1 be default). The change to an allele, \(p \cdot v\), is added or subtracted to the old value with a probability of .5. The fourth option is to replace \(v\) with a value selected uniformly random from the initialization range of that gene. Alleles to mutate are randomly selected. The value set by the routine
PGASetMutationRealValue()
is used as \(p\), UB, and sigma in cases 1, 2, and 3, respectively.Note that this function is set in
PGASetUp()
as the mutation user function for the real datatype by default.Example
Mutate string
p
in populationPGA_NEWPOP
with probability 0.001.PGAContext *ctx; int NumMutations, p; ... NumMutations = PGARealMutation (ctx, p, PGA_NEWPOP, .001);
- Parameters:
ctx – context variable
p – string index
pop – symbolic constant of the population string p is in
mr – probability of mutating a real-valued gene
- Returns:
The number of mutations performed