## 5 Proposed Heuristic
### Stage I and II: Determining Sojourn Locations and RPs
#### 5.1.3 Sojourn Locations Selection  
Determining a set of sojourn locations for the mobile-sink is another problem that arises after selecting the RPs in the network by assuming a fixed trajectory. Based on the communication technologies for the sensor-nodes and the mobile-sink two assumptions are possible to define the sojourn locations. In the first assumption, the sojourn locations are some specific points in the trajectory and the mobile-sink should stop in each point to harvest data from the RPs. In addition, in the second assumption, the sojourn locations are located in a communication range in which the mobile sink harvests data from the RP(s). In addition, in a fixed trajectory another assumption that can influence the sojourn locations is the sink-node and its installation manner. If the sink-node is being installed on a transportation vehicle or on an animal such as the approaches in [30; 39], then defining some specific points or communication ranges as sojourn locations is not possible due to unpredictable (or hard to predict) behavior of the carrier objects that is not the focus of our current work. And if the sink-node is being installed on a controllable vehicle such as a robot then it is practical to characterize the sojourn \begin{table}
\begin{tabular}{c c c c} \hline \hline _Residual Energy_ & _Number of Neighbor-Nodes_ & _Distance from Mobile-Sink_ & _Potentiality_ \\ \hline Medium & Low & High & Medium \\ Medium & Low & Medium & Medium \\ Medium & Low & Low & Medium \\ Low & High & High & Very Low \\ Low & High & Medium & Very Low \\ Low & Medium & High & Very Low \\ Low & Medium & Medium & Very Low \\ Low & Medium & Low & Low \\ Low & Low & High & Very Low \\ Low & Low & Low & Low \\ Very Low & High & High & Very Low \\ Very Low & High & Medium & Very Low \\ Very Low & High & Low & Very Low \\ Very Low & Medium & High & Very Low \\ Very Low & Medium & Medium & Very Low \\ Very Low & Medium & Low & Very Low \\ Very Low & Low & High & Very Low \\ Very Low & Low & Medium & Very Low \\ Very Low & Low & Low & Very Low \\ Very Low & Low & Low & Very Low \\ \hline \hline \end{tabular}
\end{table} 
Table 1: _Cont._locations. And generally, designing the sojourn locations follows a main strategy in which reducing the number of sojourn locations can reduce delay-time in the network. ```
Input: i) Candidate RPs, \(\zeta=\left\{\rho_{1},...,\rho_{k}\right\},k\leq|S|\); ii) Neighbor-Nodes, \(\rho_{i}=\left\{\eta_{1},...,\eta_{l_{i}}\right\},\forall i=1,...,k\) and \(l_{i}\leq|S|\); Output: i) RP-Nodes, \(\Delta=\left\{\delta_{1},...,\delta_{m}\right\},\)\(m\leq|S|\); ii) The first group of sensor-nodes which follow the RPs, \(\delta_{i}=\left\{\eta_{i},...,\eta_{l_{i}}\right\}\);
1 for\(j=1\) to \(k\)do
2 Run the Fuzzy Decision System in section 5.1.1 and calculate the potentiality of a sensor-node to work as RP;
3
4 end for
5 while\(j\leq k\)do
6 for\(q=1\) to \(l_{j}\)do
7 Send the result of potentiality to the neighbor sensor-node \(\eta_{q}\);
8 end for
9
10 end for
11 for\(j=1\) to \(W\)do
12 /*\(W\)isthetotalnumberofneighbor-nodeswhichcancontactwithRPs,directly. 13 */
14 By considering all of the candidates; vote for a RP-Node that has higher potentiality and it is in the closer distance; priority is with the potentiality;
15
16 end for
17 for\(j=1\) to \(k\)do
18 if\(|\)Numberofvotesfor\(\rho_{j}|\leq\frac{|\eta_{l_{j}}|}{2}\)then
19 Broadcastmessagetoalloftheneighbor-nodesandpublishtheresultanddeclareswinner;
20
21 end for
22
23 end for
24 for\(j=1\) to \(w\)do
25 iftheselectedRPofasensor-nodedoesnotwinthen
26 ifitcancontactwithanotherWinner-RPthen
27 FollowitasRP;
28
29 end if
30 else
31 Senda specialmessagetothevotedRPwhichis losttobecomeRP;
32
33 end if
34
35 end for
36
37 end for
```  
**Algorithm 1**RP-Node Selection  
In our research, we proposed a heuristic to select the sojourn locations after determining the RPs in the network.