# Quantum PSO-Based Optimization of Secured IRS-Assisted Wireless-Powered IoT Networks
## 3 Proposed Solution Based on Alternating Optimization  
This section presents the AO-based scheme to efficiently address optimal solutions for problem (10). Solving it analytically is difficult due to the strong coupling between the optimization variables. Therefore, the proposed approach is aimed at obtaining a near-optimal solution in an iterative manner. Specifically, problem (10) is divided into two sub-problems, alternately fixing certain variables and then iteratively maximizing the objective function until convergence. To solve the sub-problems related to the uplink and downlink shift matrices \(\{\mathbf{\Phi}_{0},\mathbf{\Phi}_{1}\}\), we consider a QPSO algorithm. Meanwhile, the bisection method optimizes time allocations \(t_{0}\) and \(\{t_{k}\}\):  
\[\max_{\mathbf{\Phi}_{0},\mathbf{\Phi}_{1}}\quad\varphi_{1}(\mathbf{\Phi}_{0}, \mathbf{\Phi}_{1})\] (11a) subject to \[\quad\varphi_{1}(\mathbf{\Phi}_{0},\mathbf{\Phi}_{1})=\max_{t_{0},\{t_{k }\}}\varphi_{2}(\mathbf{t}) \tag{11b}\]  
representing the decoupled optimization problems that are alternately solved, where (11a) optimizes the IRS phase shift matrices \(\mathbf{\Phi}_{0}\) and \(\mathbf{\Phi}_{1}\) to maximize the objective function \(\varphi_{1}\) and (11b) optimizes time allocations \(t_{0}\) and \(\{t_{k}\}\) for a given set of phase shift matrices \(\mathbf{\Phi}_{0}\) and \(\mathbf{\Phi}_{1}\) to maximize objective function \(\varphi_{2}\). Optimizing \(\{\mathbf{\Phi}_{0},\mathbf{\Phi}_{1}\}\) with a Fixed \(\{t_{0},\{t_{k}\}\}\)  
We fix time allocations \(t_{0}\) and \(\{t_{k}\}\) to optimize the IRS phase shift matrices \(\mathbf{\Phi}_{0}\) and \(\mathbf{\Phi}_{1}\); so, we rewrite (11a) as follows:\[\text{P1.1}\quad\underset{\mathbf{\Phi}_{0},\mathbf{\Phi}_{1}}{\text{max}} \quad\sum_{k=1}^{K}[R_{k}-R_{E}]^{+}\] (12a) subject to \[\quad[R_{k}-R_{E}]^{+}\geq\bar{R}\quad k=1,2,\ldots,K \tag{12b}\] \[\quad[\mathbf{\Phi}_{0}]_{n,n}=1;\ [\mathbf{\Phi}_{1}]_{n,n}=1,\quad n=1,2, \ldots,N \tag{12c}\]  
QPSO-Based Solution  
We solve problem P1.1 using the QPSO algorithm initially introduced by [PERSON] et al. [51]. In QPSO (which extends the classical PSO), the state of each particle is represented by a wave function, \(\psi(x,t)\), a concept borrowed from quantum physics [52]. According to QPSO theory, every particle exists in a quantum state, and probability density function \(|\psi(x,t)|^{2}\) can be used to determine the likelihood of detecting the particle at position \(x\) at any given time \(t\)[46]. QPSO enhances search efficiency and requires fewer parameters for convergence, compared to the standard PSO algorithm. Unlike the classical PSO, where the search and solution spaces are merged, QPSO separates these spaces. The particle's state in the quantized search space is described by a wave function that gives the probability of its position [53]. To transition between the quantum state and the classical solution space, a process known as collapse occurs. This collapse, similar to measuring the particle's position in quantum mechanics, converts the particle's quantum state into a classical state, allowing for fitness evaluation and solution optimization. We define the population size, \(N_{p}\), and initialize positions \(\mathbf{\Phi}_{0}\) and \(\mathbf{\Phi}_{1}\) of each particle randomly within a feasible region as shown in Figure 3. Then, we set the contraction-expansion coefficient \(\gamma\), the maximum number of iterations \(I\), and define the fitness function to evaluate each particle's position based on the secrecy throughput expression (12a). Let \(X_{j}\) and \(\mathit{pbest}_{j}\), respectively, be the vector position and the individual optimum position of particle \(j\). Hence, we have the process for each iteration until the maximum number of iterations. The optimization formula to update the individual optimum position of the particle \(j\) is given by  
\[\mathit{pbest}_{j}= \begin{cases}\mathit{pbest}_{j},&\text{if }f(X_{j})\leq f (\mathit{pbest}_{j})\\ X_{j},&\text{if }f(X_{j})>f(\mathit{pbest}_{j})\end{cases}