Research on Underground Chemical Gas Monitoring and Target Location Based on an Improved Moth Flame Algorithm

The danger of downhole work is mainly due to the chemical toxic gases and flammable gases NO2, CO, SO2, H2S, CH4, CO2, etc. When the concentration reaches a certain value, it will produce very great harm. With the continuous development of sensor technology and communication technology, it is necessary to monitor the relevant geographic features below the ground. Because of the complex environmental parameters of the coal mine roadway and the interference caused by various electrical equipment, the transmission of mine electromagnetic signals will be affected, resulting in low positioning accuracy. However, the underground chemical gas leakage leads to the life of underground workers which cannot be guaranteed, so it is necessary to effectively monitor the concentration of chemical gas components in underground mines. In this paper, a moth flame algorithm based on optimized inertia weights is proposed. By continuously improving the local inertia weights, the global optimum is determined by using the change of inertia weights in the iterative process of the algorithm. By testing the convergence and optimal value of several algorithms under common test functions, IMFO can obtain the global optimal solution. Finally, the concentrations of chemical gases NO2, CO, SO2, H2S, CH4, and CO2 are monitored by setting specific areas to see if they reach the early warning values. Then, 16 coordinates in the region are used to predict the above method, and the IMFO algorithm can achieve the best prediction effect.


Introduction
Because the mining operation of coal resources is below the ground and has high harmfulness, there are still hundreds of people who pay their lives due to coal mining every year, and major accidents often occur. With the continuous development of sensor technology and communication technology, it has become a realistic need to monitor the relevant geographic feature information below the ground. Nowadays, with the development of wireless sensor network communication technology, smart mines also appear and Zigbee technology, radio frequency identification technology, WiFi network technology, and UWB technology are also gradually put into use in mine environment. Due to the complex environmental parameters of the coal mine roadway and the interference caused by various electrical equipment, the transmission of mine electromagnetic signals will be affected, resulting in low positioning accuracy [1]. Therefore, the wireless sensor network technology and algorithm used to realize accurate mine positioning are an important research direction of the mine positioning system at present. Whether the massive data generated under the above technical background can accurately measure the specific position has become a hot spot in the research of the positioning algorithm. Therefore, how to build a complete and reliable wireless sensor network combined with the actual positioning algorithm to complete the real-time positioning of underground personnel is an important issue in current research [2].
Considering the difference in testing accuracy and model mismatch between noise positioning algorithms [3], a nonlinear fading filtering algorithm with a single fading factor is proposed to remove noise, and the sensitivity of the algorithm is improved by combining the least square algorithm. The results show that the positioning accuracy is better than Kalman filtering. The weights of different positioning algorithms are fused by fuzzy theory [4], and then, the positioning information is predicted by the weighted average method. The weights of three different positioning methods are applied to dynamically adjust the covariance of measurement noise. On the other hand, based on the theoretical model of wireless transmission signals, the weighted average value of the attenuation index of signal transmission paths is obtained periodically and optimized in combination with the genetic algorithm. This method is an intelligent swarm algorithm, a hot issue studied [5]. A large number of calculations by the genetic algorithm in underground environment lead to low search efficiency and poor stability in the later stage of evolution. In PSO [6], each particle in the best position is used to give inertia weights of different dimensions, different particles have different tasks, and the acceleration parameters of PSO are determined by different adaptive weights. Using the correlation sequencing function, the algorithm is tested, and the performance advantage of the proposed method is obvious in convergence speed. Considering that the underground environment is complex and affects the weighted centroid positioning [7], the genetic algorithm is used to optimize the weighting, and the improved method is superior to the traditional method in accuracy. In order to improve the positioning accuracy, a gradient enhanced regression tree positioning algorithm [8] is proposed, which fuses the positioning results of the KNN, random forest, SVM, and multilayer regression algorithm. It can see that the fused positioning can better improve the positioning accuracy of the algorithm. Aiming at the problem of low matching positioning accuracy such as MSD and MAD [9], the MPMD matching algorithm based on the feature vector product is used to improve positioning accuracy, and the results are better in error and pit noise. In view of the blind areas in the mining and monitoring of underground coal resources, document [10] proposes an improved DV-Hop positioning and monitoring system, which can accurately track personal operations, calculate the distance per jump of anchor nodes, and collect relevant operation safety data. To improve the positioning accuracy, ensure the safety of personnel and improve the production level underground in complex environment. In the wireless network environment, especially in the narrow underground space and complex working environment, there is a contradiction between its positioning error and wireless broadband. Literature [11] proposes a positioning algorithm based on PSO and Taylor-D. PSO provides optimized coordinate information, thus further reducing the positioning error and obtaining higher positioning accuracy. Literature [12] is aimed at the problems of unstable WLAN information and low positioning accuracy in narrow space; it is proposed to fuse GPS and WLAN data information, sample the integrated data, and realize particle weight by combining the Kalman filter and map. Thus, the advantages of GPS and WLAN positioning are realized, and the positioning accuracy is improved.
Inspired by moth navigation in nature, Mirjalili proposed a moth flame optimization algorithm (MFO) in 2015 [13], which is based on moth behavior and achieves a good balance between exploration and development through a special mechanism called lateral directional navigation to obtain global optimization performance. Because of the high efficiency of MFO in optimization, it has many applications in many fields and the effect is better [14]. Literature [15] constantly updates the flame position by adjusting the weight function, so as to achieve the goal of global optimization. Constantly accelerate the convergence efficiency, and calculate the adaptive value to infer the optimal position. Experiments show that the improved MFO algorithm can get the global optimization and the best performance in path optimization. Literature [16] proposes an improved IMFO based on exploration/development rate control in the field of machine learning for feature selection. Literature [17,18] proposed a moth flame algorithm and solved the engineering optimization problem successfully. The improved MFO algorithm has achieved good results in specific applications. However, it must be admitted that, in solving complex peak function optimization problems, it is necessary to design a new improved MFO algorithm to improve the global optimization performance of MFO, aiming at the problem that MFO is easy to fall into local optimization and leads to low global search accuracy. In view of the difficulty in predicting the underground location, this paper puts forward an improved IMFO algorithm to improve the prediction accuracy of the underground geographical location. The algorithm can solve the problem of low position prediction accuracy and can improve the position prediction accuracy in different spaces. The above research is based on the position prediction in two-dimensional space or the existence of insufficient accuracy. At present, the accuracy of geographical position prediction is insufficient, and it is impossible to predict effectively in three-dimensional space. The second part introduces the MFO algorithm and explains the algorithm flow. In the third part, there are some problems in improving MFO, and the linear decreasing inertia weight adjustment strategy is used to improve MFO algorithm. In the fourth part, the performance of the improved IMFO algorithm is compared with those of other algorithms.

Population Initialization.
In order to be able to simply describe the MFO algorithm, the moth as an individual is in the optimal position in the solution space. By continuously optimizing the position, we can achieve the goal of global optimization. The MFO model is described by where n is moths' number and d is the dimension of the optimization problem. The individual fitness value of moths 2 Journal of Sensors is stored in the OM matrix: The flame is the optimal position obtained in the local area. Formula (3) describes the optimal position relationship, and the adaptive value is described by OF.
2.2. Location Update Mechanism. In the process of position optimization of the MFO algorithm, moonlight is used for positioning and navigation. However, moths are prone to fall into artificially set nonmoonlight navigation, which leads to the wrong position. In daily life, moths fly spirally under the light. This characteristic behavior puts forward the MFO algorithm, and moths constantly update their position relationship through moonlight navigation, so that they can search for the best position scheme.
(1) Flame catching behavior: moth M j , which has phototactic characteristics in nature, will move towards the nearest light (flame) F j . Choose the logarithmic spiral described in equation (5) as the moving track of moth catching flame: where SðM i , F j Þ is the updated moth position, b is a constant, t is a random number from -1 to 1, t = −1 is the closest to the flame, and t = 1 is the farthest from the flame. D i = j F j − M i j is the distance between moths M j and flames F j, that is, the step length.
(2) Abandoning flame: MFO constantly adjusts the adaptive value to reach an optimal position, and its flame is constantly decreasing as described by In this, t represents the local maximum iteration number, T represents the global maximum iteration number, and N represents the maximum flame number. Local search is to continuously update the location information of subpopulations to get the optimal location solution. Formula (7) is as follows: where D i ∈ ð0, 1Þ and D min and D max denote the mini-mum and maximum moving steps. D i is the offset of position update and constantly adjusts the current position, so as to achieve a certain position offset during position search, which is more conducive to achieving global optimization.

Improved Moth Flame Optimization Algorithm
The nonfree lunch optimization theorem shows that none of the optimization algorithm can solve all optimization problems, and the MFO algorithm also faces the above problems. MFO is prone to premature convergence and fall into local optimum when dealing with complex function problems, so it needs to be improved to improve its performance. Chaos refers to a nonrepetitive chaotic dynamic system with ergodicity. Kent chaos and logistic chaos are isomorphic, and it has been proven that they can search accurately with good distribution. Literature [14][15][16] compares the ergodicity of the two. The logistic probability distribution is uniform in the middle and high at both ends, resulting in uneven ergodicity of logistic mapping. However, Kent mapping is evenly distributed in each interval, and good randomness, ergodicity, and uniform distribution characteristics are beneficial for the MFO algorithm to mine around the local optimal solution to search for a better solution. In addition, weight parameters have an important influence on the global and local search of the MFO algorithm, and a single invariant fixed weight will restrict the function of weight adjustment. In order to further improve the convergence accuracy, besides considering the iterative stage of the algorithm, the fitness value of the moth in the iterative process should also be considered; that is, a linear decreasing inertia weight adjustment strategy determined by the iterative stage and the fitness value of the moth is proposed.

Linear Declining Inertia Weight Adjustment Strategy.
With the continuous optimization of the current value of the MFO algorithm, the algorithm falls into the local optimum in the complex and high-dimensional optimization process and cannot jump out of the local search process. Experimental simulation shows that the global optimal effect can be achieved by adjusting the inertia weight. Therefore, this paper considers that the inertia weight will degrade the performance of the algorithm in the complex nonlinear optimization function. Combined with the adaptive degree value, a position updating method is proposed to change the inertia weight.
where t start is the initial value of the algorithm, t end is the final value of the algorithm, 0 < t start < t end < 1, maxiter is the 3 Journal of Sensors maximum number of iterations of the algorithm, i is the current number of iterations, t i is the inertia weight, Φ fit is the fitness value factor associated with fit, and w i is the adaptive inertia weight.
In order to make better use of inertia weight adjustment to achieve local and global search ability, the object position update formula after inertia weight w i is introduced into the algorithm which is updated to w i plays a decisive role in the value range of D k i and decreases with the local optimal solution approaching the optimal solution. The learning experience optimization value of MFO is adopted to improve the optimization ability of MFO.
w i represents the predicted trajectory of the MFO motion. When the local optimal solution appears, the inertia weight is relatively large, which leads to the local optimal value; when the global optimal solution appears, the inertia weight is characterized as relatively small, which is more conducive to the further search of the whole local optimal value. Further optimize the linear inertia weight: ð10Þ ω i ðtÞ represents the inertia weight of each i moth; ω max and ω min represent the maximum and minimum values of inertia weights. fit j represents the number of iterations of the current subpopulation, and max it i represents the maximum number of iterations of the subpopulation. The linear inertia weight decreases linearly with the increase in population iteration times. The linear decreasing strategy of inertia weight is simple and intuitive and has good optimization ability. However, the local search process of the population is a nonlinear and complex process, and the linear decrease in inertia weight cannot accurately reflect the search process. Therefore, this paper puts forward inertia weight: The above linear inertia weights are decreasing, and with the continuous iteration of the algorithm, the inertia weights will become smaller and smaller. When the inertia weight is initialized and when the inertia weight changes obviously, it shows that the local optimal situation is easy to appear. When the inertia weight algorithm does not change obviously in the later period, it shows that the algorithm is searching for the global optimal solution and it is easy to get the global optimal solution.

Moth
Cross-Border Mirror Strategy. Formula (9) constantly optimizes the position, but the coordinates are easy to cross the boundary and will be limited to the boundary. In this way, the performance of the algorithm will be reduced a lot, and the global optimal value cannot be obtained, thus affecting the overall performance of the MFO algorithm. In view of the above problems, the boundary problem is adjusted by where m i,j is the j-th dimension crossing position in the i -th moth; L j and U j are the value ranges of the j-th dimension. The multiple repetitive operation formula (12) can map m i,j to the range of the dimension, thus ensuring the diversity of the population and effectively improving the optimization performance of the MFO algorithm.
As the fitness value and iteration times show a nonlinear decreasing trend, Figure 1 shows the dynamic inertia weight change curve. The MFO algorithm iteration is the trend of change in Figure 1; when the algorithm is in the initial stage, the value is close to 1. It decreases rapidly with the change of iteration number and fitness value. When the iteration number is 35, the W value is about 0.293. The optimized position is shown in Dynamic inertia weights and iteration times and fitness value show a nonlinear relationship and artificial moth adaptive value to the better flame movement and effectively improve the search ability of the MFO algorithm.

IMFO Algorithm
Steps. The IMFO is shown in Algorithm 1.

IMFO Algorithm Performance Test
This paper selects four commonly used functions for experimental comparison.
The Rastrigin function has many local optima, and global optimum is difficult; the Ackley function has less global optimum and more local optimum; the Griewank function has several local optimum solutions, and the global optimum solution is difficult to realize. The optimal range and global optimal value of the four functions are shown in Table 1. According to the above operation results, f 1 -f 4 function is shown in Table 1.
The above f 1-f 4 function is tested, and its function image is shown in Figure 2.
f 1 -f 4 test functions are representative, including unimodal functions and multimodal functions. The purpose of the test is to detect the advantages of the proposed algorithm in algorithm performance. From the sequencing effect of the f 1 -f 4 function, the algorithm proposed in this paper has obvious advantages. The theoretical value is the global optimum value. Generally, there are one theoretical value and several   Journal of Sensors local optimum values in multimodal functions. If the test result of the function reaches or approaches the theoretical value, it represents the global optimal value. The design dimensions of the common functions are 10, 30, and 50, respectively. The test function is tested 100 times, and the average value is taken, and the optimal average value (mean) and standard deviation (SD) are taken. Table 2 lists the numerical results of PSO, MFO, and IMFO under four test functions.
From the test average and mean square error analysis of the four algorithms in Table 2, PSO and MFO algorithms have the same performance, and the IMFO algorithm is the best. For functions f 1 -f 4 , the performance of the IMFO algorithm is globally optimal. When the dimension is increased to 50, the IMFO optimization performance still has high accuracy, and the standard deviation is the smallest among the four algorithms. The optimal solution found by IMFO for the f 4 test function does not reach the theoretical optimal value and is still the smallest in value compared with other algorithms. For the multimodal function f 1 , the IMFO algorithm is improved from 8:652 × 10 −15 , 3:578 × 10 −2 , and 1:135 × 10 −1 optimized by MFO to 8:754 × 10 −16 , 8:654 × 10 −16 , and 8:231 × 10 −16 in 10, 30, and 50 dimensions, respectively. The standard deviation is 0, and the IMFO algorithm has the best performance.

Monitoring of Chemical Gas Concentration.
Due to the danger of CH 4 , CO 2 , CO, NO 2 , H 2 S, and SO 2 emitted from coal seam during mining, effective monitoring of these gas concentrations can improve the safety of downhole operation. The safety level of chemical gas is shown in Table 3.
Underground air quality monitoring can predict the danger, can effectively predict the future air quality, and can establish a set of safe methods.
The IMFO algorithm proposed in this paper is used to predict the air quality of underground operation and give early warning of possible dangers in time. The errors of using three algorithms to predict underground air quality are shown in Figures 3 and 4.
The IMFO algorithm in the prediction of chemical gas algorithm error is the best and can achieve the effect of prediction.

Location Prediction Algorithm.
In order to verify and analyze the positioning accuracy and antinoise performance of this method, MATLAB simulation experiments are carried out and compared with PSO, MFO, and IMFO algorithms proposed in this paper. Because of the special underground environment, the accuracy of spatial ranging is affected, so the simulation environment is set to be in a cuboid threedimensional area with a certain size.
Objective function is a standard to measure the advantages and disadvantages of IMFO. In each iteration of the algorithm, the position of moths needs to be updated according to the value of objective function. It is assumed that M beacon nodes are deployed in the location area, their coordinates are ðx i , y i , z i Þ, i = 1, 2, ⋯, m; the coordinates of unknown nodes are ðx, y, zÞ; the distance measured by the RSSI method is d i ; and the average location error is the average value of the location error obtained by repeating the experiment 30 times. In order to reduce the ranging error,     Journal of Sensors the mean square error of the measured distance and the estimated distance of the unknown node and the beacon node is taken as the optimization objective function. The objective function is The coordinate data in a specific area are shown in Table 4.
The IMFO algorithm is used to predict the actual coordinates, and the effect is shown in Figure 5.
The errors of PSO, MFO, and IMFO algorithms are compared below, and the errors are compared and analyzed by equation (18). The results are shown in Figure 6.
As can be seen from Figure 6, IMFO has the smallest error in different coordinates compared with other algorithms, and most values are less than 1.

Conclusion
The wireless sensor network technology and algorithm used to realize accurate mine positioning are an important research direction of the mine positioning system at present. Whether the massive data generated under the above technical background can accurately measure the specific position has become a hot spot in the research of the positioning algorithm. In this paper, the IMFO algorithm is proposed to compare the predicted coordinates with the actual coordinates in a specific area, and the prediction effect is good and the error is small. Further research in the future focuses on the problem of signal transmission, the diversity of prediction, and the application of algorithms in different scenarios. It can compare other intelligent algorithms and select the advantages of different algorithms to fuse to predict.

Data Availability
The raw data supporting the conclusions of this article will be made available by the authors, without undue reservation.

Conflicts of Interest
The authors declared that they have no conflicts of interest regarding this work.