# Rendezvous Based Adaptive Path Construction for Mobile Sink in WSNs Using Fuzzy Logic
## 4 Proposed Approach
### Updating the RPs Locations  
In the proposed approach, the locations of the RPs are updated dynamically using a Fuzzy Inference System (FIS) [22]. An example of using fuzzy logic to control the MS movement toward cluster heads for improving the LEACH protocol [23] was proposed in [24]. In this paper, the proposed algorithm is called Fuzzy_RPs. In each round, the location of each RP is updated based on three factors:  
1. The energy of each sensor around the RP. The energy level of each sensor influences how much the RP should be moved close to the sensor node. To balance the energy consumption and extend the network lifetime, the sensor with a low energy level has more impact to change the RP location and bring the RP close to it. 2. The distance between the sensor node and the corresponding RP. As the distance of transmission influences the amount of energy consumption, the location of RP should be updated to balance the distance between all sensor nodes and their corresponding RP. This factor has a significant impact to mitigate the overall energy consumption during the network lifetime. 3. The number of sensor nodes around each node. The sensor node within the dense region has more impact compared to the sensor node within the sparse region to influence the change of the RP location. The idea behind this factor is to attract the MS towards the dense region in order to be close to as many nodes as possible and therefore reduce the energy that will be used for transmission by the sensor nodes. This factor breaks the tie when two or more nodes have the same distance to their corresponding RP. For example, when two sensors have the same energy level and the same distance from the current corresponding RP, the sensor node with a high number of surrounding sensor nodes will attract the MS to update the location of the current corresponding RP towards it more closely compared with the sensor node in the sparse region. The proposed FIS has three Inputs, which represent the three factors discussed above. For each sensor node \(i\), the inputs of the FIS will be:  
1. \(E_{i}\): the remaining energy of sensor node \(i\). 2. \(d_{i\to RPi}\): the distance between sensor node \(i\) and its corresponding RP. 3. _NBi_: the 1-hop neighbors of sensor node \(i\). The output of the FIS determines a weight value wj between 0 and 1. The weight value increases if the distance is high or the energy of the node is low. The output weight value influences the change of the RP location. The sensor node with a higher weight value has more impact to change the location of the RP toward its location. Figure 2 shows the block diagram of the proposed Fuzzy_RPs. It consists of the basic four stages of FIS: fuzzification, evaluation of the fuzzy rules, aggregation, and defuzzyfication of the output fuzzy sets where the Mamdani model is used for this purpose. The membership functions of the inputs and output are shown in Figure 3. The fuzzy rules are presented in Table 2, where AND operator is used to combine the three inputs. The shape of the membership functions of the fuzzy sets for the inputs and the output as well as the fuzzy rules are considered after running a set of simulations. In each run, the range of each fuzzy set and the fuzzy rules were evaluated, and the system was tuned until we got the membership functions shown in Figure 3 and the fuzzy rules given in Table 2.  
Figure 3: Membership functions of the inputs and output. (**a**) Membership functions of input Distance. (**b**) Membership functions of input Energy. (**c**) Membership functions of input (_NB_). (**d**) Membership functions gof output \(w\). Figure 2: Block diagram of Fuzzy_RPs FIS. Assume the current position of RP \(i\) is (\(X_{RPi}\), \(Y_{RPi}\)), and the current position of sensor node \(j\) that is associated with RP \(i\) is (\(X_{j}\), \(Y_{j}\)).