# Inspired from Ants Colony: Smart Routing Algorithm of Wireless Sensor Network
## 3 Proposed Algorithm  
This part describes our Smart Routing Algorithm (SRA): that all the nodes communicate with each other, if the first node detects an event it will look for its successor, it broadcasts the request message. If a neighbour node receives that request message, it will store the ID of the sender in its list-neighbour firstly and then broadcast its own power and receiver ID and its positioning (x,y) as a response, and then wait for an acknowledgement, if the acknowledgement is received. Hence, these nodes, sender and receiver, are connected and can communicate between them. When all the recipients finish doing the same thing, the node that will send data has its neighbours list, it calculates the probability, \(p_{i,j}\), for each candidate j belongs to the list of neighbouring nodes, and then executes line 7 to line 14 of Algorithm 1 for choosing its next best node and sends data to it. After that, the next node receives data, aggregates it with its own and sends all data, using the SRA (Smart Routing Algorithm), to its successor, and this process is repeated until the data arrives at the base station. The first iteration is counted when the data arrives at the base station. This mechanism is repeated until some number of iterations; in our case, we stop at 50 iterations (the nodes are all alive). The probability that node \(i\) sends to node \(j\) is given by Equation (1):  
\[p_{i,j}=\frac{(\tau_{i,j})^{\alpha}\cdot(\eta_{i,j})^{\beta}\cdot(E_{res}(i))^{ \gamma}\cdot(E_{res}(j))^{\delta}}{\sum(\tau_{i,j})^{\alpha}\cdot(\eta_{i,j})^{ \beta}\cdot(E_{res}(i))^{\gamma}\cdot(E_{res}(j))^{\delta}}, \tag{1}\]  
where:  
* \(\tau_{i,j}\) is the pheromone amount on edge \((i,j)\),
* \(\eta_{i,j}\) is is the opportunity of the edge \((i,j)\),
* \(\alpha\) is a variable to adjust the effect of \(\tau_{i,j}\),
* \(\beta\) is a variable to adjust the effect of \(\eta_{i,j}\),
* \(E_{res}(i)\) is the residual energy of node \(i\),
* \(E_{res}(j)\) is the residual energy of node \(j\),
* \(\gamma\) is a variable to adjust the effect of \(E_{res}(i)\),
* \(\delta\) is a variable to adjust the effect of \(E_{res}(j)\). The pheromone quantity is renewed and applied to the retraced arcs (backtracking) as shown in the Equation (2):  
\[\tau_{i,j}=(1-e)\tau_{i,j}+\Delta\tau_{i,j}, \tag{2}\]  
where:  
* \(\varrho\) is the evaporation rate of pheromones,
* \(\Delta\tau_{(i,j)}\) is the amount of pheromone put, generally offered by :  
\[\Delta\tau_{(i,j)}=\left\{ \begin{array}{ll}\frac{1}{L},&\text{if node $i$ sends data to node $j$,}\\ 0,&\text{otherwise,}\end{array} \right. \tag{3}\]  
where:  
* \(L\) is the length of the path,  
The opportunity of the edge \((i,j)\) is given by this equation  
\[\eta_{(i,j)}=\frac{1}{\delta_{(i,j)}}. \tag{4}\]  
In this work, the WSN nodes send collaboratively their captured data to the sink. We employ the dissipation energy model [15; 16] = as shown in Figure 1. In this figure, \(E_{T(x)}(k,\delta)\) is the energy expended for the transmission of k bits along a distance \(\delta\), and \(E_{Rx}\) is the energy expended to receive a k-bit of data. The element \(E_{elc}\) depends on modulation, filtering, digital coding, and the spreading of the signal [16]. This element is the energy dissipated per bit to work both the receiver and the transmitter circuits. Figure 1: Radio energy dissipation model, adopted from [17].