# Asymmetric Protocols for Mode Pairing Quantum Key Distribution with Finite-Key Analysis
## Appendix A The Modified PSO Algorithm for Maximizing \(R(\vec{g})\)  
```
Input : Particle number \(N_{\text{PSO}}\), max iterations \(T\), inertia weight range \([w_{\text{init}},w_{\text{final}}]\), individual learning factor range \([c_{1,\text{min}},c_{1,\text{max}}]\), social learning factor range \([c_{2,\text{min}},c_{2,\text{max}}]\), global exploration ratio \(h\), fitness change threshold \(\zeta\) Output : Global best position \(G_{\text{best}}\) and corresponding fitness \(R(G_{\text{best}})\)
1 Function The modified PSO:
2 Initialize Swarm:
3 Randomly initialize position \(\vec{g}_{i}\) and velocity \(V_{i}\) for each particle;
4 Ensure that the initial positions \(\vec{g}_{i}\) satisfy the constraints in Equations (15) and (A1);
5 Initialize best positions:
6 for each particle \(i\) to \(N_{\text{PSO}}\)do
7 Compute fitness \(R(\vec{g}_{i})\) and set \(P_{\text{best},i}\leftarrow\vec{g}_{i}\);
8 Set global best \(G_{\text{best}}\leftarrow\arg\max R(P_{\text{best},i})\);
9 Iterative optimization:
10 for\(t=1\)to\(T\)do
11 Update inertia weight \(w\) using: \[w\gets w_{\text{init}}-\frac{w_{\text{init}}-w_{\text{final}}}{T}\times t\]  Update learning factors \(c_{1}(t)\) and \(c_{2}(t)\): \[c_{1}(t)\gets c_{1,\text{min}}+(c_{1,\text{max}}-c_{1,\text{min}})\cdot \left(1-\frac{t-1}{T}\right)\] \[c_{2}(t)\gets c_{2,\text{min}}+(c_{2,\text{max}}-c_{2,\text{ min}})\cdot\left(1-\frac{t-1}{T}\right)\]
12 for each particle \(i\) to \(N_{\text{PSO}}\)do
13 if\(i<N_{\text{PSO}}\times h\)then
14 Randomly update position \(\vec{g}_{i}\) and velocity \(V_{i}\), ensuring constraints are met;
15
16 else
17 for\(d=1\)to\(10\)do
18 Update velocity and position: \(V_{i,d}\leftarrow w\times V_{i,d}+c_{1}(t)\times\text{rand1}0\times(P_{\text{ best},i,d}-\vec{g}_{i,d})+c_{2}(t)\times\text{rand2}0\times(G_{\text{best},d}-\vec{g}_{i,d})\) \[\vec{g}_{i,d}\leftarrow\vec{g}_{i,d}+V_{i,d}\]
19 Update individual and global best:
20 for each particle \(i\) to \(N_{\text{PSO}}\)do
21 Compute fitness \(R(\vec{g}_{i})\);
22 if\(R(\vec{g}_{i})>R(P_{\text{best},i})\)then
23 Update \(P_{\text{best}}\leftarrow\vec{g}_{i}\);
24 if\(|R(G_{\text{best}})-R_{\text{new}}(G_{\text{best}})|<\zeta\)then
25 Terminate;
26
27 Output :\(G_{\text{best}}\) and \(R(G_{\text{best}})\);
```  
**Algorithm 1**The modified PSO Algorithm for Maximizing \(R(\vec{g})\) with 10-Dimensional Variables  
The PSO algorithm is a globally efficient and easily implementable optimization algorithm that reduces reliance on initial points through collaborative swarm behavior. It exhibits rapid convergence and is suitable for addressing a variety of complex multi-variable optimization problems. Considering the characteristics of the asymmetric MP-QKD protocol, we have modified the PSO algorithm as described in Algorithm A1. Lines 1-11 initialize the position, velocity, individual best, and global best of the particle swarm. It is reasonable and intuitive to expect that the particles, after initialization, should satisfy Equation (15). An often overlooked detail is that the intermediate parameters must also adhere to their physical significance, as shown below  
\[ \begin{split} 0<n^{\mathrm{Z}}_{(k_{a},k_{b})},\ n^{X}_{(k_{a},k_{b })},\ t^{\mathrm{Z}}_{(k_{a},k_{b})},\ t^{X}_{(k_{a},k_{b})}\\ 0<y^{\mathrm{Z}}_{11},\frac{M_{(\mu,\mu)}}{N}<1,\\ 0<e^{\mathrm{Z,ph}}_{11},E_{(\mu,\mu)}<0.5.\end{split} \] (A1)  
Equation (A1), which guarantees that all counts are positive, all count rates fall between 0 and 1, and all error rates are greater than 0 but less than 0.5, aligns with the requirements for practical deployment. Compared to the original PSO algorithm [36], the modified version updates the inertia weight \(w\), individual learning factor \(c_{1}\), and social learning factor \(c_{2}\) throughout the optimization process (Line 11). These updates improve the balance between global and local search, enhance particle coordination, and increase both efficiency and convergence speed.