# Routing Algorithm for Sensor Network Monitoring the Condition of Mining Equipment
## 4 Materials and Methods  
Attempts were made to implement the selected algorithms based on swarm intelligence in hardware, such as the particle swarm optimisation algorithm [35; 36; 37; 38], the ant swarm algorithm and the bee swarm algorithm. The modified particle swarm optimisation algorithm was successfully implemented in the sensor network model according to the assumptions. Each \(P_{i}\)-particle in the algorithm is defined by the b following relationship:  
\[P_{i}=\left[X_{i,1},\ X_{i,2},\ X_{i,3},\ldots,\ X_{i,D}\right] \tag{1}\]  
where:  
\(D\)--Dimension of the space in which the particle is located (in the case under consideration, it corresponds to the number of nodes in the network); the position of the particle in space is determined by the distance from all nodes of the network,  
\(i\)--\(i\)--th particle,  
\(X\)--position of the particle in D-dimensional space,  
The algorithm calculates velocity \(V_{k}^{i}\) and position \(X_{k}^{i}\) using the following formula:  
\[V_{k}^{i}=w\cdot V_{k-1}^{i}+c_{1}\cdot r_{1}\cdot\left(P_{best}^{i}-X_{k-1}^{i }\right)\Delta t+c_{2}\cdot r_{2}\cdot\left(G_{best}-X_{k-1}^{i}\right)\Delta t \tag{2}\]  
\[X_{k}^{i}=X_{k-1}^{i}+\frac{V_{k-1}^{i}}{\Delta t} \tag{3}\]  
where:  
Figure 4: Latency measurement with respect to node count [24]. \(w\)**--parameter that determines the weight of the previous position of the particle when determining the current position,**  
\(k\)**--**\(k\)**-th step of algorithm,**  
\(i\)**--**\(i\)**-th particle,**  
\(c_{1},c_{2}\)**--scaling parameters,**  
\(r_{1},r_{2}\)**--random numbers,**  
\(P_{best}^{i}\)**--best-fit local solution for** \(i\)**-th particle to the criterion,**  
\(G_{best}\)**--best-fit global solution to the criterion,**  
\(\Delta t\)**--time step length (it is assumed that the step length is equal to the unit time). **  
**Initially, the values of the previous position and velocity, as well as the local and global criteria of the best-fit solution are randomly determined from the range (0, 1>. Each particle is a representation of a solution, where, in the context of this case, the solution is the path from a node of type NODE to a node of type SINK. **  
**A specially designed objective function is used to find the optimal solution according to the following set of criteria** \(F_{dest}\)**:**  
\[F_{dest}=w_{1}\cdot RSSI+w_{2}\cdot HopToSink+w_{3}\cdot B_{state} \tag{4}\]  
**where:**  
\(w_{1},w_{2},w_{3}\)**--weights for each criterion taking values in the range (0, 1>,**  
\(RSSI\)**--power of the radio signal transmitted from a neighbouring node,**  
\(B_{state}\)**--battery charge level of the neighbouring node,**  
\(HopToSink\)**--number of hops, transmissions between NODE nodes on the way to a SINK node. **  
**The objective function for determining the best local solution and the best global solution:**  
\[P_{best}= \begin{cases}P_{i},&\quad if\ F_{dest}(P_{i})<F_{dest}(P_{best})\\ P_{best},&\quad else\end{cases}  \tag{5}\]  
\[G_{best}= \begin{cases}P_{i},&\quad if\ F_{dest}(P_{i})<F_{dest}(G_{best})\\ G_{best},&\quad else\end{cases}  \tag{6}\]  
**Once the criteria for the best fit are established, the position and velocity of each particle are recalculated. The computational process is carried out by the SINK node, based on the information received from the NODE nodes, collected during the execution of successive iterations. NODE nodes collect information about the state of their neighbours to then send to the SINK node. **  
**In the context of the fixed table of neighbours of the NODE-type nodes of the:**  
\[N_{wi}\big{[}w_{x},\ w_{y},\ w_{n}\big{]} \tag{7}\]  
**where:**  
\(w_{x},w_{y},w_{n}\)**--parameters defining the neighbours of the node** \(w_{i}\)**,**  
**The index for selecting the best neighbour is determined by the equation:**  
\[n=X_{i}\cdot LN \tag{8}\]  
**where:**  
\(X_{i}\)**--**\(w_{i}\) **node location,**  
\(LN\)**--number of available neighbours of the node** \(w_{i}\)**.