# A Quantum-Inspired Predator-Prey Algorithm for Real-Parameter Optimization
## 3 Quantum Predator-Prey Algorithm
### Algorithm  
We present QPPA in the framework shown in Figure 1, which is further described in Algorithm 1, featuring a _population_ and _predator_ and _prey subpopulations_. The predator subpopulation represents a process that actively seeks to improve a solution. Similar to a predator in an ecological setting hunting for prey, the predator creates better solutions by exploiting the prey subpopulation. During the process of the creation of new individuals in the population, in the first phase, we model the movement of the quantum predator toward the prey through Equations (14)-(32). We provide further details on how we derived Equation (7) in Section 3.2. Similar to an ecological setting where the prey tries to avoid capture, as shown in Figure 1, the prey hides in the _shelter_ that is represented as a subpopulation in transition, leading to further improvement. We begin with population \(X\) of \(N\)_individuals_ with \(M\) decision variables (parameters) that are initialized randomly as shown in Equation (1), where \(x_{i,d}\) signifies the \(d\)-th decision variable of the \(i\)-th member of the population. \[X= \begin{bmatrix}\mathbf{x}_{1}\\ \vdots\\ \mathbf{x}_{i}\\ \vdots\\ \mathbf{x}_{N}\end{bmatrix} = \begin{bmatrix}x_{1,1}&\cdots&x_{1,d}&\cdots&x_{1,M}\\ \vdots&&\vdots&&\vdots\\ x_{i,1}&\cdots&x_{i,d}&\cdots&x_{i,M}\\ \vdots&&\vdots&&\vdots\\ x_{N,1}&\cdots&x_{N,d}&\cdots&x_{N,M}\end{bmatrix}  \tag{1}\]  
We then select each individual from population \(X\) and compute the fitness score \(F_{i}\) based on the _objective function_. We represent the set of fitness values for the entire population as shown in Equation (2). \[F= \begin{bmatrix}F_{1}\\ \vdots\\ F_{i}\\ \vdots\\ F_{N}\end{bmatrix}  \tag{2}\]  
We then sort population \(X\) based on the fitness values in increasing order. \(X^{*}\) and \(F^{*}\) correspond to the sorted population matrix and the sorted fitness vector, respectively, as shown in Equations (3) and (4). Figure 1: QPPA framework highlighting the different stages of the evolution process with predator and prey subpopulations. \[X^{*}= \begin{bmatrix}\mathbf{x}_{1}^{*}\\ \vdots\\ \mathbf{x}_{i}^{*}\\ \vdots\\ \mathbf{x}_{N}^{*}\end{bmatrix} = \begin{bmatrix}x_{1,1}^{*}&\cdots&x_{1,d}^{*}& \cdots&x_{1,M}^{*}\\ \vdots&&\vdots&&\vdots\\ x_{i,1}^{*}&\cdots&x_{i,d}^{*}&\cdots&x_{i,M}^{*}\\ \vdots&&\vdots&&\vdots\\ x_{N,1}^{*}&\cdots&x_{N,d}^{*}&\cdots&x_{N,M}^{*}\end{bmatrix}  \tag{3}\]  
\[F^{*}= \begin{bmatrix}F_{1}^{*}&min(F)\\ &\vdots\\ &F_{i}^{*}\\ &\vdots\\ F_{N}^{*}&max(F)\end{bmatrix}  \tag{4}\]  
We then update the predator subpopulation \(\Omega\) of \(N_{pd}\) individuals and prey subpopulation \(\Sigma\) of \(N_{py}\) individuals by dividing the sorted population \(X^{*}\). The prey subpopulation consists of solutions with lower fitness values (Equation (5)), while the predator population consists of solutions with higher fitness values (Equation (6)), as highlighted in Algorithm 1 and Figure 1.  
```
Input: decision variables, fitness function, and problem constraints. * Define hyperparameters, i.e., size of population \(N\), maximum iterations \(T\), and the number of parameters \(M\) * Generate an initial population by drawing from a uniform distribution * Evaluate the population \(X\) using the objective function(.) for\(t=1:T\)do (i.) Sort population \(X\) based on fitness values obtained from the objective function (ii.) Create a prey subpopulation \(\Omega\) from the sorted population (lower-ranked individuals) (iii.) Create a predator subpopulation \(Sigma\) from the sorted population (higher-ranked individuals)  Quantum Predator Phase: for\(j=1:N_{pd}\)do  Get new predator subpopulation \(P\) using Equations (7) to (10). endfor  Prey Phase: for\(j=1:N_{py}\)do  Create shelter subpopulation for the \(i_{th}\) prey using Equation (11). Get new prey subpopulation \(R\) using Equations (12) to (13). endfor endfor Output: Get the best solution from \(R\) and \(P\)
```  
**Algorithm 1** Pseudocode of QPPA  
\[\Sigma=