# Routing Algorithm for Sensor Network Monitoring the Condition of Mining Equipment
## 4 Materials and Methods
**  
**The next step is to send information about the best neighbours to the NODE nodes behind the SINK node. **  
**A modified version of the ACO (ant colony optimisation) algorithm** **[**39; 40; 41**]** **has been integrated with the sensor network model, with the following assumptions. **  
**NODE nodes collect data about their neighbours (sent in FOLLOW_ME type packets). The data packets sent by NODE nodes, called ants, travel to neighbouring nodes selected on the basis of a probability function, leaving a pheromone in the visited nodes (whichactually corresponds to the incrementation of a variable). The probability that an ant from node \(i\) will select node \(j\) is given by the following formula:  
\[p_{ij}=\frac{\tau_{ij}^{\alpha}\cdot\varphi_{ij}^{\beta}}{\sum_{c\in I}\tau_{ ic}^{\alpha}\cdot\varphi_{ic}^{\beta}} \tag{9}\]  
where:  
\(\tau_{ij}\)--amount of pheromone left between node \(i\) and node \(j\),  
\(\varphi_{ij}\)--local criterion function value for the transition from node \(i\) to node \(j\),  
\(l\)--the set of nodes available to node \(i\),  
\(\alpha\), \(\beta\)--coefficients determining the weight between the criterion function and the pheromone. The local criterion function value is determined according to the following equation:  
\[\varphi=w_{1}\cdot RSSI+w_{2}\cdot HopTosink+w_{3}\cdot B_{state} \tag{10}\]  
where:  
\(RSSI\)--indicator of the strength of the radio signal received from a neighbouring node,  
\(HopToSink\)--the number of nodes through which the message travelled on its way to the SINK node,  
\(B_{state}\)--the battery charge level of the neighbouring node,  
\(w_{1},w_{2},w_{3}\)--the weights attributed to each criterion. The probability function depends on the transmitter power of the neighbouring node, expressed as the RSSI parameter value, the number of hops to the SINK node and the battery level of the neighbouring node. In the context of this algorithm, the objective is to find routes from the NODE node to the SINK node that minimise the travel time. Nodes with a higher battery charge are also preferred as potential neighbours. When an agent packet or ant reaches a SINK node, its route is compared with the routes of other agents. Out of all solutions, the optimum one is selected. After a certain number of iterations (number of agents sent), the SINK node sends information about the selected optimal path to all NODE nodes. Information about the pre-selected neighbours is stored in the nodes. Based on this, the message (ant) repeats the path selection process on its way to the SINK node. The SINK node sends information confirming that the data packet has reached its destination. This process is repeated for a certain number of iterations, and is also performed when certain events occur, such as the loss of a node or the appearance of a new node in the network. The modified bee algorithm [42; 43] uses three types of packets to distribute data in the network: BeeScout, BeeForager and BeeDancer. BeeScout, or messages corresponding to scout bees, are distributed randomly to other nodes in the network. As the messages travel over successive nodes, they record information about the distance travelled, i.e., the number of nodes visited and their battery charge level. When the forager bees reach the target SINK node, messages corresponding to the dancer bees are transmitted from this node, which informs other nodes of the paths travelled by the scout bees. In NODE nodes, the path length is calculated, based on the information provided by the dancer bees, using the following equation:  
\[P=\frac{w_{1}\cdot\sum RSSI+w_{2}\cdot\sum B_{state}}{L} \tag{11}\]  
where:  
\(L\)--path length,  
\(\sum RSSI\)--sum of the power of the radio signals received from the nodes comprising the path,  
\(\sum B_{state}\)--sum of the state of charge of the nodes contained in the path. If the calculated value identifying the path taken is greater than the value of the current best path, then this becomes the best path for the NODE node to send messagesthe forager bees.