# Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme in Intrabody Nanonetworks
## 3 Fuzzy Logic and Bio-Inspired Firefly Algorithm Based Routing Scheme
### Bio-Inspired Firefly Algorithm Based NBSs Selection
Thus, the energy consumed by the \(i\)th NBS in the transmission and reception of \(x\) number of bits is given as Equations (10) and (11):

\[E_{tx}(x)=x\times\alpha\times\ E_{tx}^{pulse} \tag{10}\]

\[E_{rx}(x)=0.1\times x\times\ E_{rx}^{pulse}, \tag{11}\]

where weight \(\alpha\) is used in Equation (10) to denote the probability of transmitting the symbol 1 in the \(x\) streams of bits. Since the symbols 0 and 1 are equiprobable, therefore, the value of \(\alpha\) is generally set to 0.5. While in the case of energy consumption during the reception, the entire \(x\) stream of bits is considered. Accordingly, the total energy consumed by the \(i\)th NBS in the \(r\)th round expressed as Equation (12):

\[E(nbs_{i}^{r})=(P_{RM}\times E_{tx}+P_{FB}\times E_{tx}+P_{RqM}\times E_{rx}+P_ {AM}\times E_{rx}), \tag{12}\]

where \(P_{RM}\), \(P_{FB}\), \(P_{RqM}\) and \(P_{AM}\) shows the total number of transmitted and received packets respectively. While \(E_{tx}\) and \(E_{rx}\) represents the amount of energy consumed in packet transmission and reception, respectively. Consequently, the amount of energy left in the NBS after completion of \(r\)th round is determined using Equation (13):

\[RE(nbs_{i}^{r})=E(nbs_{i}^{r})+E_{h}^{r}, \tag{13}\]

where \(E(NBS_{i}^{r})\) is the energy consumption of the \(i\)th NBS and \(E_{h}^{r}\) is the amount of energy harvested in the \(r\)th round. In the context of energy harvesting mechanisms in nanonetworks, conventional mechanisms such as solar energy, wind power, or underwater turbulence are inapplicable due to the technical limitations of these schemes at NS level. In the last few years, novel schemes are introduced for recharging NS devices. Piezoelectric nano-generator, which is composed of an array of ZnO nanowires, a reflecting circuit and an ultra nanocapacitor, has gained significant attention for recharging NS devices. The compression of nano-wires generates an electric current between the ends of nanowires that are used for recharging the ultra nanocapacitor. The mechanical vibration methods (such as air conditioning and heartbeat) provides the compressed release cycle. The frequency of the compressed release cycles \(f\) provides the time for recharging ultra nano-capacitor [61]. In IBNNs, NBSs are integrated inside the human body and the only possible source of mechanical vibration inside the human body is a heartbeat, therefore, \(f=1\) Hz. According to the energy harvesting model, after \(\alpha\) compressed cycles, the voltage of the charging capacitor is calculated using Equation (14):

\[d(\widehat{FF}_{i},\widehat{FF}_{j})=\sqrt{(\widehat{FF}_{j}(x)-\widehat{FF}_{ i}(x))^{2}+(\widehat{FF}_{j}(y)-\widehat{FF}_{i}(y))^{2}+(\widehat{FF}_{j}(z)- \widehat{FF}_{j}(z))^{2}}, \tag{6}\]0

where \(C_{cap}\) is the total capacitance of the ultra-nanocapacitor, \(\Delta Q\) represents the harvested charge per cycle and \(V_{g}\) is the generator voltage. However, due to technical limitation of NBSs, the typical values of quantities \(C_{cap}\), \(\Delta Q\) and \(V_{g}\) are 9 cF, 6 pc and 0.42 V respectively. The energy \(E_{cap}\) stored in ultra-nanocapacitor after \(\alpha_{cycles}\) is re-written as [61] using Equation (15):

\[d(\widehat{FF}_{i},\widehat{FF}_{j})=\sqrt{(\widehat{FF}_{j}(x)-\widehat{FF}_{ i}(x))^{2}+(\widehat{FF}_{j}(y)-\widehat{FF}_{i}(y))^{2}+(\widehat{FF}_{j}(z)- \widehat{FF}_{j}(z))^{2}}, \tag{6}\]1

where \(C_{cap}\) corresponds to entire capacitance of ultra-nanocapacitor, \(V_{g}\) signifies the voltage of the generator and \(\alpha_{cycles}\) demonstrates the number of cycles necessary to reach the energy level given by Equation (16):

\[d(\widehat{FF}_{i},\widehat{FF}_{j})=\sqrt{(\widehat{FF}_{j}(x)-\widehat{FF}_{ i}(x))^{2}+(\widehat{FF}_{j}(y)-\widehat{FF}_{i}(y))^{2}+(\widehat{FF}_{j}(z)- \widehat{FF}_{j}(z))^{2}}, \tag{6}\]2

where \(V_{g}\) is the generator voltage, \(C_{cap}\) is the capacitance of ultra-nanocapacitor and \(\Delta Q\) represents the harvested charge per cycle.