## 3 Spawn Multi-Mobile Agent Itinerary Planning (SMIP) Approach
### Determining the Itinerary for Each MA in SMIP
It should be noted that in the proposed SMIP approach, the procedure of determining the number of main MAs, SMAs, and their corresponding itineraries utilized for data gathering process is executed centrally at the sink. Thus, since the sink assigns one main MA to each partition, the number of main MAs that will be dispatched to the network is equal to the number of the network's partitions. While the total number of SMAs in the whole network can be calculated as below:  
\[TotalSMAs=\sum_{p=1}^{z}\text{ \emph{Number of SMAs }}(p) \tag{3}\]  
where \(p\) is the partition number and \(z\) is the total number of partitions in the network, \(Number\ of\ SMAs\ (p)\) is the number of SMAs in partition \(p\), which is given by:  
\[Number\ of\ SMAs(p)=\frac{TDS_{p}}{MA_{DP}}-1 \tag{4}\]  
where \(TDS_{p}\) is the total data size in partition \(p\) which can be carried by the main MA using Equation (2) and \(MA_{DP}\) is a threshold of the data payload of the main MA. Note that the result in Equation (4) has been reduced by 1 because the last data payload will be carried by the main MA. The pseudo-code of SMIP approach is detailed in Algorithm 1. ```
1 Initialization:\(\mathbf{N}\leftarrow\) Number of sensor nodes \(MA_{DP}\leftarrow\) The threshold value of the main MA data payload Partitioning the network using x-means algorithm by calculating the distance among N:\(Z\leftarrow\) Number of partitions for\(p\) = 1 to \(Z\)do
2\(S\leftarrow\) Number of source nodes in \(p\) Assign one main MA to \(p\)\(TDS_{p}\leftarrow\) The total data size of \(S\) in \(p\) using Equation (2) if\(TDS_{p}>MA_{DP}\)then
3 Calculate Number of SMAs (\(p\)) as in Equation (4) Determine the itinerary of the main MA and SMAs using LCF algorithm
4 end if
5
6 end for Return the itineraries of the main MAs and the SMAs
```  
**Algorithm 1**Pseudo-code of SMIP approach. In order to have a good understanding of the proposed SMIP approach, Figure 3 illustrates an example of data gathering based on SMIP approach when compared to GIGM-MIP algorithm. In this example, the sink is required to send the MA to one partition. In this partition, there are nine source nodes (the red nodes **1**, **2**, **3**, **4**, **5**, **6**, **7**, **8**, and **9**) to be visited by the MA. In Figure 2(a), with the GIGM-MIP algorithm, the sink determined that two MAs should be dispatched and visit the nine source nodes. By adapting the LCF algorithm, the source nodes' visited order of the first MA is (**1**, **2**, **3**, **4**, and **5**). After the first MA complete data collection from source node (**5**), it returns to the sink due to the full size of the data payload. The source nodes' visited order of the second MA is (**9**, **8**, **7**, and **6**). Note that in the GIGM-MIP algorithm, each MA has to carry its processing code (aggregation code). Moreover, each MA has its own itinerary such that each MA starts its migration from the sink and returns back to the sink with the accumulated data. On the other hand, Figure 2(b) shows the data collection process of the proposed SMIP approach. With the SMIP approach, the sink dispatches only one main MA to perform the data collection task. The source nodes' visited order of the main MA as determined by LCF algorithm is (**1**, **2**, **3**, **4**, **5**, **6**, **7**, **8**, and **9**). When the main MA finishes collecting data from source node (**5**) and its data payload exceeds the threshold, the main MA spawns an SMA in order to carry the accumulated data back to the sink. The SMA follows a different itinerary towards nodes **5**, **A** and **B** until it reaches the sink. Note that the nodes along the SMA itinerary work only as intermediate nodes, which means there is no data collection process along the SMA itinerary. Once the main MA spawns the SMA, it continues its migration to perform the data collection task from the remaining source nodes (node numbers **6**, **7**, **8**, and **9**).