*3.3. Initialization*

The general principle of superposition of quantum mechanics assumes that the original state must be considered as the result of a superposition of two or more other states in an infinite number of ways [57]. Therefore, the initial quantum individual is regarded as a superposition of all possible states. For 0-1 knapsack problems, each state represents a combination of selecting or rejecting items, and the initial quantum individual is required to generate every possible combination. For this, each vector *qθi* is initialized by:

$$q\_{\theta i}^{t=0} = \left(\left(\frac{\pi}{4}\right) \cdot r\_{i1}, \dots, \left(\frac{\pi}{4}\right) \cdot r\_{\text{int}}\right) \tag{5}$$

where *rij* = random{1,3,5,7}, which means *rij* is an odd integer generated randomly in the set *rij* ∈ {1, 3, 5, 7} while *θij* ∈ *π* 4 , 3*π* 4 , 5*π* 4 , 7*π* 4 . This means that for initial individuals, |cos(*θij*)|<sup>2</sup> = |sin(*θij*)|<sup>2</sup> = 1/2, so that the probabilities of selecting item *xi* and rejecting item *xi* are equal.

The initial quantum individual *q<sup>t</sup>*=<sup>0</sup> *i*which corresponds to *q<sup>t</sup>*=<sup>0</sup> *θi*can be given by:

$$q\_i^{t=0} = \begin{bmatrix} \cos\theta\_{i1}^0 & \cos\theta\_{i2}^0 & \dots & \cos\theta\_{im}^0\\ \sin\theta\_{i1}^0 & \sin\theta\_{i2}^0 & \dots & \sin\theta\_{im}^0 \end{bmatrix} \tag{6}$$

where *m* is the length of the qubit quantum individual.

*Q*(0) = *q*0 1, *q*0 2,..., *q*0 *n* is the initial quantum population, where *n* is the size of the population.

#### *3.4. Quantum Observation and Fitness Evaluation*

Based on the quantum superposition principle, a quantum state is a superposition of all possibly stationary states. The quantum superposition state will collapse to a stationary state by quantum observation. In the proposed QDGWO algorithm, the quantum superposition states are represented by quantum individuals, and the stationary states are represented through binary individuals. Before evaluating the fitness of individuals, quantum observation and reparation for quantum individuals *q* are required to receive binary individuals *X*, as shown in Algorithm 1.

After quantum observation, the fitness of binary individual *X* is evaluated as:

$$f\left(X\_i^t\right) = \sum\_{i=1}^m p\_i x\_i^t \tag{7}$$

**Algorithm 1** Quantum Observation and Reparation **Input:** quantum individuals *q* **Output:** binary individuals *X xi* ← 0 //Initialize the bits of individual *X* to 0. *<sup>w</sup>*total ← 0 // Initialize the total weights of the individuals to 0. **while** (*totalw* ≤ *C*) **do** *i* ← rand\_i[1, *m*] //Generate the random integer *i* ∈ {1, 2, . . . , *<sup>m</sup>*}. **if** (*xi* = 0) **then** *r* ← rand(0, 1) **if**(*r* > |cos(*θi*)|2) **then** *xi* ← 1 *<sup>w</sup>*total ← *<sup>w</sup>*total + *wi* //Select item *xi* and include the weight *wi* of item *xi* in the total weight *wtotal.* **end if end if end while** *xi* ← 0 *<sup>w</sup>*total ← *<sup>w</sup>*total − *wi* //The total weight *wtotal* has exceeded the capacity *C* when the loop is ended,soitem *xi*needstobeextractedfromtheselecteditemsforreparation.

#### *3.5. Adaptive Mutation Operation with Dynamic Iteration Factor*

The mutation operation is one of the main operations in differential evolution. In the QDGWO, DE/best/2, proposed by Price and Storn [44], is used to select parent vectors. In this strategy, the mutation vector *q*M*<sup>t</sup> θi* is generated by the vector *qθα* corresponding to the current best binary individual *Xα* and the difference between two different target vectors *qθr*<sup>1</sup> and *qθr*<sup>2</sup> which are randomly selected. This difference is weighted by the differentiation control factor *F*.

The quantum mutation vector *q*M*<sup>t</sup> θi*at the *t*th generation can be generated by:

$$q\_{\theta i}^{\rm Mt} = q\_{\theta \alpha} + F^t (q\_{\theta r1} - q\_{\theta r2}) \tag{8}$$

where *r*1 ∈ {1, 2, . . . , *m*} and *r*1 = *i*;*r*2 ∈ {1, 2, . . . , *m*} and *r*2 = *i*;*r*1 = *r*2.

To improve the performance of differential operations in different phases, we propose an adaptive strategy to determine the differentiation control factor *F* with the iteration of evolution:

$$F^t = F\_0 + F\_1 \cdot \mathcal{Z}^{\omega} \cdot \text{rand}(0, 1) \tag{9}$$

$$
\omega = e^{1 - \frac{l \text{max}}{l \text{max} - l}} \tag{10}
$$

where *F*0 is the initial differentiation control factor, and *F*1 is the adaptive f differentiation control factor. *t*max is the maximum iteration number of the algorithm.

With this adaptive strategy, in the early stage of the iteration, the smaller *t* will be proposed with a larger *<sup>F</sup>t*, which is beneficial for attaining good diversity of individuals for global searching. *Ft* will be smaller and smaller during the iteration. In the late stages, *Ft* is close to *F*0, which aids in local searching for the global optimal solution.

The quantum mutation individual *q*M*<sup>t</sup> i* corresponding to the quantum mutant vector *q*M*<sup>t</sup> θi*can be obtained by:

$$q\_i^{\mathbf{M}t} = \begin{bmatrix} \cos\theta\_{i1}^{\mathbf{M}t} & \cos\theta\_{i2}^{\mathbf{M}t} \\ \sin\theta\_{i1}^{\mathbf{M}t} & \sin\theta\_{i2}^{\mathbf{M}t} \end{bmatrix} \cdot \dots \cdot \begin{bmatrix} \cos\theta\_{im}^{\mathbf{M}t} \\ \sin\theta\_{im}^{\mathbf{M}t} \end{bmatrix} \tag{11}$$

where *m* is the length of the qubit quantum individual.

The quantum mutation population *Q*<sup>M</sup>(*t*)=(*q*M*<sup>t</sup>* 1 , *q*M*<sup>t</sup>* 2 , ... , *q*M*<sup>t</sup> n* ) is made up of the quantum mutation individuals at the *t*th generation, where *n* is the size of the population.
