# Quantum Selection for Genetic Algorithms Applied to Electromagnetic Design Problems
## 2 Genetic Algorithm with Quantum Selection  
The algorithm begins with the standard GA with elitism, as presented in Algorithm 1. This version serves as the foundation for the quantum-classical evolutionary optimization algorithm introduced later, and also provides a reference for performance comparison. The operators used are well-known and commonly applied, specifically tournament selection, heuristic crossover, and uniform mutation. These operators are detailed in Algorithms 2, 3, and 4 respectively. ```
1 Population creation
2 whileterminal condition not metdo
3 Fitness evaluation
4 Selection operator
5 Crossover operator
6 Mutation operator
7 Offspring trimming
8 Add best individual to offspring
9 Population \(\leftarrow\) Offspring
```  
**Algorithm 1**Genetic algorithm. Trimming the offspring may be necessary because the number of generated offspring does not always equal the original population size. This trimming process involves randomly selecting a number of offspring to match the population size. Next, the best individual from the previous generation is inserted into the offspring population by replacing a random individual. This introduces elitism, which has been shown to improve GA performance in various scenarios [12]. ```
1 while Parents is not fulldo
2 Select \(k\) individuals randomly from the population \(best\leftarrow\) first individual in the tournament for\(j\gets 1\) to \(k\)do
3 if\(\mathit{Fitness}(\mathit{individual}[j])<\mathit{Fitness}(\mathit{best})\)then
4\(best\gets\mathit{individual}[j]\)
5 Copy best to Parents
```  
**Algorithm 2**Tournament selection operator. Tournament selection forms random pools to reduce the likelihood of always selecting the best individual as a parent. This increases genetic diversity without sacrificing selection pressure. However, this method can lead to multiple copies of the same individual being selected, which may increase the risk of population stagnation. ```
1\(n\gets 0\)for\(i\gets 1\)to Parents sizedo
2 for\(j\gets 1\)to Parents sizedo
3 if\(i\
eq j\)then
4\(\mathbf{a}\leftarrow \begin{bmatrix}a_{1}&a_{2}&\cdots&a_{\text{dim}}\end{bmatrix} \), where \(a_{i}\sim\mathcal{U}(0,1)\), \(i=\{1,2,\cdots,dim\}\)
5 Offspring\([n]\leftarrow\mathbf{a}\circ\text{Parent}[i]+(\mathbf{1}-\mathbf{a})\circ\text{Parent}[j]\)
6 Offspring\([n+1]\leftarrow\mathbf{a}\circ\text{Parent}[j]+(\mathbf{1}-\mathbf{a})\circ \text{Parent}[i]\)
7\(n\gets n+2\)
```  
**Algorithm 3**Heuristic crossover operator. Heuristic crossover is a simple yet effective method that ensures all offspring are generated along the line segments connecting parent pairs. It is especially useful in convex problems or non-convex problems, where the minimum is surrounded by several local minima. However, it lacks strong exploratory capability. ```
1 for\(i\gets 1\)to\(Offspring\) sizedo
2 if\(\mathcal{U}(0,1)<\mathit{mutation}\) ratethen
3\(b\gets\mathit{int}(\mathcal{U}(1,dim))\)
4 Offspring\([i][b]\leftarrow\mathcal{U}(bounds)\)
```  
**Algorithm 4**Uniform mutation operator. When an individual is selected for mutation, the uniform mutation operator randomly reassigns one of its genes with a new value, uniformly drawn from within the search space. The uniform probability density function (PDF) enhances exploratory capabilities in the early generations, but it reduces convergence speed as the population nears the optimum. In GAQS, the tournament selection operator is replaced by a hybrid quantum-classical selection operator called the quantum selection operator (QSO), presented in Algorithm 5. This operator first sorts the population by fitness and assigns quantum states ranging from \(|1\cdots 1\rangle\) to \(|0\cdots 0\rangle\) to each individual. This mapping links individuals with quantum states. Next, the \(k_{e}\) worst individuals are removed and replaced with new random individuals. This step boosts genetic diversity in the population. Parent selection proceeds by measuring a quantum circuit (QC), which determines which individual is selected as a parent.