# Mutation Algorithms for Real-Valued Parameters (GA)

Genetic Algorithms(GAs) are adaptive heuristic search algorithms that belong to the larger part of evolutionary algorithms. In each generation chromosomes(our solution candidates) undergo mutation and crossover and selection to produce a better population whose chromosomes are nearer to our desired solution. Mutation Operator is a unary operator and it needs only one parent to work on. It does so by selecting a few genes from our selected chromosome (parent) and then by applying the desired mutation operator on them.

In this article, I will be talking about four Mutation Algorithms for real-valued parameters –

1) Uniform Mutation

2) Non-Uniform

3) Boundary Mutation

4) Gaussian Mutation

Here ,we are considering a chromosome with n real numbers (which are our genes) and x_{i} represents a gene and i belongs to [1,n].

**Uniform Mutation –**

In uniform mutation we select a random gene from our chromosome, let’s say x_{i} and assign a uniform random value to it.

Let x_{i} be within the range [a_{i},b_{i}] then we assign U(a_{i},b_{i}) to x_{i}

U(a_{i},b_{i}) denotes a uniform random number from within the range [a_{i},b_{i}].

Algorithm – 1. Select a random integer number i from [1,n] 2. Set x_{i}to U(a_{i},b_{i}).

**Boundary Mutation –**

In boundary mutation we select a random gene from our chromosome , let’s say x_{i} and assign the upper bound or the lower bound of x_{i} to it.

Let x_{i} be within the range [a_{i},b_{i}] then we assign either a_{i} or b_{i} to x_{i}.

We also select a variable r= U(0,1) ( r is a number between 0 and 1).

If r is greater than or equal to 0.5 , assign b_{i} to x_{i} else assign a_{i} to x_{i}.

Algorithm – 1. select a random integer number i form [1,n] 2. select a random real value r from (0,1). 3. If(r >= 0.5) Set x_{i}to b_{i}else Set x_{i}to a_{i}

**Non-Uniform Mutation –**

In non-uniform mutation we select a random gene from our chromosome, let’s say x_{i} and assign a non-uniform random value to it.

Let x_{i} be within the range [a_{i},b_{i}] then we assign a non-uniform random value to it.

We use a function,

f(G)=(r2*(1-G/Gmax))b ,

where r2 = a uniform random number between (0,1)

G = the current generation number

Gmax = the maximum number of generations

b = a shape parameter

Here we select a uniform random number r1 between (0,1).

If r greater than or equal to 0.5 we assign (b_{i}-x_{i}) * f(G) to x_{i} else we assign (a_{i}+ x_{i}) * f(G).

Algorithm – 1. Select a random integer i within [1,n] 2. select two random real values r1 ,r2 from (0,1). 3. If(r1 >= 0.5) Set xi to (b_{i}-x_{i}) * f(G) else Set xi to (a_{i}+ x_{i}) * f(G)

**Gaussian Mutation –**

Gaussian Mutation makes use of the Gauss error function . It is far more efficient in converging than the previously mentioned algorithms. We select a random gene let’s say x_{i} which belongs to the range [a_{i},b_{i}]. Let the mutated off spring be x’_{i}. Every variable has a mutation strength operator (σ_{i}). We use σ= σ_{i}/(b_{i}-a_{i}) as a fixed non-dimensionalized parameter for all n variables;

Thus the offspring x’_{i} is given by —

x’_{i}= x_{i}+ √2 * σ * (b_{i}-a_{i})erf^{-1}(u’_{i})

Here erf() denotes the Gaussian error function.

erf(y)=^{2}⁄_{√π}∫^{y}_{0}e^{-t2}dt

For calculation u_{i}’ we first select a random value u_{i} from within the range (0,1) and then use the following formula

if(u_{i}>=0.5) u’_{i}=2*u_{L}*(1-2*u_{i}) else u’_{i}=2*u_{R}*(2*u_{i}-1)

Again u_{L} and u_{R} are given by the formula

u_{L}=0.5(erf(^{(ai-xi)}⁄_{(√2(bi-ai)σ)})+1) u_{R}=0.5(erf(^{(bi-xi)}⁄_{(√2(bi-ai)σ)})+1)

References —

1.https://www.iitk.ac.in/kangal/papers/k2012016.pdf

2.https://en.wikipedia.org/wiki/Mutation_(genetic_algorithm)

3.http://read.pudn.com/downloads152/ebook/662702/gaotv5.pdf

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer **Complete Interview Preparation Course****.**

In case you wish to attend **live classes **with experts, please refer **DSA Live Classes for Working Professionals **and **Competitive Programming Live for Students**.