# Performance Analysis of IoT-Based Health and Environment WSN Deployment
## 3 Health and Environment Sensor Network Deployment
### BA-Based Sensor Network Deployment  
In the BA algorithms, the optimized locations of sensor nodes of the network are determined by simulating bees' behaviors in seeking the best food source with the aim of maximizing the coverage and lifetime. The BA contains three kinds of bee including employed bees (assigned to food sources), onlooker bees (watching the dance of employed bee), and scout bees (searching new food sources randomly) [66]. Figure 3 shows the BA-based sensor network deployment algorithm. The algorithm is explained step by step below.  
Step 1: Generate an initial random population with \(p\) number of employed bees that creates a bee colony. Each bee, representing one sensor network (Figure 4), is generated by UDG with \(n\) vertices at random position. Each vertex represents a sensor node, a resource, in the WSN. The vertices that are not located in the communication range of the sensors are not connected to each other in the graph. The connectivity of the generated random graph is checked by using its adjacency matrix (G) if and only if [16].  
\[\mathrm{Y}=\mathrm{G}+\mathrm{G}^{2}\ldots+\mathrm{G}^{n-1}\ \
eq 0 \tag{12}\]  
\[\mathrm{G}=\left\{\mathrm{x}_{i\j}\right\}_{n\times n}\mathrm{i}=1,\ \ldots,\ \mathrm{n};\mathrm{j}=1,\ \ldots,\ \mathrm{n} \tag{13}\]  
Figure 3: Bees Algorithm (BA) for Minimum Spanning Tree (MST)-based network deployment.  
If the generated random graph is not connected, the positions of some vertices are changed until the connected UDG graph is obtained. To do this, first the connected components of the graph are found, then the positions of the vertices of a component with the minimum number of the vertices are changed toward the nearest component.  
Step 2: Generate MST based on the Kruskal algorithm and distances between the sensor nodes as weights of the edges from the generated UDG.  
Step 3: Evaluate fitness function, according to Equation (13), of the employed bees of the initial population.  
Step 4: Set t = 0. The following steps are done until t less than the number of generations (t \(<\) N\({}_{\text{iteration}}\)).  
Step 4.1: Select m bees that have higher fitness value (\(f_{i}\)) as better bees.  
Step 4.2: Select e elite bees from m selected bees.  
Step 4.3: Recruit onlooker bees to search in the neighborhood of each selected e elite and (\(m\) - \(e\)) better bees and evaluate their fitness. To do this, the neighborhood search distance and size for searching around each type of selected bee. The neighborhood search distance shows how many vertices of the bee can be changed randomly in the sensing range. In other words, the searching distance in the sensor network deployment is a number that determines the position of maximum how many sensors can be changed based on the type of bees (dep for elite bees and dbp for better bees). Therefore, in this step, the position of the random number of vertices is changed randomly in the neighborhood search of the bee, as below:  
\[\text{x}_{\text{i}} = \text{x}_{\text{i}}\ \pm\text{Rand}\ (0,\ \ d) \tag{14}\] \[\text{y}_{\text{i}} = \text{y}_{\text{i}}\ \pm\text{Rand}\ (0,\ \ d) \tag{15}\]  
The searching size means the number of onlooker bees for searching around the bees. The number of onlooker bees in the WSN deployment is the number of new bees that can be generated by changing the position of the network vertices of the selected bees. The number of onlooker bees for elite and better bees is different, so nep and nbp are the numbers of onlooker bees sent to search the neighborhood around the elite and better bees, respectively. It should be noted, the network connectivity also is checked after the position of the vertices changed.  
Step 4.4: Select a best bee at each neighborhood search.  
Step 4.5: Assign (s = n - m) scout bees to randomly search and evaluate their fitness.  
Step 4.6: t = t + 1.  
Step 5: Find the best global bee (WSN).  
Figure 4: Schematic example of Bee with \(n\) = 10.