# Rendezvous Based Adaptive Path Construction for Mobile Sink in WSNs Using Fuzzy Logic
## 4 Proposed Approach
### Initial Locations of the RPs  
The initial locations of the RPs are obtained as given in Algorithm 1. First, as in [12], a set of P RPs is obtained by clustering the sensor nodes into \(|P|\) clusters using k-means algorithm [21]. These \(|P|\) points represent the set of candidate RPs for building the MS path. Each RP \(i\), (\(1\leq i\leq|P|\)) is then assigned a priority value \(R(i)\) using Equation (4):  
\[R(i)=\frac{S_{RP}(i)}{H_{RP}(i)} \tag{4}\]  
where \(S_{RP}(i)\) is the number of sensor nodes associated with RP \(i\) and \(H_{RP}(i)\) is the average hop distance between RP \(i\) and the sensor nodes associated with it. Equation (4) gives high priority for the RP, which has more sensor nodes attached to it, and the average distance of these nodes to that RP is small compared to the other potential RPs. Assume \(PL\) is the length, in meters, of the path that connects all required RPs to collect the data. Assume the time that the MS needs to receive the data from the sensor nodes when it stops at each RP \begin{table}
\begin{tabular}{l l} \hline \hline
**Term** & **Definition** \\ \hline \(S\) & Set of sensor nodes \\ \(s_{i}\) & Sensor node \(i\) \\ \(S_{j}\) & Set of sensor nodes associated with RP \(j\) \\ \(P\) & Set of potential RPs \\ \(C\) & Set of RPs that are used to build the MS path \\ \(S_{RP}(i)\) & Number of sensor nodes associated with RP \(i\) \\ \(H_{RP}(i)\) & Average hop distance between RP \(i\) and the sensor \\  & nodes associated with it \\ (\(X_{RPi}\), \(Y_{RPi}\)) & Location of \(RP_{i}\) \\ \(E_{i}\) & Remaining energy of sensor node \(i\) \\ \(d_{i\to RPi}\) & The distance between sensor node \(i\) and its \\ \(NBi\) & The 1-hop neighbors of sensor node \(i\) \\ \(PL\) & Path length \\ \(v\) & MS speed \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notations used. is \(T_{data}\), then the total time for collecting the data from all sensor nodes \(T_{total}\) in each round is given as:  
\[T_{total}=c\times T_{data}+\frac{PL}{v} \tag{5}\]  
where \(c\) is the number of RPs obtained using Algorithm 1 (\(c\leq|P|\)) and \(v\) is the MS speed. Some WSN applications require that the sensed data should be collected within a specific delay limit. Therefore, depending on the WSN application (for example, a real-time application), the path length should not exceed a threshold value (\(PL_{threshold}\)). Based on that, in Algorithm 1, after determining the candidate set \(P\) as RPs using k-means algorithm, only c RPs of this set will be selected to build the MS path. ```
INPUT: S, \(PL_{threshold}\)  OUTPUT: C, path for MS
1:Begin RPs INITIAL LOCATIONS
2:\(P\) = k-means(S): // Cluster the S sensor nodes into \(P\) clusters using k-means algorithm [21]
3:for i = 1 to P do
4: Calculate the priority value of RP i using Equation (4)
5:End for
6:Sort the set P of RPs based on their priority values in descending order
7:\(C\) = { _}_;_ _/* Set C contains the RPs that will be used to construct the MS path*/
8:RPx = remove RP from P
9:\(C\) = C \(\cup\) {RPx}
10:\(c\) = 1
11:While True do
12:RPy = remove RP from P
13:\(C\) = C \(\cup\) {RPy}
14:\(c\) = \(c\) + 1
15:\(PL\) = TSP(C)/* Call traveling sales person algorithm to obtain the path between the RPs in C */
16:If\(PL\geq PL_{threshold}\)then break
17:End While
18:If (size(P) > 0) then /* if some RPs in P are not used to construct the path */
19:Redistribute the nodes attached to the RPs in P to the RPs in C
20:until the path length is equal or larger than the specified
21:threshold. 22:End if
23:End
```  
**Algorithm 1**Finding the initial locations of the RPs  
Once the initial RPs are selected and the initial path for data collection is constructed, the MS determines for each sensor a corresponding RP where each sensor node will be assigned to the closest RP. The MS then broadcasts a rendezvous information packet (RIP) to the whole network to inform each node about its RP. Therefore, when each sensor node receives the RIP packet, it obtains its destination RP.