## 3. MPSO for Inter-Layer Contact Plan
The MPSO initializes the group by the following steps:  
_Step 1_: Based on the contact topology of MLSCN, a certain number of CPs that can complete the data transmission on HAPs are randomly generated, and the average delivery time of these CPs is calculated at the same time. _Step 2_: According to the average delivery time calculated in step 1 and the contact topology of MLSCN, MPSO counts all PVLs that may be established during the delivery period, and calculates the average establishing time and the transfer amounts of the contact. _Step 3_: MPSO calculates the relevancy between each pair of CPs according to the average values calculated in step 2. _Step 4_: Based on the optimization model of relevancy minimization, the classical Genetic Algorithm (GA) is used to iteratively correct the transfer amounts and average establishing time of each PVL in CPs until the iteration termination condition is reached. Due to the needs of the average establishing time and transfer amounts of PVLs, the first step of gird-based initialization is to generate a large number of CPs randomly, and so as to determine the  
Figure 5: Random initialization and Grid-based initialization with two dimensions in MPSO. \[Var(T^{pl})=\frac{\sum\limits_{n=1}^{N_{n}}\sum\limits_{m=1}^{N_{m}}\left(T^{ pl}_{n,m}-T^{ave}_{n,m}\right)^{2}}{N^{l_{n,m}}_{T^{ave}}}\ \ \ \forall pl,n=v,m=p \tag{12}\]  
where \(N^{l_{n,m}}_{T^{ave}}\) is the number of contacts that MLCN can establish by the time \(T^{ave}\). To maximize the differences among the particles of the group, the objective function in grid-based initialization is set as Equation (13):  
\[\text{min}\sum\limits_{i}\sum\limits_{j}r(pl_{i},pl_{j})\ \ \forall i\
eq j \tag{13}\]  
According to the objective function, the classical Genetic Algorithm (GA) is used to search the optimal solution of initial group. Table 1 shows the simulation result, the comparison between traditional way and grid-based initialization in relevancy. As can be seen in Table 1, whether for transfer amounts or average establishing time, the initialized group is much smaller than that of random initialization. The initialized MPSO encodes each CP in the initial group into a binary string leading the algorithm more manageable. Each bit of the string represents an establishment status of a particular contact. In the example contact topology of Figure 2, considering the cross-layer contacts \([v_{2}^{1},p_{1}^{1}]\) and \([v_{3}^{1},p_{2}^{1}]\) at state \(c_{1}\), the binary string reserves two code bits for state \(c_{1}\). If the first bit in the binary string equals to 1, it means that contact \([v_{2}^{1},p_{1}^{1}]\) is established in the CP. Otherwise, the contact is excluded from the CP. Since the CPD of SPLs is not covered in the grid-based initialization of MPSO, and randomly generated bits are likely to break the constraints of the model, the bits of SPLs must be repaired soon. The repaired string is a complete inter-layer CP, and then combined with the intra-layer CP introduced in the next section, it constitutes a complete feasible CP in the MLSCN. In order to demonstrate the advantages and disadvantages of CPs, the following evaluation function is used to calculate the fitness of CPs:  
\[F=\frac{1}{\sum\limits_{c}\sum\limits_{n}\sum\limits_{m}CT_{c}\cdot X_{c,n,m} }\cdot\phi(T_{s})\ \ \ \forall c,n,m=g \tag{14}\]  
where \(T_{s}\) is the lifetime of a packet, \(\phi(T_{s})\) is the penalty function and shown as follows:  
\[\phi(T_{s})=1-(\frac{N^{p}_{o}\cdot(T^{ave}_{o}-T_{s})}{N^{p}_{all}\cdot T^{ave }_{all}}) \tag{15}\]  
where \(N^{p}_{o}\) is the number of packets whose delivery time exceeds the lifetime. \(T^{ave}_{o}\) is the average delivery time of the packet which exceeds the lifetime, and \(T^{ave}_{all}\) is the average time for all packets to reach the destination node. \(N^{l}_{all}\) is the total number of the packets waiting delivery on all UAVs. \(\alpha\) is the penalty factor. After the evaluation of each particle, MPSO determines whether iterating or not.