Charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm
By using the combination method of Morlet wavelet neural network and improved bat algorithm in the harmonic detection of the charger, the problems of poor detection timeliness and low accuracy in the prior art are solved, and efficient and accurate harmonic detection effect is achieved.
Patent Information
- Application Number
- CN202411575613.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-11
AI Technical Summary
When detecting harmonics generated by the charger, the prior art has poor timeliness, low detection accuracy, and lacks unified standards for determining the hidden layer structure, which makes it difficult to take into account the stability and speed of the detection results.
The detection method based on Morlet wavelet neural network and improved bat algorithm is adopted. The number of hidden layer nodes of Morlet wavelet neural network is optimized through the improved bat algorithm, and the compact structure of wavelet transform and BP neural network is combined to improve the detection timeliness and accuracy.
More efficient and more accurate harmonic detection is achieved, avoiding the problem of poor certainty of hidden layer structures and improving the stability and speed of detection.
Smart Images

Figure CN119415938A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of optimized intelligent detection, and relates to an intelligent detection method for charger harmonics, and more specifically, to a charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm. Background Art
[0002] As a new energy product of the rapidly developing era, electric vehicles are gradually being widely valued by the society. The gradual completion of the electric vehicle ecosystem and the timely updating of related technologies have provided a good environment for the widespread use of electric vehicles, but at the same time, the impact of electric power quality problems on electric vehicle charging has also increased. The energy obtained by electric vehicles comes from the power grid, and the power in the power grid needs to be transferred to electric vehicles through a charger. The charger is a nonlinear power electronic device. When it is connected to the power grid, it will cause harmonic pollution and seriously affect the power quality of the power grid. The hazards of harmonics are as follows:
[0003] (1) Impact on the safety of power system operation. When excessive harmonics are generated in a charging station, they will propagate to the connected power grid and cause harmonic pollution, affecting the equipment of adjacent users and threatening electrical equipment with high requirements for power quality. In serious cases, it may lead to power safety accidents.
[0004] (2) Increase the loss of power grid operation. Larger harmonic pollution will increase the load of the power system and reduce the power factor. At the same time, it will cause the power equipment to be used inefficiently, resulting in energy waste.
[0005] (3) Affecting the service life of equipment. For example, for electric motors, harmonics will generate pulsating torque and increase the power consumption of the motor, thus shortening the service life of the motor.
[0006] (4) Reduce the accuracy of equipment measurement. At present, many power equipment used for measurement are designed based on ideal sine and cosine waveforms. Therefore, the appearance of harmonics will cause measurement deviations, and the accuracy of measurement will be affected.
[0007] The operation of chargers will affect the quality of power grid electricity and cause serious harmonic pollution to the grid. When collecting data on grid operation and centrally monitoring the quality of grid operation, it is necessary to accurately and efficiently detect and analyze the harmonics generated by the charger during the charging process, so as to provide support for the economical and efficient operation of the charger, suppress harmonics, and improve the quality of grid power supply.
[0008] There are currently many methods for detecting harmonics. The Fourier transform method is relatively easy to implement for detecting harmonics, but this method detects harmonics in the frequency domain and cannot obtain the mutation information of harmonic signals in the time domain, and has poor timeliness. The harmonic current detection method based on instantaneous reactive power theory has great limitations for harmonic detection of non-steady-state current. In recent years, the application of neural networks to harmonic detection has become more and more extensive. Neural networks applied to harmonic detection have the advantages of not relying on accurate mathematical models and having strong ability to handle nonlinear problems, but if the initial parameters are not properly selected, the training is prone to fall into local optimality. Wavelet transform can distinguish different frequencies in the signal, has good dynamic characteristics and variable focal length characteristics, and can better analyze in the time domain and frequency domain. However, due to the different characteristics of different wavelet basis functions, the decomposed harmonics are prone to leakage and other phenomena, resulting in large differences in detection results. Summary of the invention
[0009] The purpose of the present invention is to provide a charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm to solve the problems raised in the above background technology.
[0010] To achieve the above object, the present invention provides the following technical solution: a charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm, comprising:
[0011] Step 1: Set the parameters of the improved bat algorithm, including the number of individuals in the bat population, the maximum number of iterations, the initial loudness and frequency of pulse emission, the range of position vectors, the pulse enhancement coefficient, the loudness attenuation coefficient, and the frequency range;
[0012] Step 2: Using the training sample data, the optimal number of hidden layer nodes of the Morlet wavelet neural network is solved by the improved bat algorithm;
[0013] Step 3: Assign the optimal number of hidden layer nodes to the Morlet wavelet neural network, set the parameters of the Morlet wavelet neural network, including the learning rate, the number of sampling points, the sampling frequency, the network accuracy, the number of input layer nodes and the number of output layer nodes of the network, and use the training sample data to train the Morlet wavelet neural network;
[0014] Step 4: Use the trained Morlet wavelet neural network for harmonic detection.
[0015] Preferably, in step 1, n points {x1…x n}, {x1…x n} is regarded as the initial bat population, where x i=(xi1…xid), i∈[1,n], is a solution in the search space, and D is the dimension of the problem to be solved;
[0016] The bat population is initialized by random generation. At the same time, the position of the bats in the population is calculated by the fitness function, and the position x of the optimal bat individual is solved and recorded. best .
[0017] Preferably, the position x and velocity v of the individual bat at time t are updated by the following formulas (1), (2), and (3):
[0018] f i =f min +(f max -f min )β (1)
[0019]
[0020]
[0021] In the above formula, f i represents the frequency of the sound wave emitted by the i-th bat individual at time t, f max and f min They represent the maximum and minimum frequencies of the sound waves emitted by individual bats, respectively. β is a random number in the range [0, 1], uniformly distributed, and the bat individual with the best fitness is x. * To express;
[0022] The fitness value of the individual bat is determined by the objective function, and the optimal position of the current individual bat is recorded. At this time, a random number rand is generated and compared with the pulse frequency r of the bat at the current optimal position. If r is less than rand, it means that the bat is relatively far away from the target position, and the optimal solution individual bat position needs to be locally updated. The update formula (4) is as follows:
[0023] x new =x old +ε·A t (4)
[0024] Among them, ε is a random number, its range is [-1, 1], is the average loudness of all bats in the population in generation t;
[0025] When searching for a target, individual bats will emit pulses with a frequency R and loudness A. The pulse loudness A and pulse frequency R will change according to the positional relationship between the bat and the target during the process of searching for prey. They will be updated as the iteration progresses. When the distance between the bat and the prey gradually decreases, the loudness emitted by the bat will gradually decrease, and the pulse occurrence rate will increase. Therefore, when A = 0, it indicates that the individual bat has reached the target position. At this time, the pulse frequency R is also 0. The pulse loudness A and pulse frequency R can be expressed by the following formulas (5) and (6):
[0026]
[0027]
[0028] In the above formula, α and γ are both constants. When t→∞, for any 0<α<1, γ>0, there will be
[0029] Preferably, in the process of bat individual optimization in the basic bat algorithm, the coefficient of speed update of the bat individual in the basic algorithm is always kept at a constant value of 1, which reduces the diversity of its population. At the same time, the flexibility of the individual is restricted to a certain extent, which easily leads to the non-convergence phenomenon of the bat algorithm in the process of local optimization and global optimization. To address this problem, the focus distance is introduced, and the change rate of the focus distance is used to judge whether the bat individual in this search process should improve the local search ability or the global search ability. The formula is as follows:
[0030]
[0031]
[0032]
[0033]
[0034] In the above formula: n is the number of bat populations, D is the dimension of the bat population, x * is the optimal position currently searched by the bat population. The focus distance change rate h will affect the value of the inertia factor;
[0035] The formula for the inertia factor is as follows:
[0036]
[0037] In the above formula, z1=0.3, z2=0.2; λ is a random number uniformly distributed between [0,1];
[0038] It can be seen from formula (11) that when |h|>1, the ability of individual bats to search for global optimal solution is relatively poor. Therefore, it is necessary to increase the update step size and the inertia factor so that the bats can use a faster flight speed to search for the location of the global optimal solution. When |h|<0.05, it is necessary to reduce the inertia factor so that the flight speed of individual bats in searching for targets is slowed down to ensure that individual bats can be more accurate in local search for targets.
[0039] Preferably, in step 2, training sample data is used, and the mean square error between the measured value and the predicted value in the sample data is taken as the fitness value. The improved bat algorithm in step 1 is iteratively calculated, and the entire bat population after the optimization is completed is evaluated, and the global optimal position of the bat population, that is, the individual with the lowest fitness value, is taken as the optimal solution output; the optimal solution output by the improved bat algorithm is the optimal number of hidden layer nodes of the Morlet wavelet neural network.
[0040] Preferably, in step 3, a compact structure integrating wavelet transform and BP (Back Propagation) neural network is adopted, and the activation function of the hidden layer of the wavelet neural network is the wavelet basis function; the implementation process of the error propagation of the wavelet neural network can be expressed by equations (12) and (13):
[0041]
[0042]
[0043] In the above formula, w ij Represents the weight transmitted from the hidden layer to the output layer; r jk is the weight transmitted from the input layer to the hidden layer; the kth value of the input sample connected to the lth layer of neurons is represented by xkl; the output of the lth neural network for the i-th dimension is represented by y il Indicates; E is the square error between the network output and the expectation; ψ represents the wavelet activation function, and the scaling factor of the wavelet activation function is a j Indicates that the translation factor is b j ;u i is the threshold of the network, which determines the limit of the activation function; d il represents the output value of the ith neuron in the lth dimension; L, m, n, and N represent the number of samples, the number of network input layers, the number of network hidden layers, and the number of network output layers respectively;
[0044] In step 3: the Morlet function is used as the wavelet basis function of the wavelet transform, formula (19) is the function expression of the Morlet wavelet, and formula (20) is the Fourier transform of the Morlet function;
[0045]
[0046]
[0047] In the above formula, ω0 represents a dimensionless quantity, f represents frequency, t represents time, and ω=2πf.
[0048] Preferably, the optimal number of hidden layer nodes obtained in step 2 is assigned to the Morlet wavelet neural network, and other initial parameters of the Morlet wavelet neural network are set, including the learning rate, the number of sampling points, the sampling frequency, the network accuracy, the number of input layer nodes and the number of output layer nodes of the network, and the Morlet wavelet neural network is trained using the training sample data; the calculation steps of the wavelet neural network training are as follows:
[0049] S1: Random initialization of network connection weights and wavelet transform scaling and translation factor parameters;
[0050] S2: Input the training samples as input data to the input layer of the wavelet neural network, and use the results corresponding to the learning samples as the output layer data of the wavelet neural network;
[0051] S3: Perform forward operation, calculate the difference between the expected value and the output value of the wavelet neural network, compare the difference with the preset threshold, if the requirement is met or the maximum number of iterations is reached, the training is completed, and the network structure and parameters are output, otherwise it will enter the next step of calculation;
[0052] S4: Perform inverse operation. When the requirements of the previous step are not met, perform inverse operation on the calculated mean square error through gradient, and timely update the connection weights in the wavelet neural network and the scaling factor and translation factor of the wavelet transform to achieve the purpose of gradually approaching the expected value of the network output.
[0053] The present invention has at least the following beneficial effects:
[0054] 1. In the actual application of BP neural network in harmonic detection, there are problems such as the contradiction between stability and convergence speed, easy to fall into local optimality, and the determination of hidden layer structure is relatively blind, which seriously affects the speed, accuracy and stability of harmonic detection.
[0055] 2. The method of the present invention uses a wavelet neural network, which can better analyze dynamically changing signals in the time domain and frequency domain; the Morlet function is used as the activation function of the wavelet neural network, which ensures that the harmonic information is complete and undistorted during the wavelet transformation process;
[0056] 3. Using the improved bat algorithm, the introduction of the dynamic adaptive inertia factor based on the focus distance calculation can ensure that the bat population's ability to conduct local and global searches is balanced, effectively improving the bat population's ability to find the best solution for the number of nodes in the hidden layer of the wavelet neural network, so that the bat algorithm has higher convergence accuracy and faster convergence speed in optimizing the wavelet neural network, and has stable convergence. The simulation results show that the use of this method for harmonic detection has higher detection accuracy and faster speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 A flowchart of the method proposed for the present invention;
[0058] Figure 2 It is a structural diagram of the wavelet neural network of the present invention;
[0059] Figure 3 This is a schematic diagram of the error distribution between the original signal and the detection signal after the present invention uses the Morlet wavelet neural network for detection;
[0060] Figure 4 This is a schematic diagram of an iterative curve during harmonic detection after the present invention utilizes Morlet wavelet neural network detection;
[0061] Figure 5 It is a schematic diagram of the error distribution between the original signal of the detection result and the detection signal when the present invention uses the wavelet neural network optimized based on the basic bat algorithm to perform harmonic detection;
[0062] Figure 6 It is a schematic diagram of an iteration curve during harmonic detection when the present invention uses a wavelet neural network optimized based on a basic bat algorithm to perform harmonic detection;
[0063] Figure 7 The present invention adopts the improved bat algorithm to optimize the wavelet neural network for harmonic detection, and the error distribution diagram of the original signal and the detection signal of the detection result;
[0064] Figure 8 The present invention adopts the improved bat algorithm to optimize the wavelet neural network for harmonic detection, and is a schematic diagram of the iterative curve during harmonic detection. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] Example
[0067] Please refer to Figure 1-Figure 8 The method of the present invention is implemented using sample data of a three-phase uncontrolled rectifier charger widely used in the market, and is verified by MATLAB simulation.
[0068] Based on Morlet wavelet neural network algorithm, the performance of wavelet neural network is tested by fitting the simulation signal.
[0069] Set the learning rate to 0.00001, the number of sampling points to 1000, the sampling frequency to 1000, and the network accuracy to 0.65×10 -10 , the number of nodes in the input layer of the network is set to 12, and the number of nodes in the output layer is set to 1. When the bat algorithm is not used to optimize the network, the number of nodes and connection weights in the hidden layer of the network are obtained by random training.
[0070] After detection using Morlet wavelet neural network, the error distribution between the original signal and the detection signal is as follows: Figure 3 As shown in the figure, the iterative curve during harmonic detection is as follows Figure 4 As shown in the figure. The detection error range is between -0.2 and 0.2, and the Morlet wavelet converges after 7000 iterations. Compared with other detection methods used in the past, it achieves better detection accuracy and speed. However, it is found in the simulation implementation that when the same signal is detected multiple times, the detection results show great differences, and even non-convergence occurs.
[0071] Under the same parameter settings of the above wavelet neural network, the wavelet neural network optimized based on the basic bat algorithm is used for harmonic detection. The number of individuals in the bat population is set to 10, the maximum number of iterations is set to 20, and the initial loudness of the pulse emission is set to Sum frequency r i 0 The error distribution between the original signal and the detected signal is shown in the figure below: Figure 5 As shown in the figure, the iterative curve during harmonic detection is as follows Figure 6 As shown in the figure. The detection error of the wavelet neural network after the basic bat algorithm is optimized is between -0.05 and 0.03. When the number of iterations is close to 1700, the error tends to be stable. After optimization, the detection error is significantly reduced, the number of iterations is significantly reduced, and the detection accuracy and efficiency are improved. However, it is found that the phenomenon of non-convergence occasionally occurs in repeated simulation implementations.
[0072] Under the same parameter settings of the above wavelet neural network, the wavelet neural network optimized by the improved bat algorithm is used for harmonic detection. The initial parameter settings of the bat algorithm are the same as those of the basic bat algorithm. The error distribution of the original signal and the detection signal of the detection result is shown in Figure 7 As shown in the figure, the iterative curve during harmonic detection is as follows Figure 8 As shown in the figure. The detection error range of the wavelet neural network optimized by the improved bat algorithm is between -0.03 and 0.02, and it converges when the number of iterations is close to 1000, which further improves the detection accuracy and efficiency. The wavelet neural network optimized by the improved bat algorithm is repeatedly used to detect harmonics. The output of the network each time is close to the actual value to the greatest extent, which improves the defect of the wavelet neural network being sensitive to the number of nodes in the initial hidden layer and has stable convergence.
[0073] It includes wavelet neural network, one of which is a compact structure that integrates wavelet transform and BP (Back Propagation) neural network, the activation function of the hidden layer of the wavelet neural network is the wavelet basis function, and the Morlet function is used as the wavelet basis function of the wavelet transform, thereby improving the accuracy and speed of harmonic detection;
[0074] Secondly, on the basis of the traditional bat algorithm, the focusing distance and inertia weight are introduced to improve the stable convergence of the global optimization of the bat algorithm. The optimization result of the bat algorithm is used as the number of hidden layer nodes of the wavelet neural network, which solves the large difference in multiple detection results caused by the random setting of the number of hidden layer nodes when the wavelet neural network detects harmonics; the detection steps are as follows:
[0075] Step 1: Set the parameters of the improved bat algorithm, the main parameters include the number of individuals in the bat population, the maximum number of iterations, the initial loudness and frequency of pulse emission, the range of position vectors, pulse enhancement coefficient, loudness attenuation coefficient, and frequency range;
[0076] Step 2: Using the training sample data, the optimal number of hidden layer nodes of the Morlet wavelet neural network is solved by the improved bat algorithm;
[0077] Step 3: Assign the optimal number of hidden layer nodes to the Morlet wavelet neural network, set other parameters of the Morlet wavelet neural network, including learning rate, number of sampling points, sampling frequency, network accuracy, number of input layer nodes and number of output layer nodes of the network, and use training sample data to train the Morlet wavelet neural network;
[0078] Step 4: Use the trained Morlet wavelet neural network for harmonic detection.
[0079] The specific steps of step one are:
[0080] Step 1.1: Assume that n points {x1…x n}, {x1…x n} is regarded as the initial bat population, where x i =(xi1…xid), i∈[1,n], is a solution in the search space, and D is the dimension of the problem to be solved. The bat population is initialized by random generation. At the same time, the position of the bats in the population is calculated by the fitness function, and the position x of the optimal bat individual is solved and recorded. best .
[0081] The position x and velocity v of the individual bat at time t are updated by the following formulas (1), (2), and (3):
[0082] f i =f min +(f max -f min )β (1)
[0083]
[0084]
[0085] In the above formula, f i represents the frequency of the sound wave emitted by the i-th bat individual at time t, f max and f min Represent the maximum and minimum frequencies of the sound waves emitted by individual bats. β is a random number in the range [0, 1], uniformly distributed. In the current population, the bat individual with the best fitness is represented by x. * To express.
[0086] The fitness value of the individual bat is determined by the objective function, and the optimal position of the current individual bat is recorded. At this time, a random number rand is generated and compared with the pulse frequency r of the bat at the current optimal position. If r is less than rand, it means that the bat is relatively far from the target position, and the optimal solution individual bat position needs to be locally updated. The update formula (4) is as follows:
[0087] x new =x old +ε·A t (4)
[0088] Among them, ε is a random number, its range is [-1, 1], is the average loudness of all bats in the population in generation t.
[0089] When searching for a target, individual bats will emit pulses with a frequency R and loudness A. The pulse loudness A and pulse frequency R will change constantly according to the positional relationship between the bat and the target during the process of the bat's search for prey, and will self-update with the development of iterations. When the distance between the bat and the prey gradually decreases, the loudness of the bat's pulses will gradually decrease, and the pulse rate will increase. Therefore, when A = 0, it means that the individual bat has reached the target position, and the pulse frequency R is also 0. The pulse loudness A and pulse frequency R can be expressed by the following formulas (5) and (6):
[0090]
[0091] r i t+1 =r i 0 [1-exp(-γt)] (6)
[0092] In the above formula, α and γ are both constants. When t→∞, for any 0<α<1, γ>0, there will be r i t →r i 0
[0093] In a simple case, when setting the parameters A, r, α, and γ, α=γ=0.9 is used.
[0094] Step 1.2: It can be seen from formula (2) that in the process of individual bat optimization in the basic bat algorithm, the coefficient of speed update of individual bats in the basic algorithm is always kept at a constant value of 1, which reduces the diversity of its population. At the same time, the flexibility of individuals is restricted to a certain extent, which easily leads to the non-convergence phenomenon of the bat algorithm in the process of local optimization and global optimization. To address this problem, the focus distance is introduced, and the change rate of the focus distance is used to judge whether the individual bats in this search process should improve their local search ability or global search ability. The formula is as follows:
[0095]
[0096]
[0097]
[0098]
[0099] In the above formula: n is the number of bat populations, D is the dimension of the bat population, x * is the optimal position currently searched by the bat population. The focus distance change rate h will affect the value of the inertia factor.
[0100] The formula for the inertia factor is as follows:
[0101]
[0102] In the above formula, z1=0.3, z2=0.2; λ is a random number uniformly distributed between [0,1].
[0103] It can be seen from formula (11) that when |h|>1, the ability of individual bats to search for global optimal solution is relatively poor. Therefore, it is necessary to increase the update step size and the inertia factor so that the bats can use a faster flight speed to search for the location of the global optimal solution. When |h|<0.05, it is necessary to reduce the inertia factor so that the flight speed of individual bats in searching for targets is slowed down to ensure that individual bats can be more accurate in local search for targets.
[0104] The step 2 specifically includes: using training sample data, taking the mean square error between the measured value and the predicted value in the sample data as the fitness value, iteratively calculating the improved bat algorithm in step 1, evaluating the entire bat population after the optimization, and taking the global optimal position of the bat population, that is, the individual with the lowest fitness value, as the optimal solution output. The optimal solution output by the improved bat algorithm is the optimal number of hidden layer nodes of the Morlet wavelet neural network.
[0105] The step three specifically includes:
[0106] Step 3.1: A compact structure combining wavelet transform and BP (Back Propagation) neural network is adopted. The activation function of the hidden layer of the wavelet neural network is the wavelet basis function. The error propagation process of the wavelet neural network can be expressed by equations (12) and (13):
[0107]
[0108]
[0109] In the above formula, w ij Represents the weight transmitted from the hidden layer to the output layer; r jk is the weight transmitted from the input layer to the hidden layer; the kth value of the input sample connected to the lth layer of neurons is represented by xkl; the output of the lth neural network for the i-th dimension is represented by y il Indicates; E is the square error between the network output and the expectation; ψ represents the wavelet activation function, and the scaling factor of the wavelet activation function is a j Indicates that the translation factor is b j ;u i is the threshold of the network, which determines the limit of the activation function; d ilRepresents the output value of the ith neuron in the lth dimension. L, m, n, and N represent the number of samples, the number of network input layers, the number of network hidden layers, and the number of network output layers, respectively.
[0110] like:
[0111]
[0112] but:
[0113]
[0114] According to the gradient descent theory, the corresponding parameter adjustment process is as follows:
[0115]
[0116]
[0117]
[0118]
[0119] In the above formula, η represents the learning coefficient.
[0120] Step 3.2: Use the Morlet function as the wavelet basis function of wavelet transform. Equation (19) is the function expression of the Morlet wavelet, and Equation (20) is the Fourier transform of the Morlet function.
[0121]
[0122]
[0123] In the above formula, ω0 represents a dimensionless quantity, f represents frequency, t represents time, and ω=2πf.
[0124] Step 3.3: Assign the optimal number of hidden layer nodes obtained in step 2 to the Morlet wavelet neural network, set other initial parameters of the Morlet wavelet neural network including learning rate, number of sampling points, sampling frequency, network accuracy, number of input layer nodes and number of output layer nodes of the network, and use the training sample data to train the Morlet wavelet neural network; the calculation steps of wavelet neural network training are as follows:
[0125] (1) Random initialization of network connection weights and wavelet transform scaling and translation factor parameters.
[0126] (2) The training samples are input as input data to the input layer of the wavelet neural network, and the results corresponding to the learning samples are used as the output layer data of the wavelet neural network.
[0127] (3) Forward operation. The expected and output values of the wavelet neural network are calculated to obtain the difference, and the difference is compared with the preset threshold. If the requirement is met or the maximum number of iterations is reached, the training is completed and the network structure and parameters are output. Otherwise, the next step of calculation is entered.
[0128] (4) Inverse operation. When the requirements of the previous step are not met, the calculated mean square error is inversely operated through the gradient, and the connection weights in the wavelet neural network and the scaling factor and translation factor of the wavelet transform are updated in a timely manner to achieve the purpose of gradually approaching the expected value of the network output.
[0129] Morlet Wavelet Transform Neural Network
[0130] Neuron is the most basic component of neural network. Its characteristic is that it maps multiple different inputs into a single output using activation function, which can realize nonlinear mapping from input to output. The mathematical relationship of neuron is shown in formula (21).
[0131]
[0132] In the above formula, x i represents the input of the artificial neuron, y j represents the output of the artificial neuron, ω ij represents the connection weight from neuron i to neuron j, b j is the threshold, and f(·) represents the activation function of this layer.
[0133] BP (Back Propagation) neural network is the most common one used to detect harmonics. When the neural network starts training, the signal first enters the input layer, then enters the hidden layer after being output from the input layer, and then enters the output layer after being calculated through the weight threshold and the hidden layer activation function, and then enters the output layer, and then is calculated by the output layer, and then the error between the output layer result and the target data is calculated. When the error is large and is not within the preset allowable range, it is necessary to propagate the error back through the hidden layer to the input layer, and use the corresponding algorithm to update the weights and thresholds of each layer in a timely manner. This process is repeated many times, and when the iteration reaches the set maximum number of iterations or meets the accuracy requirements, the nonlinear mapping model of input and output is constructed.
[0134] Although the BP neural network model has many advantages in the actual application of harmonic detection, there are still many problems that need to be paid attention to and solved, mainly:
[0135] (1) Stability and convergence speed are contradictory. Since gradient learning is used in the training process, a relatively small learning rate will make the learning process relatively stable, but a small learning rate will lead to a longer training time and a relatively slow convergence speed.
[0136] (2) There is a problem of being easily trapped in the local optimum. Since the BP neural network uses the gradient descent method for learning during the training process, if the initial parameters of the neural network are not selected properly, the result may fall into the local optimal solution.
[0137] (3) There is a lack of unified standards for determining the structure of the hidden layer. At present, the determination of the hidden layer structure of the neural network mainly relies on empirical formulas, lacking a unified theoretical standard. This leads to a great deal of blindness in the design of the neural network structure, and improper structure selection will seriously affect the detection results of the model.
[0138] The theory of wavelet transform was first proposed in 1974. It has been developed based on Fourier analysis and has gradually become a powerful mathematical tool. It has a wide range of applications in many fields such as image processing, signal analysis, fault diagnosis and quantum mechanics. Compared with the window that cannot be changed according to the frequency transformation in the Fourier transform process, the wavelet transform can better analyze the dynamically changing signals in the signal analysis process because of its scaling factor and translation factor, and can distinguish different frequencies in the signal. It has good dynamic characteristics and variable focal length characteristics, and can better analyze in the time domain and frequency domain.
[0139] The wavelet neural network used in this method refers to the activation function used in the BP neural network as the wavelet transform function. The wavelet transform and the BP neural network adopt a compact structure, and its structure is as follows: Figure 2 As shown, the error propagation of the wavelet neural network is as described in step 3.1.
[0140] The determination of wavelet basis function is a key factor affecting the detection ability of wavelet neural network, so it is necessary to determine whether the requirements are met based on the comparison of different wavelet basis functions. When using wavelet transform for detection, under the condition that other conditions remain unchanged, the use of different wavelet basis functions will make the results of wavelet transform have greater differences. Therefore, it is necessary to determine the appropriate wavelet basis function according to the characteristics of the problem. Morlet wavelet is a single-frequency complex sine function, which shows good locality in both time domain and frequency domain, and because the high precision of phase information accounts for an important component in harmonic detection, the symmetry of the function must be considered when selecting the wavelet basis function. Only by ensuring symmetry can the information be guaranteed to be complete and undistorted during the wavelet transform process. The innovation of the present invention also lies in that the Morlet function is used as the activation function of the wavelet neural network, and the effectiveness of the innovative method has been proved from theoretical analysis and experimental results. The function expression of Morlet wavelet is described in step 3.2.
[0141] Improved bat algorithm
[0142] The selection of the number of hidden layer nodes of the wavelet neural network can affect the quality of its detection performance, so it is very important to determine the optimal number of hidden layer nodes. As an excellent intelligent optimization algorithm, the bat algorithm can be used as a solution to optimize the number of hidden layer nodes of the wavelet neural network. In nature, bats use echolocation to find prey. When the bat is far away from the prey, the pulse intensity emitted by the bat is large and the pulse frequency is low. As the distance to the prey gets closer, the pulse intensity of the bat decreases and the pulse frequency increases. This process is similar to the problem of finding the optimal solution of the objective function in the feasible domain. In 2010, Yang Xinshe's team was inspired by this process, conducted in-depth research and proposed an intelligent optimization algorithm called the bat algorithm. When using the bat algorithm to solve the optimal problem, it is necessary to first convert the problem space to be solved into the algorithm space through appropriate mapping; secondly, in the algorithm space, initialize the relevant parameters; then use the search strategy to search for feasible solutions in the algorithm space and form a solution to be selected; then use specific rules as screening conditions, update the individual states in the population, and gradually iterate until the conditions are met and stop; finally, transform the algorithm space back into the problem space to output the optimal solution. The innovation of the present invention also lies in using the improved bat algorithm to obtain the optimal solution for the number of nodes in the hidden layer of the wavelet neural network.
[0143] The traditional basic bat algorithm is as described in step 1.1. In the basic bat algorithm, the position and speed of the bat are updated according to the parent generation as the reference standard. The moving step size of each individual bat in the basic bat algorithm is fixed, which will result in a single speed update for the individual bat. The selection of step size is particularly important for the optimization performance of the bat algorithm. When a smaller update step size is selected, it is easy to fall into the local optimal solution due to the slow change; on the contrary, if the selected update step size is too large, it is easy for the individual bat to fly away from the optimal solution, causing oscillation and other problems. Therefore, in order to facilitate the convergence and local search of the algorithm, a relatively small inertia factor needs to be selected; and when the algorithm needs to search globally and jump out of the local minimum, a relatively large inertia factor needs to be selected; this makes the inertia weight change according to different situations during the population search process to avoid falling into the local optimum and generating oscillation and other problems.
[0144] The method of the present invention improves this problem of the basic bat algorithm by introducing a focusing distance, judging whether the individual bats in the current search process should improve their local search ability or their global search ability by the rate of change of the focusing distance, and calculating the inertia factor of the speed update by the focusing distance. Increasing the inertia factor allows bats to use a faster flying speed to search for the location of the global optimal solution; reducing the inertia factor slows down the flight speed of individual bats in searching for targets, to ensure that individual bats can be more accurate when searching for targets locally. The introduction of a dynamic adaptive inertia factor based on focusing distance calculation can ensure that the local and global search capabilities of the bat population are balanced, effectively improving the optimization capability and stability of the bat population. This improvement to the basic bat algorithm is described in step 1.2.
[0145] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0146] While the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that many changes, modifications, substitutions and variations can be made to the embodiments without departing from the principles and spirit of the invention.
Claims
1. A charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm, characterized in that: include; Step 1: Set the parameters of the improved bat algorithm, including the number of individuals in the bat population, the maximum number of iterations, the initial loudness and frequency of pulse emission, the range of position vectors, the pulse enhancement coefficient, the loudness attenuation coefficient, and the frequency range; Step 2: Using the training sample data, the optimal number of hidden layer nodes of the Morlet wavelet neural network is solved by the improved bat algorithm; Step 3: Assign the optimal number of hidden layer nodes to the Morlet wavelet neural network, set the parameters of the Morlet wavelet neural network, including the learning rate, the number of sampling points, the sampling frequency, the network accuracy, the number of input layer nodes and the number of output layer nodes of the network, and use the training sample data to train the Morlet wavelet neural network; Step 4: Use the trained Morlet wavelet neural network for harmonic detection.
2. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 1 is characterized in that: In step 1, n points {x1…x n }, {x1…x n } is regarded as the initial bat population, where x i =(x i1 …x id ), i∈[1,n], is a solution in the search space, and D is the dimension of the problem to be solved; The bat population is initialized by random generation. At the same time, the position of the bats in the population is calculated by the fitness function, and the position x of the optimal bat individual is solved and recorded. best .
3. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 2 is characterized in that: The position x and velocity v of the individual bat at time t are updated by the following formulas (1), (2), and (3): f i =f min +(f max -f min )β (1) In the above formula, f i represents the frequency of the sound wave emitted by the i-th bat individual at time t, f max and f min They represent the maximum and minimum frequencies of the sound waves emitted by individual bats, respectively. β is a random number in the range [0, 1], uniformly distributed, and the bat individual with the best fitness is x. * To express; The fitness value of the individual bat is determined by the objective function, and the optimal position of the current individual bat is recorded. At this time, a random number rand is generated and compared with the pulse frequency r of the bat at the current optimal position. If r is less than rand, it means that the bat is relatively far away from the target position, and the optimal solution individual bat position needs to be locally updated. The update formula (4) is as follows: x new =x old +e·A t (4) Among them, ε is a random number, its range is [-1, 1], is the average loudness of all bats in the population in generation t; When searching for a target, individual bats will emit pulses with a frequency R and loudness A. The pulse loudness A and pulse frequency R will change according to the positional relationship between the bat and the target during the process of searching for prey. They will be updated as the iteration progresses. When the distance between the bat and the prey gradually decreases, the loudness emitted by the bat will gradually decrease, and the pulse occurrence rate will increase. Therefore, when A = 0, it indicates that the individual bat has reached the target position. At this time, the pulse frequency R is also 0. The pulse loudness A and pulse frequency R can be expressed by the following formulas (5) and (6): r i t+1 =r i 0 [1-exp(-γt)] (6) In the above formula, α and γ are both constants. When t→∞, for any 0<α<1, γ>0, there will be r i t →r i 0 .
4. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 3 is characterized in that: In the process of bat individual optimization in the basic bat algorithm, the speed update coefficient of the bat individual in the basic algorithm is always kept at a constant value of 1, which reduces the diversity of its population. At the same time, the flexibility of the individual is restricted to a certain extent, which easily leads to the non-convergence phenomenon of the bat algorithm in the process of local optimization and global optimization. To solve this problem, the focus distance is introduced. The change rate of the focus distance is used to judge whether the bat individual in this search process should improve the local search ability or the global search ability. The formula is as follows: In the above formula: n is the number of bat populations, D is the dimension of the bat population, x * is the optimal position currently searched by the bat population. The focus distance change rate h will affect the value of the inertia factor; The formula for the inertia factor is as follows: In the above formula, z1=0.3, z2=0.2; λ is a random number uniformly distributed between [0,1]; It can be seen from formula (11) that when |h|>1, the ability of individual bats to search for global optimal solution is relatively poor. Therefore, it is necessary to increase the update step size and the inertia factor so that the bats can use a faster flight speed to search for the location of the global optimal solution. When |h|<0.05, it is necessary to reduce the inertia factor so that the flight speed of individual bats in searching for targets is slowed down to ensure that individual bats can be more accurate in local search for targets.
5. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 1 is characterized in that: In step 2, the training sample data is used, and the mean square error between the measured value and the predicted value in the sample data is taken as the fitness value. The improved bat algorithm in step 1 is iteratively calculated, and the entire bat population after the optimization is completed is evaluated. The global optimal position of the bat population, that is, the individual with the lowest fitness value, is taken as the optimal solution output; the optimal solution output by the improved bat algorithm is the optimal number of hidden layer nodes of the Morlet wavelet neural network.
6. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 1 is characterized in that: In step 3, a compact structure combining wavelet transform and BP (Back Propagation) neural network is adopted, and the activation function of the hidden layer of the wavelet neural network is the wavelet basis function; the implementation process of the error propagation of the wavelet neural network can be expressed by equations (12) and (13): In the above formula, w ij Represents the weight transmitted from the hidden layer to the output layer; r jk is the weight transmitted from the input layer to the hidden layer; the kth value of the input sample connected to the lth layer of neurons is represented by x kl Indicates; the output of the lth neural network for the i-th dimension is y il Indicates; E is the square error between the network output and the expectation; ψ represents the wavelet activation function, and the scaling factor of the wavelet activation function is a j Indicates that the translation factor is b j ;u i is the threshold of the network, which determines the limit of the activation function; d il Represents the output value of the i-th neuron in the l-th dimension; L, m, n, and N represent the number of samples, the number of network input layers, the number of network hidden layers, and the number of network output layers respectively; In step 3: the Morlet function is used as the wavelet basis function of the wavelet transform, formula (19) is the function expression of the Morlet wavelet, and formula (20) is the Fourier transform of the Morlet function; In the above formula, ω0 represents a dimensionless quantity, f represents frequency, t represents time, and ω=2πf.
7. The charger harmonic detection method based on Morlet wavelet neural network and improved bat algorithm according to claim 6 is characterized by: Assign the optimal number of hidden layer nodes obtained in step 2 to the Morlet wavelet neural network, set other initial parameters of the Morlet wavelet neural network including learning rate, number of sampling points, sampling frequency, network accuracy, number of input layer nodes and number of output layer nodes of the network, and use the training sample data to train the Morlet wavelet neural network; the calculation steps of wavelet neural network training are as follows: S1: Random initialization of network connection weights and wavelet transform scaling and translation factor parameters; S2: Input the training samples as input data to the input layer of the wavelet neural network, and use the results corresponding to the learning samples as the output layer data of the wavelet neural network; S3: Perform forward operation, calculate the difference between the expected value and the output value of the wavelet neural network, compare the difference with the preset threshold, if the requirement is met or the maximum number of iterations is reached, the training is completed, and the network structure and parameters are output, otherwise it will enter the next step of calculation; S4: Perform inverse operation. When the requirements of the previous step are not met, perform inverse operation on the calculated mean square error through gradient, and timely update the connection weights in the wavelet neural network and the scaling factor and translation factor of the wavelet transform to achieve the purpose of gradually approaching the expected value of the network output.