# Energy Efficient Management of Pipelines in Buildings Using Linear Wireless Sensor Networks
## 3 Proposed Solution
### Lion Optimization Algorithm
\(U(-1,1)\) is used for the generate \(-1\) or \(1\) depending upon the direction of the resident male roaming in same or opposite direction of the pride territory respectively. The tournament process enables the pride to change its size in each iteration by using Equation (6):  
\[Size_{p}^{i}=max\left(2,ceil\left(\frac{inol_{i}}{2}\right)\right)i\ =\ 1,\ 2,\ 3 \ldots\ldots N \tag{6}\]  
where, \(inol_{i}\) is the number of lions in pride \(i\) with improved fitness in previous iteration is given by Equation (7):  
\[inol_{i}=\sum_{j=1}^{n}\mathit{success}(j,iter,N)\ i\ =\ 1,\ 2,\ 3\ldots\ldots N \tag{7}\]  
Here the \(\mathit{success}(j,iter,N)\) gives the success of lion \(j\) in group \(N\) at iteration, iter denoted by (8):  
\[\mathit{success}(j,iter,N)=\left\{ \begin{array}{l}1\ \mathit{best}_{j,N}^{iter}< \mathit{best}_{j,N}^{iter-1}\\ 0\ \mathit{best}_{j,N}^{iter}=\mathit{best}_{j,N}^{iter-1}\end{array} \right. \tag{8}\]  
The nomad lion moves randomly in the search space (explorative search) used to avoid local optima. The movement of the \(i\)th nomad in the \(j\)th is represented by Equation (9):  
\[\mathit{nomad}_{ij}^{lion}=\left\{\begin{array}{c}\mathit{nomad}_{ij}^{lion} \ \mathit{if}\ \mathit{rand}>\ \mathit{pr}_{i}\\ \  
connected even in the case of node failure. This is done by using the backup nodes placed in the pipeline at a distance of 2*R. So, we have:  
\[No_{nodes}=\frac{L}{2*R}+\frac{L}{2*R}=\frac{L}{R} \tag{12}\]  
Here, the \(\frac{L}{2*R}\) are the backup nodes used to backup the communication. The nodes may change their roles if the reverse direction flow occurs. Nodes near the sink (leader nodes) assume the liability of sending their information and sending the majority of the received messages from different nodes. Along these lines, the sent sensor systems lifetime relies on the vitality of the nodes near the sink. In the meantime, the sent nodes experience the ill effects of little support size where messages could be dropped because of non-accessibility of spare space, so the nodes near the sink consume large amounts of energy so the volunteer nodes are placed nearer the sink nodes. Moreover, these volunteer nodes are also required to check for sudden changes in the pressure to block the current flow and prevent losses due to leaks. The node placement in the pipelines of the systems is optimized using the Lion Optimization Algorithm, which is a meta-heuristic technique. Here, the number of sensor nodes is considered to be the number of lions, which consists of prides as well as wanderers. The base station (BS) is considered as the prey which is to be approached by all the other lions (sensor nodes). The number of pipelines surrounds the base station. One node closest to the base station is considered to be the leader node which is directly connected with the BS. The concept of attacking by the pride comes into play when the data has to be transferred by the nodes. The corresponding fitness to deal with the optimization of positioning the sensor nodes in LWSN is as follows:  
\[F=\frac{\alpha_{1}}{dist}+\alpha_{2}*delay+\alpha_{3}*drop\_ratio\]  
such that:  
\[\alpha_{1}+\alpha_{2}+\alpha_{3}=1\]  
_dist_ is the distance of the node from the previous node; _delay_ is the end-to-end delay and drop ratio is the ratio of the number of packets dropped to the total number of packets sent. This function is a minimization function. The target is to place the node the farthest with minimum _delay_ and _drop ratio_. The optimization function is executed in two scenarios: one is the normal and other is after ignoring the neighbor the current node. The average value of the two-fitness function is used as the decision factor. Here, \(\alpha_{1}=0.3,\ \alpha_{2}=0.3,\ \alpha_{3}=0.4\) taken is based on experiments. The whole concept can be easily understood by using the following algorithm: