## 5 Proposed Heuristic
### Stage I and II: Determining Sojourn Locations and RPs
#### 5.1.1 Fuzzy Decision System  
Since its first introduction in 1960 [51; 52], Fuzzy Logic theory could gain a huge attention in various applications. The main objective in Fuzzy Logic theory is to overcome uncertainties in the environment by constructing a system that its parameters are understandable for humans. Figure 4 depicts the general scheme of the Fuzzy Inference System that decides about the potentiality of a sensor-node to work as RP by taking input variables and calculating the output variable. The main advantages of this system are simplicity to implement in the sensor-nodes and robustness to deal with uncertainties in the environment. In our research, we have to determine the input and the output variables and design the Fuzzy rule base. Input VariablesDetermining a suitable set of input variables for the Fuzzy Inference system has direct influence on the system's accuracy. In the following, we will explain our input variables with details. * _Residual energy_ is the main factor for a sensor-node to be selected as RP. We designed the following linguistic variables to describe the amount of remaining energy for a sensor-node; _very high_, _high_, _medium_, _low_, and _very low_. Figure 5a illustrates the membership functions to map the crisp values of residual energy to the related linguistic values. The membership functions for the linguistic variables _high_, and _very low_ are trapezoidal and triangular for the rest of linguistic variables. * _Number of neighbor-nodes_ is another factor that determines the popularity of a sensor-node in case of being selected as RP. In this factor, we just consider the sensor-nodes that can contact with the candidate-node directly. Therefore, a sensor-node with highest number of neighbor-nodes is more desirable. We defined three linguistic variables to describe the number of neighbor-nodes which are _high_, _medium_, and _low_. In Figure 5a, the membership functions for _high_ and _low_ are trapezoidal and for _medium_ triangular. * _Distance from Mobile-Sink_ is the third factor in our designated Fuzzy inference system that is for obtaining the required energy for the sensor-node to contact with the mobile-sink in case of being selected as RP. Clearly, when a sensor-node is closer to the sojourn location, it can conserve its residual energy and extend the lifetime of the network. In the Fuzzy inference system, as shown in Figure 5b there are three linguistic variables to describe the distance from mobile-sink; _high_, _medium_, and _low_. The membership functions for _high_ and _low_ are trapezoidal and for _medium_ the membership function is triangular. Figure 4: Fuzzy Inference System for identifying potentiality of the sensor-nodes to become RP. Output Variable:The output variable for the Fuzzy Inference System is called Potentiality which determines the degree of ability for a sensor-node to become a RP. We specify four linguistic variables which are _high_, medium, low, and very low. As shown in Figure 5, the membership functions for the linguistic variables _high_ and _very low_ are trapezoidal and for the rest of linguistic variables are triangular. We designed the membership functions for all of the linguistic variables experimentally. As illustrated in Figure 4, after defining the linguistic values and the related membership functions, the next step is about obtaining the Fuzzy Rule Base. Table 1 consists of 45 Fuzzy rules which are based on the heuristic Fuzzy rule generation with the principle of balancing energy consumption among the sensor-nodes which can be elected as RP during the network's operation with assuring the connectivity of the sensor-nodes. And the final step is defuzzification. In this step, the system should generate a crisp value for the amount of potentiality and the center of area (COA) is the technique that we applied.