# Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme in Intrabody Nanonetworks
## 3 Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme
### Fuzzy Logic-Based Correlated Region Selection  
In our proposed work, different correlated regions are selected for data reporting; the selection decision of the participating region is performed using FLBDS, as demonstrated in Algorithm 1. Our proposed FLBDS significantly overcomes the complexity overhead of the selection decision of correlated regions in resource constraint IBNNs. ```
1:Input:
2:Set of correlated regions \(\{CR^{\prime}\}=\{cr_{1},cr_{2},cr_{3}\ldots cr_{n}\}\)
3:Action:
4:For each correlated region \(CR\) index \(i\) do
5:\(CR^{i}_{D}\) = Density (One-hop neighbors of nanorouter in the correlated region \(i\))
6:\(CR^{i}_{F}\) = Energy (Residual energy in the correlated region \(i\))
7:\(CR_{PCMR}\) = Previous critical messages received (PCMR in the last data reporting interval in the correlated region \(i\))
8:End For
9:Evaluate input parameters \((CR^{i}_{D},CR^{i}_{E},CR^{i}_{PCMR})\) using Fuzzy Rules given in Figure 3.
10:For each \(CR_{i}\) do
11:Calculate \(Enrichment-value_{CR}\) (Using the defuzzification process). 12:Enriched list of \(CR\) (\(Enrichment(\{CR\})\gets Enrichment-value_{CR}\)
13:End For
14:Output:
15:\(Enrichment-value_{CR}\) = List of Information and Energy enriched correlated regions
```  
**Algorithm 1**Selection decision of correlated regions for data reporting using FLBDS  
The fuzzy logic-based decision is made after completion of three main parts of the FLBDS, namely fuzzification, fuzzy inference system and defuzzification. Our proposed fuzzy logic-based decision model uses three input parameters (i.e., messages, density and energy) for generating one output parameter. The first input parameter gives knowledge about the number of messages that are received from a correlated region during the last interval. The second input parameter density shows the NBSs density at the one-hop distance from nanorouter and the last input parameter is energy that represents the remaining energy of the correlated region. Based on these three input parameters, the output parameter determines the enrichment value of a correlated region. 1. Fuzzification: In our proposed fuzzy logic-based decision model, the input and output parameters are described using the linguistic variables. The expressions used for input parameters, density, messages and energy are 'high,'medium' and 'low,' respectively. While the output parameter represents the enrichment value using the linguistic variables'very high', 'high,'medium,' 'low' and'very low.' In the fuzzification process, these variables are represented by triangular membership functions, which are used to associate a grade to each input linguistic variable. The selection of the number of membership functions and their initial values is based on process knowledge and intuition. The membership function has a value between 0 and 1 over an interval of the crisp variable. 2. Fuzzy Inference System: After the fuzzification process, the fuzzified values are processed by the fuzzy inference engine to inference the fuzzy rules for driving decisions. The fuzzy rules used in our proposed fuzzy logic-based decision model are elaborated using Figure 3. The fuzzy rules are the sets of 'IF' and 'THEN' statements, for instance, the first rule is read as **IF** (Density is high) and (number of messages received are also high) and (energy is high) **THEN** (The enrichment of the correlated region is very high). The number of rules depends on the number of input membership functions, which grow exponentially with the increase in the number of input membership functions. The characteristics of the defined rules are imprecise; the value generated from the rules are fuzzy instead of crisp values. The input parameters are fuzzified according to the membership value to obtain crisp values. The attained crisp values are then used to determine the enrichment of the correlated-region. 3. Defuzzification: The obtained result is processed in the defuzzification process to achieve a quantifiable output (i.e., the enrichment of a correlated region).