Spectral line extraction based on ant-colony algorithm

A spectral-line-extraction algorithm based on the ant-colony algorithm is proposed to address the difficulty of extracting spectral lines in low signal-to-noise ratio conditions, and the problem that results from the optimal path algorithm falls into local optimization. The algorithm applies the ant-colony path-optimization strategy to detect a spectral line and constructs a corresponding mathematical model using the grid method. A new cost function is proposed to replace path length as the optimization standard in the conventional ant-colony algorithm. At the same time, the roulette rule is used to determine the direction of the next step. This algorithm improves the traditional heuristic function, increases the attraction of the target spectral line to the route search, and improves the convergence rate. Sea-trial data show that the algorithm performs better in extracting spectral lines with a low signal-to-noise ratio than the optimal path algorithm.

The criteria for selecting the number of IMF components are not given in this paper. The screening of each IMF component plays an essential role in whether the signal can be fully expressed. In Ref. [6], a method based on instantaneous phase-difference variance weighting was proposed. The fluctuation of the phase difference between sound pressure and velocity is different from that between noise signals, which improves the output signal-to-noise ratio and is beneficial for line-spectrum extraction. In Ref. [7], the cochlear advantage was used for frequency division and sharp filtering, and a linespectrum-extraction method based on the Gammatone auditory filter bank was provided. However, the author only provided the simulation results of a single line spectrum and did not analyze the situation of multiple line spectra. In Ref. [8], a space-time joint detection method by space-time domain processing was proposed in which spatiotemporal filtering can be performed on unknown line-spectrum signals in the minimum mean-square-error sense. In Refs. [10][11][12][13], the signal-to-noise ratio of the line spectrum was improved by constructing various adaptive line enhancers, which facilitate the extraction of line spectra. The results of these methods are not satisfactory when the signal-to-noise ratio is low. Other methods for extracting spectral lines include the discrete-Fourier-transformation (DFT) spectral-line-detection method, parametric modeling method, class of adaptive spectral line enhancer method [10][11][12][13], and higher-order spectral methods. Di Martino et al. [14] proposed a spectral-line-extraction method based on path optimization. The algorithm achieved the goal of extracting a spectral line by constructing a line-spectrum characteristic function such that the value of the characteristic function was a minimum for the path leading to the spectral line. The algorithm can only extract a single line spectrum, and multiple line spectra can be extracted by adding a frequency-domain sliding window. In the route-searching process for the algorithm based on path optimization, a multi-step decision method is adopted in which a local optimum replaces a global optimal solution, so the final solution might not be the global optimum. In addition, the performance of the algorithm is unsatisfactory in relatively low-signal-to-noise-ratio conditions. Attention is paid herein to the ant-colony algorithm to find an optimal global algorithm and improve the performance in low-signal-to-noise-ratio conditions. The ant-colony algorithm is an optimization method originally designed by Dorigo et al. [15], inspired by the foraging behavior of an ant colony in nature. It is widely used in cloud computing, data mining, robot path planning, and other fields [16][17][18][19][20][21][22]. It is a relatively mature global optimization algorithm with the benefits of positive feedback, parallel computing, and good robustness. In Ref. [16], α and β were dynamically adaptively adjusted by establishing an interlock between α and β in the route-searching process of an ant colony, which overcomes the demerits of low convergence speed. In Ref. [18], a method based on particle swarm optimization and an ant-colony algorithm was proposed, which uses the particleswarm-optimization method to optimize the parameters of the ant colony. This method can improve the comprehensive performance of the ant-colony algorithm and realize the rapid path planning of a robot. In Ref. [19], obstacle repulsion weights and a new heuristic factor to path-selection probability were introduced, which improve the ability of obstacle avoidance and increase the strength of the diversity. In Ref. [22], an improved ant-colony optimization algorithm was proposed to reduce the partial cross-paths and number of lost ants in the process of the general ant-colony algorithm in a blind search. The algorithm can accelerate the optimization process, has strong searchability, and nearly double the convergence speed.
Most of the ant-colony algorithms are used for path planning, and no methods for linespectrum extraction exist. Because a path is different from a line spectrum, a specific transformation is required. In a lofargram, the line spectrum is usually a bright line that can be transformed into a path by several methods. Based on the above considerations, a spectralline-extraction algorithm based on the optimal path and ant-colony algorithms is proposed to improve the line-spectrum-extraction ability.

Classical ant-colony-algorithm framework
The principle of the ant-colony algorithm originates from simulating the foraging behavior of ants. Foraging ants may secrete a pheromone along the search route. The more ants that travel a route, the higher the pheromone concentration becomes. The pheromone serves as a positive attraction for arriving additional ants; the higher the pheromone concentration, the greater the probability for the arriving ant to choose a particular route. At the same time, the pheromone will also evaporate, which allows the ants search for other routes, improves the global search capability, and avoids falling into a local optimum.
To fully describe the ant-colony algorithm, several elements must be defined: m is the number of ant colonies; i and j represent the nodes that the ant passes through; τ ij (t) represents the pheromone concentration between nodes i and j at time t, which reflects the importance of moving from node i to node j ; α represents the significance of the pheromone; η ij (t) is the expected heuristic function, which represents the inverse of the distance from node i to node j at time t; β is the expectation factor; p k ij (t) is the statetransition probability formula, representing the possibility of ants moving from node i to node j in the kth iteration; ρ is the pheromone evaporation rate, which avoids the infinite accumulation of pheromones that is usually set to be less than 1. Taboo records the nodes each ant passes through to prevent the ant from passing through the node again. When the ant passes through all of the specified nodes, it completes an iteration.
The state-transition probability formula of the ant-colony algorithm is then where allow represents the next node for the ant to go to next. Hence, where d ij is the distance from node i to node j.
After the completion of each cycle by the ant, the path pheromone is updated to where τ ij (t + 1) is the updated intensity of the pheromone from node i to node j, and �τ ij (t) is the pheromone increment from node i to node j. Three models are used to compute �τ ij (t) , i.e., the ant-density, ant-quantity, and ant-cycle models, as shown in Eqs. (5), (6), and (7), respectively, Here, Q is the intensity coefficient of the pheromone increase, and L k is the path length traversed by the ant after the cycle ends. In the ant-density and ant-quantity models, updates are based on local information, while updates are based on global information in the ant-cycle model. Experimental results have also shown that the best performance is obtained from the update method of the ant-cycle model.

Spectral-line-extraction algorithm based on ant-colony algorithm
When extracting the signal of a spectral line, the lofargram of the signal is often obtained first. According to the description in Sect. 2, the spectral lines in a lofargram may be regarded as the various paths to apply the ant-colony algorithm to extract spectral lines.

Issues when applying ant-colony algorithm to line-spectrum extraction
First, the grid method is applied to divide the lofargram into small squares. The ants are then randomly placed in the small squares to begin a search over the entire lofargram. The following issues are considered when applying the ant-colony algorithm.
1. In the classical ant-colony algorithm, the search is conducted with the ants randomly selecting any of the eight surrounding directions, as shown in Fig. 1. In the figure, a five-pointed star represents an ant. In the lofargram, the line spectrum is usually a relatively straight, bright line, which means each spectral line has a unique frequency at any given time; that is, an ant can only forage along the directions of increasing or decreasing time and cannot forage laterally. If the ants forage laterally, the calculation overhead of the algorithm will increase, and there may be more than one frequency point at a time that is unreasonable. 2. In the classical ant-colony algorithm, the starting point and destination of the ants are generally fixed. However, in the lofargram, they are unknown.
3. In the classical ant-colony algorithm, updates of the heuristic function and pheromone are determined by the distance of the ant from the destination. However, the destination is unknown in the lofargram, so this distance cannot be used as a standard for updates.

Algorithm improvements
A spectral-line-extraction method based on the ant-colony and optimal path algorithms is proposed, and the following improvements are made to address the problems described above: 1. The search area of the ants is limited; that is, each ant can only search in the direction of the time axis, and an ant cannot search horizontally. As shown in Fig. 2, the ordinate represents time, and the abscissa represents frequency. 2. Inspired by the characteristic function advanced by Di Martino et al. [14], a new cost function is proposed as a standard for determining the updates of the heuristic function and the pheromone: where ξ represents the path of the spectral line; d (i) represents the frequency continuity of the line spectrum, which reflects the frequency fluctuation of the line spectrum; G (i) represents the trajectory continuity of the line spectrum, which reflects whether the line spectrum is broken; A (i) represents the intensity of the line spectrum, namely the amplitude at each frequency point on the line-spectrum path; and eps represents the accuracy of the algorithm that prevents the occurrence of zeros in the denominator. Equation (8) shows that the greater the intensity of the line spectrum, the greater A (i), the better the frequency continuity, the smaller d (i), and the better the continuity of the path, the greater G (i). Alternatively, the smaller the cost function of the line spectrum, the smaller P_ cos(ξ ) . In the processing of underwater acoustic signals, a spectral line is often a straight line with a certain energy. Therefore, the definition of the cost function in Eq. (8)  In Eq. (9), f (P i ) represents the value of the frequency of spectral line P i at point i. In Eq. (10), g (P i ) is a flag variable defined in Eq. (11). That is to say, when g (P i ) is less than the threshold count, a break is considered to have occurred at this point; otherwise, g (P i ) is set to 1. Usually, count is set to the mean value of background noise in the frequency domain.
The new heuristic function is then which shows that the smaller P_ cos(ξ ) , or rather, the closer the search path is to the spectral line, the greater the value of the heuristic function, which is consistent with the design principles of the heuristic function. With the progress of the ant search process, the value of P_ cos(ξ ) is constantly changing, so the heuristic function is continuously updated.

3.
A considerable amount of calculation is required if all the frequency states in the lofargram are simultaneously detected. A block-processing framework is introduced to reduce the computational complexity of line-spectrum extraction and improve calculation speed. As shown in Fig. 3, the lofargram is divided into four parts, and there is a certain degree of overlap between adjacent blocks in the frequency dimension.
In Fig. 3, the abscissa represents frequency and the ordinate represents time. It is supposed that there are 17 N frequency points and K time points. The lofargram is divided into four parts in the frequency direction, i.e., 1 N-5 N, 4 N-9 N, 8 N-13 N, and 12 N-17 N, and the length of the overlapping part is N. Five-line spectra in the lofargram are represented by different colors. The function of the overlap is to prevent the loss of line-spectrum extraction. For example, the red line spectrum is incomplete in the first part (1 N-5 N in the frequency direction), which is difficult to extract successfully. However, the red line spectrum is complete and easily extracted in the second part (4 N-9 N in the frequency direction). Figure 4 shows the algorithm processing flow, where C represents the set number of iterations.

Algorithm processing flow
The algorithm processing steps are as follows.

A fast
Fourier transformation is performed for the acquired signal to obtain the lofargram spectrum and subject it to a grid process. 2. The taboo table is used to record the nodes visited by the ants. The taboo table is initialized to 1, and the node of the taboo table is set to 0 when the ant passes through the node. 3. M ants are placed randomly in the lofargram at the starting time, and the cost function P_ cos(ξ ) for each ant to proceed to the next node is calculated according to (8). 4. The heuristic factor η ij (t) is calculated from the cost function P_ cos(ξ ) according to Eq. (12). 5. The state-transition function p k ij (t) for each ant to proceed to the next node is calculated, and the direction of each ant is determined using the roulette rule. 6. The taboo table is updated, and the node passed by the ant is set to 0. The path taken by each ant in each generation is recorded. 7. When the ants traverse the time axis of the entire lofargram, it marks the end of one iteration, and the above process is repeated. 8. The n paths with the minimum cost function are recorded, and a second threshold determination is performed to remove the false line spectra. Finally, the desired spectral line is obtained.

Results and discussion
The algorithm's feasibility is verified by simulation and sea-trial data, and the proposed algorithm is compared with the optimal path algorithm.

Simulation experiment
Single-frequency signals of 30, 70, and 150 Hz and a sampling frequency of 400 Hz are used in the simulation. The frequency resolution is 1 Hz, and the total signal duration is 50 s.
The parameters of the algorithm selected are as follows: α = 7 , β = 7,Rho = 0.1 , Q = 100 , m = 400 , and L = 100 . α is the significance of the pheromone, β is the expectation factor, Rho is the pheromone volatilization coefficient, Q is the pheromone intensity coefficient, m is the ant number, and L is the number of iterations. The starting point of the ant is randomly placed at the start time of the LOFAR spectrum, and the ant reaches the destination when it finds the end time of the LOFAR spectrum.
As shown in Figs. 5, 6, 7, 8, the signal-to-noise ratios of the three spectral lines are all − 14 dB. Figure 5 shows that the signal-to-noise ratios of the spectral lines are low and the energies weak. Figure 6 shows the spectral lines extracted using the optimal  where f t (i) represents the extracted spectral line and f t (i) the real spectral line. Based on Eq. (13), the average error of the three spectral lines is 0.78. Figure 7 shows the results of the extracted spectral lines using the proposed algorithm. The lines are numbered and marked with red lines. The three spectral lines are successfully extracted, and the average error of the three spectral lines is 0.06, indicating that the performance is better than that of the optimal path algorithm. Figure 8 shows the iteration curve of the (13)   The variable detection probability P D is defined in Eq. (14) to compare the performance of the two algorithms. Figure 9 shows the P D of different line spectra using the two methods at a signal-to-noise ratio of − 14 dB. It can be seen that the P D of different line spectra using the two methods are both high, and that of different line spectra using the proposed method is higher than that using the optimal path algorithm: The signal-to-noise ratio of all three spectral lines is set to − 16 dB to verify the algorithm's performance at an even lower signal-to-noise ratio, as shown in Fig. 10. As seen in the figure, the spectral lines' energy is weak, and parts are almost buried in the noise. Figure 11 shows the spectral lines extracted using the optimal path algorithm. They are numbered and marked with red lines. The three spectral lines are extracted, but the performance is unsatisfactory. The average error is 4.35. Figure 12 shows the spectral lines  Figure 13 shows the iteration curve of the algorithm and that the algorithm quickly converges after approximately 45 iterations. Figure 14 shows the P D values of different line spectra using the two methods at a signal-to-noise ratio of − 16 dB. It can be seen that the performance of the optimal path algorithm is unsatisfactory at a relatively low signal-to-noise ratio. The P D of line (3) is only 8%, indicating that only 8% of the frequency points of line (3) are successfully extracted, which is a poor result. However, the P D of line (3) using the proposed algorithm is relatively good, reaching 70%, indicating that most of the frequency points can be successfully extracted. The other two lines can also be extracted completely, which is a satisfactory result. Figure 15 is a comparison of the detection probabilities of the two algorithms under different signal-to-noise ratios. The three lines' detection probabilities are averaged  for comparison convenience, as shown in Eq. (15). The red line represents the average detection probability obtained using the optimal path algorithm, and the black line represents the average probability obtained using the algorithm proposed in this paper. The results under each signal-to-noise ratio are obtained after 200 Monte   Carlo simulation tests. It can be seen from the figure that the detection probability of the proposed algorithm is always higher than that of the optimal path algorithm. Moreover, when the signal-to-noise ratio of the optimal path algorithm is lower than − 17 dB, the detection probability is already less than 50%, while the algorithm proposed in this paper has a detection probability of higher than 80% when the signal-to-noise ratio is − 19 dB, and the performance is better: In Eq. (15), P D (i) represents the three above-mentioned line spectra.

Sea-trial data verification
The effectiveness of the algorithm is then verified with the following two sets of seatrial data. Figure 16 shows the first set of sea-trial data for a merchant ship. These data are acquired at a sampling frequency of 10,240 Hz. Considering the actual processing needs, only the frequency band below 600 Hz is processed. The frequency resolution is 1 Hz, and the data length is 100 s. It can be seen from the figure that the original lofargram has more spectral lines, and several of them have weak energy. Figure 17 shows the line-spectrum-extraction results of the optimal path algorithm. As shown in the figure, most of the strong lines are extracted, but some weak lines are not, such as those at 381 and 400 Hz. Moreover, several false line spectra are shown, such as those at 91 Hz, and the performance is unsatisfactory. Figure 18 shows the results obtained after processing with the proposed algorithm. The figure shows that the spectral-line extraction is more complete and that the weak spectral lines, such as those at 140 and 150 Hz, are extracted more completely.    Figure 19 shows the second set of sea-trial data for another merchant ship, with more spectral lines with weaker energy. The data are processed under the same conditions as those described above. Figure 20 shows the line-spectrum-extraction results of the optimal path algorithm. The figure shows that most of the lines are extracted, but some weak lines are not, such as those at 403 and 448 Hz. In addition, several false line spectra are shown, such as those at 100 Hz. The results of the spectral lines extracted with the proposed algorithm are shown in Fig. 21. All the spectral lines are essentially entirely extracted, including the weak lines at 186 and 448 Hz.

Conclusions
This research proposes a spectral-line-extraction algorithm based on the ant-colony and optimal path algorithms to address the difficulty of extracting spectral lines with a low signal-to-noise ratio. By designing a new ant search method and a heuristic function, the proposed algorithm combines the proposed cost functions and successfully applies the ant-colony algorithm to spectral line extraction. Simulation and sea-trial data show that the proposed algorithm possesses good spectral-line-extraction capability even at a low signal-to-noise ratio.