*3.7. Selection Operation*

After the crossover operation, the trial quantum individuals will be transformed into binary individuals by observation and reparation, as discussed in Section 3.4. The population of trial quantum individuals *Q*<sup>C</sup>(*t*) is transformed into a population of trial binary individuals *P*<sup>C</sup>(*t*) = *X*C*<sup>t</sup>* 1, *X*C*<sup>t</sup>* 2,..., *X*C*<sup>t</sup> n* .

The selection operation generates the individuals of next iteration *Xt*+<sup>1</sup> *i* between the current individuals *Xti*and the trial binary individuals *X*C*<sup>t</sup> i*, as follows:

$$X\_{i}^{t+1} = \begin{cases} X\_{i}^{\text{Ct}} \text{ if } (f(X\_{i}^{\text{Ct}}) > f(X\_{i}^{t})) \\\ X\_{i\prime}^{t} \text{ if } (f(X\_{i}^{\text{Ct}}) \le f(X\_{i}^{t})) \end{cases} \tag{14}$$

The quantum individuals of the next iteration are generated by:

$$q\_{\theta i}^{t+1} = \begin{cases} \begin{array}{c} q\_{\theta i}^{\mathrm{Ct}} \text{ if } (f\left(X\_i^{\mathrm{Ct}}\right) > f\left(X\_i^t\right)) \\ \text{update } q\_{\theta i}^t \text{ by } R\_{\mathrm{GWO}} \text{ if } (f\left(X\_i^{\mathrm{Ct}}\right) \le f\left(X\_i^t\right)) \end{array} \tag{15}$$

where *R*GWO is a quantum rotation gate (QRG) with an adaptive GWO. *R*GWO is presented in Section 3.8.

#### *3.8. Quantum Rotation Gate with Adaptive GWO*

The quantum rotation gate *<sup>U</sup>*(*<sup>θ</sup>i*) is used to update the values of the qubits in a quantum individual as follows [36]:

$$\mathcal{U}(\theta\_i) = \begin{bmatrix} \cos(\theta\_i) & -\sin(\theta\_i) \\ \sin(\theta\_i) & \cos(\theta\_i) \end{bmatrix} \tag{16}$$

The quantum individuals of the next iteration after quantum rotation are presented as:

$$
\begin{bmatrix} a'\_{i} \\ \beta'\_{i} \end{bmatrix} = \begin{bmatrix} \cos(\theta\_{i}) & -\sin(\theta\_{i}) \\ \sin(\theta\_{i}) & \cos(\theta\_{i}) \end{bmatrix} \begin{bmatrix} a\_{i} \\ \beta\_{i} \end{bmatrix} \tag{17}
$$

where *θi* = *<sup>s</sup>*(*<sup>α</sup>iβi*)Δ*θi* is the rotation angle of the QRG, and *<sup>s</sup>*(*<sup>α</sup>i βi*) is the direction signal of the rotation angle.

The polar plot of the QRG for qubits is illustrated in Figure 3, and the quantum rotation angle parameters used in [36] are shown in Table 1.

**Figure 3.** Polar plot of quantum rotation gate for qubit.

**Table 1.** Lookup table of rotation angle.


Where *f*(.) is the profit; *<sup>s</sup>*(*<sup>α</sup>i βi*) is the direction sign of rotation angle; and *xi* and *bi* are the *i*th bits of the binary solution *x* and the best solution b, respectively.

Generally speaking, the core concept of the quantum rotation gate is to motivate the probability amplitudes of each qubit in quantum individuals to converge to the corresponding bits of the current best solution in the population. Realistically, the lookup table is a convergence strategy. In this strategy, the fitness *f(x)* of the binary solution *x* after quantum observation is compared with the fitness *f(b)* of the current best solution *b*. The quantum rotation gate will update the probability amplitude (*<sup>α</sup>i*, *βi*) toward the direction that favors the emergence of the better solution between *x* and *b*. For example, if *xi* = 0 and *bi* = 1, and *f*(*xi*) > *f*(*bi*), then *xi* is the current best solution. This means that the state |0 is the optimal state for the *i*th qubit of a quantum individual, and that the QRG will update (*<sup>α</sup>i*, *βi*) to increase the probability of the state |0 to make the probability amplitude evolve toward the direction benefiting the appearance of *xi* = 0. If (*<sup>α</sup>i*, *βi*) is located in the first quadrant as shown in Figure 2, the quantum rotation is in a clockwise direction, which favors *xi*= 0.

Normally, quantum rotation can bring the quantum chromosomes closer to the current optimal chromosomes and generate the exploitation near the current optimal solution to find better solutions. As with other metaheuristic algorithms, individuals of the population converge more closely to the best solution after quantum rotation. The QRG makes the population evolve continuously and speeds up the convergence of the algorithm.

The magnitude of Δ*θi* determines the granularity of the search and should be chosen appropriately. A too-small value of the rotation angle will affect the convergence speed and may even lead to a stagnant state. However, if the value is too large, the solutions may diverge or converge prematurely to a local optimal solution [37].

The traditional QRG requires predefined rotation angles, and the value and direction of *θi* should be designed for specific application problems. Because the values of quantum rotation angles are dependent on the problems, the verification of angle selection becomes important, although tedious, work when traditional QRGs are used for optimization problems. If the quantum rotation angles can be obtained adaptively without relying on predefined data, the efficiency of the QRG will be greatly improved, while the types of applications with the QRG can be easily increased. This is exactly what metaheuristic algorithms are good at. Of the large number of metaheuristics, the GWO is a novel swarm optimization algorithm motivated by the social behavior of grey wolves. Because the GWO has the advantages of simple principles, fast searching speed, high seeking accuracy, and easy implementation, it can be easily combined with practical engineering problems [58]. Therefore, the GWO has high theoretical research value and application value, and becomes suitable for generating quantum rotation angles.

In addition, the traditional QRG motivates the probability amplitudes of each qubit in quantum individuals to converge to the corresponding bits of the current best solution in the population. If the current best solution is not the global optimal solution, the direction of quantum rotation may be far from the global optimal solution, and the algorithm may be trapped in local optimal stagnation. Since the GWO records multiple best individuals, it is useful for the QRG to jump out of local optimum with the GWO.

In the proposed QDGWO algorithm, the rotation angle of the QRG is determined with an adaptive GWO. This is described as follows: In the original GWO algorithm, the positions of other *ω* wolves are updated by the distance vector between themselves and the three best wolves, while for the *α*, *β*, and *δ* wolves, they can hunt the prey more freely. The hunting zone for *α*, *β*, and *δ* wolves will become smaller during the iteration. In the adaptive GWO, these features of the GWO will be inherited and developed.

For a quantum rotation gate with an adaptive GWO ( *R*GWO),Δ*θtij* is calculated using the position of *α*, *β*, and *δ* wolves as follows:

$$
\Delta \theta\_{i\dot{j}}^t = \theta \cdot \left\{ \gamma\_i^a \left( X\_{a\dot{j}}^t - X\_{i\dot{j}}^t \right) + \gamma\_i^\beta \left( X\_{\dot{\beta}\dot{j}}^t - X\_{i\dot{j}}^t \right) + \gamma\_i^\delta \left( X\_{\delta j}^t - X\_{i\dot{j}}^t \right) \right\} \tag{18}
$$

where *i* ∈ {1, 2, 3, . . . , *n*}; *j* ∈ {1, 2, 3, . . . , *m*}; *n* is the size of the population; *m* is the number of items; *θ* is the rotation angle magnitude; *Xtij* is the *j*th component in the binary individual of the *i*th wolf during *t*th iteration; and *γ<sup>α</sup> i* , *γβ i* and *γδ i* are determined by comparing the fitnessofthecurrentbinaryindividualwith*α*,*β*,and*δ*wolvesasfollows:

$$\gamma\_i^a = \begin{cases} \frac{f(\mathbf{X}\_n^t)}{f(\mathbf{X}\_i^t)'} \text{ if } f(\mathbf{X}\_i^t) < f(\mathbf{X}\_n^t) \\\frac{N(0,1) \times t\_{\text{max}}}{k(t\_{\text{max}}+t)}, \text{ otherwise} \end{cases} \tag{19}$$

$$\gamma\_i^{\mathcal{S}} = \begin{cases} \frac{f\left(\mathbf{X}\_{\beta}^t\right)}{f\left(\mathbf{X}\_i^t\right)}, \text{ if } f\left(\mathbf{X}\_i^t\right) < f\left(\mathbf{X}\_{\beta}^t\right) \\ \frac{\mathbf{N}\left(\bullet\right) \times t\_{\text{max}}}{k\left(t\_{\text{max}} + t\right)}, \text{ otherwise} \end{cases} \tag{20}$$

$$\gamma\_i^{\delta} = \begin{cases} \frac{f\left(\mathbf{X}\_{\delta}^t\right)}{f\left(\mathbf{X}\_i^t\right)}, \text{ if } f\left(\mathbf{X}\_i^t\right) < f\left(\mathbf{X}\_{\delta}^t\right) \\ \frac{N\left(0,1\right) \times t\_{\text{max}}}{k\left(t\_{\text{max}} + t\right)}, \text{ otherwise} \end{cases} \tag{21}$$

where *N*(0,1) is the Gaussian distribution, *μ* = 0, *σ* = 1.

For the *ω* wolves, they hunt the prey based on their own positions vs. the positions of the three best wolves. It is obvious that for the *i*th wolf in the *ω* wolves group, *f X<sup>t</sup> i* < *f X<sup>t</sup> δ* ≤ *f X<sup>t</sup> β* ≤ *f X<sup>t</sup> α* . Therefore, the rotation angle of the *i*th wolf can be calculated with the binary individuals of *α*, *β*, *δ*, and the *i*th wolf.

For *α*, *β*, and *δ* wolves, they have the duty of searching for the optimal solution from their old positions. With increasing *t*, *γ<sup>α</sup> i* , *γβ i* and *γδ i* will be much smaller in the late stages of the iteration than what they are in the early stages of the iteration, which helps the *ω* wolves converge toward an estimated position of prey calculated by *α*, *β*, and *δ* wolves. This strategy is helpful for jumping out of local optimal stagnation, especially in the final stage of iterations.

The speed of convergence and quality of the solution are greatly affected by the magnitude of the rotation angle *θ*, which is given by:

$$\begin{aligned} \theta &= \theta\_{\text{min}} + \left(1 - \frac{t}{l\_{\text{max}}}\right) \cdot (\theta\_{\text{max}} - \theta\_{\text{min}})\\ 0 &< \theta\_{\text{min}} < \theta\_{\text{max}} \end{aligned} \tag{22}$$

where *θ* is linearly decreasing from *θ*max to *θ*min during the iteration. In the end, *q<sup>t</sup>*+<sup>1</sup> *θi*can be generated by:

$$
\theta\_{\rm ij}^{t+1} = \theta\_{\rm ij}^t + s\_{\rm ij}^t \Delta \theta\_{\rm ij}^t \tag{23}
$$

where *stij*is the direction signal of the rotation angle as follows:

$$s\_{ij}^t = \begin{cases} \quad 1, \text{ if } \theta\_{ij}^t \in (0, \frac{\pi}{2}) \cup (\pi, \frac{3\pi}{2})\\\quad -1, \text{ if } \theta\_{ij}^t \in (\frac{\pi}{2}, \pi) \cup (\frac{3\pi}{2}, 2\pi) \\\qquad \pm 1, \text{ otherwise} \end{cases} \tag{24}$$

With the adaptive strategy of *γ* and *θ*, the searching granularity of the QDGWO changes from coarse to fine. A different searching granularity in the iteration will facilitate the process for search agents to reach the global optimal solution.

#### *3.9. Procedure of QDGWO Algorithm*

Based on the description above, the procedure of the QDGWO and its main steps can be summarized as shown in Algorithm 2.


#### *3.10. Example of QDGWO Algorithm to Solve KP01*

In the following, a KP01 problem is described as an example to be solved by the QDGWO algorithm.

Given a set of ten items, *W* = (*<sup>x</sup>*1, *x*2, *x*3, ... , *x*10), and *wi* is the weight of the *i*th item *xi*; *p*i is the value of *xi*; and *C* is the weight capacity of the knapsack. Suppose that *wi* = *i*, and *pi* = *wi*+5, and *C* = 12 *m*∑ *i*=1 *wi* = 27.5.

Then, this 0-1 knapsack problem can be defined as:

$$\begin{aligned} \text{Maximize } f(\mathbf{x}) &= \sum\_{i=1}^{m} p\_i \mathbf{x}\_i \\ \text{s.t. } \sum\_{i=1}^{m} w\_i \mathbf{x}\_i &\le 27.5, \mathbf{x}\_i \in \{0, 1\}, \forall i \in \{1, 2, \dots, 10\} \end{aligned} \tag{25}$$

where *wi* = *i*, and *pi* = *wi* +5= *i* + 5.

In this example, the population size was set to 20, and the maximum number of iterations was set to 200. The other parameters are presented in Table 2. The evolution process of *q*1, an individual of the quantum population, is shown below.


**Table 2.** Parameters of algorithms in experiments.

The initial quantum population *Q*(0) = *q*0 1, *q*0 2,..., *q*020 was initialized by Equations (5) and (6). The vector *qθ*1 was initialized by *q*0 *θ*1 = 3*π* 4 , *π* 4 , 5*π* 4 , 7*π* 4 , 5*π* 4 , 7*π* 4 , 3*π* 4 , *π* 4 , 5*π* 4 , *π* 4 , and the quantum individual *q*0 1 was initialized by *q*0 1 = \$ − √2 √2 2 2 ! ! ! ! ! √2 √2 2 2 ! ! ! ! ! − √2 2 − √2 2 ! ! ! ! ! √2 2 − √2 2 ! ! ! ! ! − √2 2 − √2 2 ! ! ! ! ! √2 2 − √2 2 ! ! ! ! ! − √2 √2 2 2 ! ! ! ! ! √2 √2 2 2 ! ! ! ! ! − √2 2 − √2 2 ! ! ! ! ! √2 √2 2 2 % . After quantum observation, the binary individual *X*<sup>0</sup> 1 was generated as (1,0,1,1,0,0,1,0,0,<sup>1</sup>),andthefitnessof *X*<sup>0</sup> 1wasevaluatedas *f X*<sup>0</sup> 1 = 10 ∑ *pix*<sup>0</sup> *i*= 50.

 The mutation vector *q*M0 *θ*1 was generated by Equations (8)–(11), where t = 0; *ω* = *e* 1− *t*max *t*max−*t* = 1; and *F*<sup>0</sup> = *F*0 + *F*1 · 2*ω* · rand(0, 1) = 0.02 + 0.03 × 2 × 0.68 = 0.0608 (rand(0,1) was randomly generated as 0.68).

*i*=1

The vector *qθα* corresponding to the current best binary individual *Xα* and two different random target vectors *qθr*<sup>1</sup> and *qθr*<sup>2</sup> are shown as:

$$q\_{\theta\kappa} = \left(\frac{\pi}{4}, \frac{3\pi}{4}, \frac{\pi}{4}, \frac{5\pi}{4}, \frac{7\pi}{4}, \frac{3\pi}{4}, \frac{\pi}{4}, \frac{\pi}{4}, \frac{\pi}{4}, \frac{3\pi}{4}, \frac{3\pi}{4}\right);$$

$$q\_{\theta r1} = \left(\frac{3\pi}{4}, \frac{7\pi}{4}, \frac{7\pi}{4}, \frac{5\pi}{4}, \frac{\pi}{4}, \frac{3\pi}{4}, \frac{5\pi}{4}, \frac{5\pi}{4}, \frac{\pi}{4}, \frac{\pi}{4}, \frac{7\pi}{4}\right);$$

$$q\_{\theta r2} = \left(\frac{7\pi}{4}, \frac{7\pi}{4}, \frac{3\pi}{4}, \frac{5\pi}{4}, \frac{\pi}{4}, \frac{5\pi}{4}, \frac{\pi}{4}, \frac{\pi}{4}, \frac{\pi}{4}, \frac{5\pi}{4}, \frac{3\pi}{4}\right).$$

The quantum mutation vector *q*M0 *θ*1was generated by:

$$\begin{array}{rcl}q\_{\theta1}^{\mathrm{M0}} &= q\_{\theta a} + F^0(q\_{\theta r1} - q\_{\theta r2})\\ &= (0.1892\pi, 0.75\pi, 0.3108\pi, 1.25\pi, 1.75\pi, 0.7196\pi, 0.3108\pi, 0.3108\pi, 0.6892\pi, 0.8108\pi)\end{array}$$

The quantum trial vector *qC*<sup>0</sup> *θ*1 at the *t*th generation was generated by Equations (12) and (13):

$$q\_{\theta1}^{\text{CO}} = (0.75\pi, 0.75\pi, 0.3108\pi, 1.75\pi, 1.25\pi, 1.75\pi, 0.3108\pi, 0.25\pi, 0.6892\pi, 0.25\pi)$$

where *CR* was randomly generated as 0.35, and *rnbr\_i* = 3.

After quantum observation, the trial binary individual *X*C0 1 was generated as (1, 0, 1, 1, 0, 0, 1, 0, 1, <sup>0</sup>), and the fitness was evaluated as *f XC*<sup>0</sup> 1 = 10∑ *i*=1 *pix*0*i* = 49. Because *f X*C*<sup>t</sup>* 1 < *f Xt*1, *q<sup>t</sup>*+1 should be updated by the QRG with an adaptive GWO.

The positions and profits of the current three best wolves were shown as:

$$\begin{aligned} \mathbf{X}\_{\boldsymbol{a}}^{0} &= (1, 1, 1, 0, 1, 1, 0, 1, 0, 0), \boldsymbol{f}(\mathbf{X}\_{\boldsymbol{a}}^{0}) = \sum\_{i=1}^{10} p\_{i} \mathbf{x}\_{i}^{0} = \mathbf{5} \mathbf{5}; \\\\ \mathbf{X}\_{\boldsymbol{\beta}}^{0} &= (1, 1, 1, 1, 1, 0, 0, 0, 1, 0), \boldsymbol{f}(\mathbf{X}\_{\boldsymbol{\beta}}^{0}) = \sum\_{i=1}^{10} p\_{i} \mathbf{x}\_{i}^{0} = \mathbf{5} \mathbf{4}; \\\\ \mathbf{X}\_{\boldsymbol{\delta}}^{0} &= (0, 1, 1, 0, 0, 1, 1, 0, 1, 0), \boldsymbol{f}(\mathbf{X}\_{\boldsymbol{\delta}}^{0}) = \sum\_{i=1}^{10} p\_{i} \mathbf{x}\_{i}^{0} = \mathbf{52}. \end{aligned}$$

Additionally, *θ* = *θ*min + 1 − *t t*max ·(*<sup>θ</sup>*max − *<sup>θ</sup>*min) = *θ*max = 0.03*π*; *γα*1 = *f*(*X*0*α*) *f*(*X*01 ) = 1.1; *γβ*1 = *<sup>f</sup>*(*X*0*β*) *f*(*X*01 ) = 1.08; *γδ*1 = *f*(*X*0*δ* ) *f*(*X*01 ) = 1.04.

Then, the quantum individual of the next iteration *q<sup>t</sup>*+<sup>1</sup> *θi* was generated by Equations (16)–(24) as:

$$\begin{array}{rcl} \Delta q\_{\theta 1}^{0} &= [\Delta \theta\_{11}^{0}, \Delta \theta\_{12}^{0}, \dots, \Delta \theta\_{110}^{0}] \\ &= [-0.0312\pi, 0.0966\pi, 0, -0.0642\pi, 0.0654\pi, 0.0642\pi, -0.0654\pi, 0.033\pi, 0.0636\pi, -0.0966\pi] \end{array}$$

$$q\_{\theta1}^{0} = \left(\frac{3\pi}{4}, \frac{\pi}{4}, \frac{5\pi}{4}, \frac{7\pi}{4}, \frac{5\pi}{4}, \frac{7\pi}{4}, \frac{3\pi}{4}, \frac{\pi}{4}, \frac{5\pi}{4}, \frac{\pi}{4}\right)$$

$$\begin{array}{rcl} q\_{\theta1}^1 &= q\_{\theta1}^0 + s\_1^0 \Lambda q\_{\theta1}^0 \\ &= (0.7812\pi, 0.3466\pi, 1.25\pi, 1.8142\pi, 1.3154\pi, 1.6858\pi, 0.8154\pi, 0.283\pi, 1.3136\pi, 0.1534\pi) \end{array}$$

The individuals of the next iteration continued to evolve until the maximum number of iterations was reached. After the iterations, the best profit of this KP01 problem was 57, and one of the best solutions was (0,1,1,1,1,1,1,0,0,0).
