Design of Digital Infinite Impulse Response Filter Based on Artificial Fish Swarm Algorithm

Filter design is an indispensable part in the field of digital signal processing technology. With the continuous improvement of signal processing requirements, the calculations required for digital filter design are becoming more and more complex. Therefore, using biological intelligent optimization algorithms has very important practical significance in improving the quality of digital filters design. According to the characteristics of the infinite unit impulse response filter, taking the coefficients of the system function as the optimization variable, this paper constructs the mathematical optimization model of the digital filter design, which takes the minimum square error of the system function of the design filter and the ideal filter as the optimization the goal. The artificial fish swarm algorithm is used to solve the optimization model of the digital filter, and the realization process of the artificial fish swarm algorithm to solve the filter optimization model is given. We use MATLAB software to simulate, compare and analyse the influence of artificial fish swarm algorithm parameters and filter parameters on the design results. The experimental results show that the artificial fish swarm algorithm can effectively design the digital filter, and the amplitude-frequency response curve of the optimized filter is roughly the same as that of the ideal filter.


Introduction
Digital filter is an important part in the field of digital signal processing technology. It separates the effective signal from the interference signal in the input signal through a certain algorithm to obtain a noise-free effective signal [1] [2]. Digital filters include finite impulse response filters (FIR) and infinite impulse response filters (IIR) [3].
The digital filter design mainly divides into two types: The first type is to design an analog filter according to the design requirements, and then transform it into a digital filter through an analog-todigital converter [4] [5]. The second category is to use the biological intelligence optimization algorithm [6] [7] to optimize the target parameters of the digital filter designed to obtain the optimal solution.
With the continuous improvement of signal processing requirements, it is of great practical significance to adopt biological intelligent optimization algorithms to improve the design quality of digital filters. This paper establishes the optimal design model of IIR digital filter, uses artificial fish school optimization algorithm to solve the mathematical model, gives the realization process, discusses the influence of algorithm parameters on the design effect, and realizes the optimal design of digital filter. z H k k k k N k (2) Where, N is the number of second-order nodes, A is the gain,   Since the phase of the IIR digital filter is nonlinear, the amplitude-frequency response is considered in the design process. Assuming that the amplitude-frequency response of an ideal digital filter is , the design goal is to make the square error of the amplitude-frequency response between the designed filter and ideal filter, namely, Find the partial derivative with respect to gain A in formula (6), and then make the partial derivative equal to zero, then the analytical expression of gain can be solved, In order to ensure the stability of the system, it is necessary to ensure that each pole is within the unit circle of the Z-plane domain, that is, the poles of In order to minimize the phase shift of the design filter, the value range of k a and k b is

Artificial fish model
Artificial Fish Swarm Algorithm (AFSA) is an intelligent optimization algorithm, which achieves the purpose of optimizing by simulating the process of fish searching for food in nature [10] [11]. The artificial fish swarm algorithm simulates the process of finding food in the natural as an optimized solution process of mathematical problems. The living environment of a fish population in nature is a set of feasible solutions to the mathematical problem. Each artificial fish represents a feasible solution. It perceives information in the environment through vision and smell, distinguishes the behavior at the next moment, and controls itself to make corresponding behavior choices. At the same time, they use internal information exchange to influence other artificial fish. Finally, the fish finds the place with the highest food concentration, that is, to obtain the optimal solution to the problem.

Artificial fish behavior analysis
Observing the situation of the fish in the water, you can find the following behaviors [12].
Foraging behavior: The behavior of a fish population looking for food, generally relying on the perception of artificial fish to search for food in the water, this is an instinctive behavior that the fish population depends on for survival.
Swarming behavior: It is an animal's behavior in nature to seek advantages and avoid disadvantages. In order to increase the survival rate, fish often gather to form population and forage together.
Following behavior: When a certain fish finds food, it will transmit the information to other fish through the communication within the population. The nearby fish will follow the fish that found the food, and the fish further away will follow it.
Random behavior: Each fish in the population is randomly distributed in the water, swimming randomly to find new food.
The above are the behaviors of fish looking for food, and they will randomly change behaviors by sensing environmental information to find high-concentration food as soon as possible. Maximum number of iterations: G represents the iterations for artificial fish to find optimal food. Visual distance: isual V , which means the detection range of artificial fish [13]. When the detection range of the artificial fish becomes larger, the search range of the artificial fish will be larger, and it will be easier to find a companion. Otherwise, the search range of the artificial fish will become smaller.

Mathematical
Maximum moving step: tep S , which means the distance of the artificial fish moves once. When the step size increases, the convergence speed will increase, but when it reaches a certain level, the convergence speed will decrease as the step size increases.
Crowding factor:  , which represents the maximum distance allowed between each fish [14]. When  increases, the allowable distance between each fish will increase, the fish will not be crowded together easily, and it will be easier to jump out of the local optimal solution.
Bulletin board: used to record the highest food concentration and its location. After each artificial fish chooses to perform a certain action, it will compare its current state with the bulletin board, and the larger one will be updated to the bulletin board until the iteration termination condition is satisfied.

Behavior description
Artificial fish perceive the environment and perform foraging or random behaviors when they detect that there is food and the surrounding area is not too blocked. Then exchange information with the inside of the fish, choose to perform swarming behavior and following behavior to find the best food concentration [15].
(1) Foraging behavior Set the current state of the artificial fish as i x , and randomly select a state within the visual field, (8) Where,

 
Rand means to randomly generate a number in the range of [0,1].
If the food concentration in the new state r x is higher than the food concentration in the current state i x , move one step along the state, that is, Otherwise, select a state r x again, perform the above judgment. After repeated multiple times to reach the maximum number of trials number -ry T , if the new state still cannot be found, perform random behavior, (10) (2) Swarming behavior Judge the number of artificial fish in the visual field, find the centre position c x , if the food concentration in the centre position is high, the artificial fish will move one step to the centre position, namely, Where, ic d represents the distance between the artificial fish and the centre of the fish population, otherwise, it performs foraging behavior.
(3) Following behavior x with highest food concentration, if the optimal artificial fish is not crowded, the artificial fish will move one step to the position of the optimal fish, namely, Where, io d represents the distance between the artificial fish and the optimal fish, otherwise, it performs foraging behavior.
(4) Random behavior If the artificial fish finds food, they move randomly in the water, (13) After each artificial fish chooses to perform a certain behavior, it will compare its food concentration with the bulletin board, and update the bulletin board when its food concentration is greater.

Artificial Fish Swarm Algorithm for Digital IIR Filter Optimization
The artificial fish swarm algorithm is used to complete the optimization design of the digital filter. The basic idea is to determine the corresponding relationship between the artificial fish state, the food concentration of the artificial fish swarm algorithm and the digital filter design problem. According to the technical indicators of the ideal digital filter, we use the continuous iterative update of the fish population to complete the design process of the filter and finds the optimal filter design result.
The system function coefficients to be optimized of the digital filter corresponds to the state of the individual artificial fish The artificial fish is looking for the state with the highest food concentration, so the reciprocal of the square error between the design filter and the ideal filter is taken as the food concentration, To achieve the optimal performance of the designed filter, the square error of the digital filter corresponding to the artificial fish individual must be minimized, that is, the E function value must be minimized. After reaching the maximum number of iterations, the place with the highest food concentration is the position of the optimal solution.
The flow chart of digital filter design based on artificial fish swarm algorithm is shown in Figure 1. The specific steps are as follows.
Step1: Set the parameters of the artificial fish swarm algorithm and the digital filter. Set the value range of the parameters   , the discrete frequency sampling points M , the number of second-order nodes N , the technical indicators of the ideal filter, the population size of artificial fish P , the number of trials number -ry T , the maximum number of iterations G .
Step2: According to formula (7), calculate the gain A , and then use formula (14) to calculate the food concentration corresponding to the artificial fish.
Step3: The artificial fish chooses behavior, and after each action, the food concentration in the new state is calculated and compared with the value on the bulletin board, and the larger one is updated to the bulletin board.
Step4: Repeat Step2 to Step3 until the maximum number of iterations is reached. At this time, the optimal artificial fish corresponds to the optimal parameters of the design filter.

Results Analysis
MATLAB software is used to realize the digital filter design based on artificial fish swarm algorithm, and the influence of artificial fish swarm algorithm parameters and filter parameters on the optimization results is analysed.
The technical indicators of an ideal low-pass filter are, The amplitude-frequency response curve comparison between the designed digital low-pass filter and the ideal low-pass filter is shown in Figure 2. The solid line is the ideal low-pass filter, and the dashed line is the designed IIR digital low-pass filter. It can be seen from the figure that, the passband cut-off frequency of the digital filter designed with the AFSA algorithm is about 0.3π, the passband ripple is relatively large, and the stopband cut-off frequency is about 0.62π, which is similar to the amplitude of the ideal digital filter.
The error curve is shown in Figure 3. It can be seen that after the number of iterations reaches 75 times, the square error tends to stabilize, and the square error is about 2.54.
, other parameters remain the same as in Figure 2, and the result is shown in Figure 4. It is found that the cut-off frequency of the passband is around 0.3π, the ripple fluctuation of the passband is slightly larger than that in Figure 2, and the cut-off frequency of the stopband is about 0.62π, but the amplitude of the stopband is about to attenuate to the minimum.
The error curve is shown in Figure 5, it can be seen that when the number of iterations reaches more than 70 times, the square error tends to be stable. At this time, the square error is about 2.46, which is much smaller than that in Figure 3. It shows that appropriately reducing the perception distance of artificial fish can reduce the error between the designed digital filter and the ideal digital filter.  , and other parameters are the same as in Figure 4. The design result is shown in Figure 6, the passband cut-off frequency is about 0.3π, and the amplitude does not change much compared to Figure 4; the stopband cut-off frequency is about 0.63π, and the amplitude of the stopband is higher than the stopband amplitude of Figure 4. It is obviously reduced and has been attenuated to a minimum, but there is still a certain error with the amplitude of the ideal filter. Figure 7 shows the error curve, it can be seen that after the number of iterations reaches 70 times, the square error tends to stabilize. At this time, the square error is about 2.44, which is smaller than the error in Figure 5. It shows that appropriately increasing the number of artificial fish can reduce the error between the designed digital filter and the ideal digital filter.   Figure 8. It can be seen that the passband cut-off frequency is around 0.3π, and the amplitude of the passband is slightly reduced compared to Figure 6. The stop band cut-off frequency is about 0.67π, but the error of the two characteristic curves on the stop band is slightly increased.
The error curve is shown in Figure 9. It can be seen that when the number of iterations reaches about 30 times, the square error tends to be stable. At this time, the square error reaches 2.48, which is slightly larger than the error in Figure 7. It shows that increasing the number of second-order sections of the digital filter has little effect on improving the design effect.   Figure 6, the design result is shown in Figure 10. The passband cut-off frequency is at about 0.3π, compared with Figure 6, the amplitude of the passband does not change much; the cut-off frequency of the stopband is about 0.63π, and the amplitude of the stopband does not drop to 0 at the lowest.
Compared with Figure 6, the error between its amplitude-frequency characteristic curve and the amplitude-frequency characteristic curve of an ideal digital filter in the stop band is significantly increased. The error curve is shown in Figure 11. It can be seen that when the number of iterations reaches about 50 times, the square error tends to be stable. At this time, the square error reaches 3.68, which is much larger than the square error in Figure 7. The reason might be that when increases the frequency sampling points, the algorithm falls into the local optimum.  Figure 12, the passband cut-off frequency is around 0.3π, and the stopband cut-off frequency is around 0.65π. Compared with Figure 6, it can be seen that the error on the stop band is basically unchanged, but the amplitude of the stop band is significantly reduced. The square error change curve is shown in Figure 13. It can be seen that when the number of iterations reaches 50, the square error tends to stabilize. At this time, the square error is about 1.21, which is significantly reduced compared to Figure 7.  fully show that the artificial fish school algorithm can effectively design the low-pass filter, so that its amplitude-frequency response curve approaches the ideal digital filter.

Conclusion
In this paper, an optimization model of the digital filter is constructed. The coefficient of the digital filter is used as the optimization variable. The optimization goal is to minimize the square error between the design filter and the ideal filter. The artificial fish swarm algorithm is used to optimize the design of the digital low-pass filter. The amplitude-frequency response curve of the designed low-pass filter is given. The influence of the parameters of the AFSA and the filter parameters on the optimization effect is analysed, and the effectiveness of the filter designed by the artificial fish swarm algorithm is verified.
The paper uses artificial intelligence algorithms to complete the design of digital filters, which is very necessary to further improve the accuracy of digital filter design. The focus of future research might be on the rationality of the parameter settings of the artificial fish swarm algorithm.