# Neuroevolution for Parameter Adaptation in Differential Evolution
## 2 Materials and Methods
### Proposed Approach
First of all, Difference-Based Mutation (DBM), proposed in [55], was added, as it allows better fine-tuning of the weight coefficients. In addition, according to the conclusions of [45], the following activation functions were used:  
* Linear: equals \(z\);
* Negative: \(-z\);
* Absolute value: \(|z|\);
* Squared: \(z^{2}\);
* Unsigned step function: equals 1 if \(z>0\);
* Sigmoid: \(\frac{1}{1+e^{-z}}\);
* ReLU: \(max(0,z)\);
* Gaussian: \(e^{\frac{-2}{2}}\);
* Hyperbolic tangent: \(tanh(z)\);
* Sine: \(sin(\pi z)\);
* Cosine: \(cos(\pi z)\). Here, \(z\) is the sum of inputs to a certain node. The default function is linear, and the mutation may choose any of these functions with equal probability. ```
1:Set \(NP_{max}=23D\), \(NP=NP_{max}\)\(D\), \(NFE_{max}\),
2:\(H=20D\), \(A=\emptyset\), \(M_{F,r}=0.5\), \(M_{Cr,r}=0.9\), \(k=1\)
3:\(NA=NP\), \(p_{A}=0\), \(g=0\)
4: Initialize population \(P_{0}=(x_{1,j},\ldots,x_{NP,j})\) randomly
5:while\(NFE<NFE_{max}\)do
6:\(S_{F}=\emptyset\), \(S_{Cr}=\emptyset\), \(n_{A}=0\)
7: Sort and rank population according to fitness \(f(x_{i})\)
8:for\(i=1\) to \(NP\)do
9: Current memory index \(r=randInt[1,H+1]\)
10: Crossover rates \(Cr_{i}=randn(M_{Cr,r},0.1)\)
11:\(Cr_{i}=min(1,max(0,Cr))\)
12:repeat
13:\(F_{i}=randc(M_{F,r},0.1)\)
14:until\(F_{i}\geq 0\)
15:\(F_{i}=min(1,F_{i})\)
16:endfor
17:for\(i=1\) to \(NP\)do
18:repeat
19:\(pbest=randInt(1,NP*p)\)
20:\(r1=randInt(1,NP)\)
21:if\(rand[0,1]<p_{A}\)then
22:\(r2=randInt(1,NP)\)
23:else
24:\(r2=randInt(1,NA)\)
25:endif
26:until\(i\
eq pbest\
eq r1\
eq r2\)
27:for j=1 to D do
28:\(v_{i,j}=x_{i,j}+F(x_{pbest,j}-x_{i,j})+F(x_{r1,j}-x_{r2,j})\)
29:endfor
30: Binomial crossover with \(Cr\)
31: Calculate \(f(u_{i})\)
32:if\(f(u_{i})<f(x_{i})\)then
33:\(x_{i}\to A_{randInt[1,NA]}\), \(x_{i}=u_{i}\)
34:\(F\to S_{F}\), \(Cr\to S_{Cr}\), \(\Delta f_{i}=f(x_{i})-f(u_{i})\)
35:endif
36:endfor
37: Get \(NP_{g+1}\) and \(NA_{g+1}\) with NLPSR
38:if\(|A|>NA_{g+1}\)then
39: Remove random individuals from the archive
40:endif
41:if\(NP_{g}>NP_{g+1}\)then
42: Remove worst individuals from the population
43:endif
44: Update \(M_{F,k}\), \(M_{Cr,k}\)
45:\(p_{A}=|A|/NP\)
46:\(k=mod(k,H)+1\), \(g=g+1\)
47:endwhile
48: Return best solution \(x_{best}\)
```  
**Algorithm 2** NL-SHADE-RSP\({}_{s}\)  
The mutation step also included two additional mutation operations other than adding weight and adding a connection:  
* Mutating random node: The type of operation performed in a randomly chosen node is changed to another one, and the new innovation number is assigned to the node. * Assigning random weights: Every connection is mutated with a probability of \(1/NC\), and \(NC\) is the number of connections. The connection receives either weight chosen from \(randn(0,0.1)\) or \(randn(1,0.1)\). Otherwise, the current value of the weight is used as a mean value to generate new ones as follows: \(w=randn(w,0.01)\), where \(w\) is the current weight value. With a probability of \(1/NC\), each weight is either activated or deactivated. * Difference-based mutation, which utilizes the idea of difference vectors used in DE to mutate new weights. For this purpose, three individuals are selected: the target one with index \(i\) and two others with randomly chosen indices \(r1\) and \(r2\). The genes with the same innovation numbers are identified, and if they have different weights, they are marked as mutating. Next, the following equations are applied: \(w_{i,j}=w_{ij}+F_{NEAT}*(w_{r1,j}-w_{r2,j})\), where \(j\) is the index of matching genes, and \(F_{NEAT}=0.5\). In the NEAT algorithm used in this study, several mutation operations could be applied to the same individual. The probabilities of mutation were set as shown in Table 1, in accordance with the values used in [55]. The crossover operation was performed only for the weights, i.e., disjoint and excess genes were not added to the offspring, and each matching gene in the offspring received a weight value from one of the parents with equal probabilities.