# Numerical Algorithms in III-V Semiconductor Heterostructures
## 2 Materials and Methods
### The Used Genetic Algorithm  
The first algorithm used to optimize the problem of Equation (14) is a modification of the genetic algorithm. Genetic algorithms suggested by [PERSON] [34] are inspired by biology, and the algorithm initiates by formulating an initial population of potential solutions for any optimization problem. These solutions are also called chromosomes. The chromosomes are iteratively altered using the biologically inspired operations of selection, crossover, and mutation [35]. Genetic algorithms have been used in a variety of optimization problems, such as aerodynamic optimization [36], steel structure optimization [37], image processing problems [38], etc. Also, they have been used as the training methods of neural networks in a variety of papers, such as the paper of [PERSON] et al. [39] used to estimate the topology of neural networks. Also, they have been used to construct neural networks for daily rainfall runoff forecasting [40], evolving neural networks for the deformation modulus of rock masses [41], etc. The steps of the modified genetic algorithm are outlined below. 1. **Initialization Step** 1. **Set** with \(N_{C}\) the total number of chromosomes. 2. **Set** with \(N_{C}\) the total number of generations allowed. 3. **Define** with \(K\) the number of weights for the neural networks. 4. **Produce** randomly \(N_{C}\) chromosomes. Every chromosome consists of two equal parts. The first half represents the parameters of the artificial neural network \(N_{1}(x,\overrightarrow{w_{1}}\) and the second half represents the parameters of the artificial neural network \(N_{2}(x,\overrightarrow{w_{2}}\). The size of each part is set to \(3K\), where \(K\) is the number of weights. 5. **Set** as \(p_{s}\) the selection rate, with \(p_{s}\leq 1\). 6. **Set** as \(p_{m}\) the mutation rate, with \(p_{m}\leq 1\). 7. **Set** iter = 0. 2. **Fitness calculation Step** 1. **For**\(i=1,\ldots,N_{C}\), **do** 1. **Calculate** the fitness \(f_{i}\) of every chromosome \(g_{i}\). The chromosome consists of two equal parts. The first part (parameters in range \([1\ldots 3K]\) is used to represent the parameters of the artificial neural network \(N_{1}\) and the second part (parameters in range \([3K+1\ldots 6K]\) ) represents the parameters of the artificial neural network \(N_{2}\). The calculation of the fitness has the following steps: 1. Set \(w_{1}=g_{i}[1\ldots 3K]\), the first part of chromosome \(g_{i}\) 2. Set \(w_{2}=g_{i}[3K+1\ldots 6K]\), the second part of chromosome \(g_{i}\) 3. Set \(f_{i}\) the value for Equation (14) 2. **EndFor** 3. **Genetic operations step** 1. **Selection procedure. ** After sorting according to the fitness values, the first \((1-p_{s})\times N_{C}\) chromosomes with the lowest fitness values are copied to the next generation and the rest are replaced by offsprings produced during the crossover procedure. 2. **Crossover procedure**: Two new offsprings \(\bar{z}\) and \(\widehat{w}\) are created for every selected couple of \((z,w)\). The selection of \((z,w)\) is performed using the tournament selection. The new offsprings are produced according to the following: \[ \begin{array}{rcl}z_{i}&=&a_{i}z_{i}+(1-a_{i})w_{i}\\ \widehat{w_{i}}&=&a_{i}w_{i}+(1-a_{i})z_{i}\end{array} \] (15) The value \(a_{i}\) is a random number, where \(a_{i}\in[-0.5,1.5]\)[42]. 3. **Perform** the mutation procedure: For every element of each chromosome, a random number number \(r\in[0,1]\) is drawn. If \(r\leq p_{m}\), then this element is altered randomly. 4. **Termination Check Step** 1. **Set**\(iter=iter+1\) 2. **The termination rule used here was initially proposed in the work of [PERSON] [43]. The algorithm computes the variance of the best-located fitness value at every iteration. If no better value was discovered for a number of generations, then this is a good evidence that the algorithm should terminate. Consider \(f(g_{\mbox{best}})\) as the best fitness of the population and \(\sigma^{(\mbox{iter})}\) as the associated variance at generation iter.