# A Resource Oriented Route Selection Framework Using Contextual Information Based on Fuzzy Logic
## 4 Proposed Approach
### Combining of Routing Metrics
Three sets of each input variables are as follows:  
\[ETX=\{{{}^{\prime}}\textit{Short}^{\prime},{{}^{\prime}}\textit{Average}^{ \prime},{{}^{\prime}}\textit{Long}^{\prime}\} \tag{9}\]  
\[QFI=\{{{}^{\prime}}\textit{Low}^{\prime},{{}^{\prime}}\textit{Medium}^{\prime },{{}^{\prime}}\textit{High}^{\prime}\} \tag{10}\]  
\[REI=\{{{}^{\prime}}\textit{Low}^{\prime},{{}^{\prime}}\textit{Average}^{ \prime},{{}^{\prime}}\textit{Full}^{\prime}\} \tag{11}\]  
After the fuzzification step, the next important step is the fuzzy inference, which is used to combine the fuzzy rules from the rule base. After establishing all the rules, the defuzzification will be the next step. It is the process of producing a fuzzy output value from the given fuzzy sets and corresponding membership degrees to produce a crisp value. In our defuzzification step, we use centroid defuzzifier. It is the most commonly used method that returns the center of gravity of the fuzzy set. We determine the membership function of each output variable of parent quality, as shown in Figure 7. The output of the defuzzifier can be obtained while using Equation in (12). \[Q=\frac{\sum\limits_{r=1}^{27}{\theta_{r}\times\mu_{r}}}{\sum\limits_{r=1}^{27 }{\mu_{r}}} \tag{12}\]  
where, \(\theta_{r}\) is the output of the rule \(r\) and \(\mu_{r}\) is the output product-inference engine (membership function). After defuzzification, the output of the fuzzy logic system \(Q\) becomes the crisp value. The route selection process of COOF is based on the fuzzy logic system, as shown in Figure 8. Where the input variable sets are ETX, QFI and REI. In the path selection process, the fuzzy rules govern the combination of three different metrics that represent input fuzzy sets, as shown in Figure 8. In our fuzzy system, three input fuzzy controller with three membership function for each input exists, therefore our rule base consists of \(3^{3}=27\) rules. Figure 5:0 Fuzzy system based path selection structure. Figure 5:1 Output variable of quality of path. The knowledge base consists of two components, database and rule base. The database component consists of linguistics terms for each variable and membership. Moreover, it also contains the objective function attributes and local policy. The rule base components relate the inputs to their outputs for the decision making of linguistic terms. Moreover, the rule base plays an important role in generating the results that were produced by the inference engine through the mapping of the inputs to outputs. It is worth mentioning that all of the information obtained from a node is received through a DIO message. The fuzzy inference engine uses this information to determine the quality of the path. Table 2 shows a few rules that have been formulated according to the criteria, as well as based on application scenarios. In addition, the table also contains the output fuzzy variable, which indicates the path quality, and this quality consists of five fuzzy sets from '_Excellent_' to '_Bad_'. The last column of Table 2 shows the quality variable, which is a fuzzy output variable, and the route selection is performed based on this quality variable. In the fuzzy rule, we define the 'Excellent' path quality to the candidate parent node that has high link quality, short queue fluctuation, and high remaining energy. Hence, based on this quality indicator, a node will decide through which parent node, data should be transmitted towards the root. The proposed parent selection framework can be used for other similar IoT infrastructure in different application domains. For this, according to the application requirements, the fuzzy input variables (ETX, QFI, REI) values can be customized based on different scenarios, such as network structure and device capability. Besides, the fuzzy rules and fuzzy sets are used according to the application requirements and device processing capability [40]. Hence, the membership function of the quality classes can be consist of more than five.