Method for estimating SOC (State of Charge) of battery by optimizing spiking neural network
By introducing Tent chaotic sequence and reverse learning strategy, the sparrow search algorithm is optimized, combined with atomic repulsion and binding force, the parameters of the pulse neural network are dynamically adjusted, and the problems of low training efficiency and limited generalization ability of the pulse neural network in battery SOC estimation are solved, and more accurate battery SOC estimation and stronger generalization ability are achieved.
Patent Information
- Application Number
- CN202510618096.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-08-01
AI Technical Summary
The existing pulsed neural networks have low training efficiency, limited generalization capabilities and difficult parameter tuning in battery SOC estimation, and the sparrow search algorithm is prone to fall into local optimization in high-dimensional parameter space, which limits its deployment in embedded systems.
By introducing Tent chaotic sequences and reverse learning strategies, the initial position and velocity of sparrow individuals are generated, combined with the concepts of atomic repulsion and binding force, the sparrow search algorithm is optimized, the number and parameters of hidden layer neurons of the pulsed neural network are dynamically adjusted, and the ADJ strategy is used to optimize the pulsed neural network.
The global search capability of the Sparrow Search algorithm is enhanced, local optimal trapping is avoided, the algorithm's adaptability and search efficiency in different battery states is improved, more accurate battery SOC estimation is achieved, overfitting is avoided, and the generalization ability of the neural network is improved.
Smart Images

Figure CN120405442A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electric vehicle battery management, and specifically relates to a method for estimating the State of Charge (SOC) of a battery by using a spiking neural network optimized based on an improved sparrow search algorithm. Background Art
[0002] With the development of new energy technologies, batteries, as the main energy storage devices, have been widely used in fields such as electric vehicles, portable electronic devices, and renewable energy systems. Accurately estimating the SOC of a battery is crucial for ensuring the performance and lifespan of the system.
[0003] Although the application of spiking neural networks (SNNs) in SOC estimation has biologically inspired non-linear dynamic characteristics, problems such as low training efficiency, limited generalization ability, and difficulties in parameter tuning have restricted their application in actual industrial scenarios. As an emerging meta-heuristic algorithm, the sparrow search algorithm (SSA) shows potential in optimizing the parameters of SNNs. However, it is prone to falling into local optima in high-dimensional parameter spaces and consumes a large amount of computing resources, which limits its deployment in embedded systems. Summary of the Invention
[0004] Aiming at the deficiencies in the prior art, the present invention provides a method for optimizing the estimation of battery SOC by using a spiking neural network.
[0005] The present invention achieves the above technical objectives through the following technical means.
[0006] A method for optimizing the estimation of battery SOC by using a spiking neural network, comprising: obtaining the true value SOC(t) of the SOC of a power battery and external characteristic data through the ampere-hour integration method; constructing a spiking neural network structure based on the LIF model; introducing the concepts of atomic repulsive force and binding force and improving the sparrow search algorithm by Cauchy mutation; establishing an ADJ strategy based on the improved sparrow search algorithm to optimize the spiking neural network; importing the measured external characteristic data of the power battery into the optimized spiking neural network, and obtaining the finally predicted SOC through non-linear mapping. real (t) and external characteristic data; constructing a spiking neural network structure based on the LIF model; introducing the concepts of atomic repulsive force and binding force and improving the sparrow search algorithm by Cauchy mutation; establishing an ADJ strategy based on the improved sparrow search algorithm to optimize the spiking neural network; importing the measured external characteristic data of the power battery into the optimized spiking neural network, and obtaining the finally predicted SOC through non-linear mapping.
[0007] Further, the improved sparrow search algorithm is specifically as follows: First, introduce the Tent chaotic sequence and reverse learning strategy to generate the initial position and initial velocity of sparrow individuals; Second, encode the initial position of the sparrow into weights, thresholds, and time constants through real number encoding, thereby initializing the pulse neural network, and calculate the fitness based on the initialized pulse neural network; Then, introduce the concepts of atomic repulsive force and binding force to update the positions of the discoverers in the sparrow population, update the positions of the followers in the sparrow population through Cauchy mutation and the magnitude of the fitness, and update the positions of the vigilant in the sparrow population; Then, based on the updates of the positions of the discoverers, followers, and vigilant in the sparrow population, recalculate the fitness of sparrow individuals; Finally, if the iteration times of the sparrow search algorithm are less than the maximum iteration times N max , continue to update the positions of the sparrow population and calculate the fitness of sparrow individuals, otherwise, record the fitness of sparrow individuals in each iteration process, and compare to obtain the maximum fitness fitness * , and use the sparrow position at the maximum fitness fitness * as the optimal position.
[0008] Furthermore, the initial position X° and initial velocity V° of the sparrow individuals are:
[0009]
[0010] where X * , X # are the position matrices generated by the Tent chaotic sequence and reverse learning strategy, and V * , V # are the velocity matrices generated by the Tent chaotic sequence and reverse learning strategy.
[0011] Furthermore, the formula for the fitness fitness is:
[0012]
[0013] where n represents the number of samples of the true SOC value; y max is the maximum value of the true SOC value; y min is the minimum value of the true SOC value; is the predicted SOC value; y i is the true SOC value.
[0014] Furthermore, the specific process of updating the position of the discoverer is as follows:
[0015] (1) When R2≥ST, update the position of the discoverer sparrow according to the following formula:
[0016]
[0017] Among them, R2 is the warning value; ST is the safety threshold; represents the position of the i-th sparrow in the j-th dimension at time t+1; represents the position of the i-th sparrow at time t on the j-th dimension; Q is a standard normally distributed random number; L is a 1×d matrix, where d represents the number of parameters that need to be optimized for each sparrow in each iteration;
[0018] (2) When R2 <ST时,根据以下公式更新发现者麻雀的位置:
[0019]
[0020] in, is the speed of the i-th sparrow in the j-th dimension at time t+1; is the speed of the i-th sparrow in the j-th dimension at time t; rand is a random number between [0,1]; is the acceleration of the i-th sparrow in the j-th dimension at time t, and the sparrow's acceleration a i,j The calculation formula is:
[0021]
[0022] Among them, m i,j is the mass of the sparrow individual; G i,j represents the constraint force between the center of the population and the finder; ∑F represents the resultant force of the repulsive force on the finder from each individual sparrow; is a parameter for adjusting the atomic repulsion force, e is the base of the natural logarithm, α and n are constants related to the improved sparrow algorithm, r is the distance between the discoverer and other individuals; β and p are coefficient factors; T is the current number of iterations; is the population center position at time t.
[0023] Furthermore, the specific process of updating the follower position is:
[0024] First, update the position of the follower sparrow according to the following formula:
[0025]
[0026] in, represents the position of the i-th sparrow in the j-th dimension at time t+1; represents the position of the i-th sparrow at time t on the j-th dimension; L is a 1×d matrix; The best position for the current discoverer; is the global worst position obtained in the current iteration; Q *is a 1×d matrix; matrix A is a 1×D vector; i > N / 2 means that the fitness ranking of the current sparrow is in the second half of the population, N represents the total number of the sparrow population, d represents the number of parameters that each sparrow needs to optimize in each iteration; D represents the total dimension of the search space;
[0027] Secondly, after updating its position, when the i-th sparrow is in the worst position, according to the formula update its acceleration, where, represents the acceleration of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; represents the acceleration of the i-th sparrow at the t-th moment in the j-th dimension; is the learning factor; Cauchy(0,γ) is a random number generated from the Cauchy distribution, and γ is the scale parameter, is the fitness function value of the i-th sparrow at the t-th moment in the j-th dimension;
[0028] Then, after updating its acceleration, if the position of the sparrow exceeds the upper boundary u b,j or the lower boundary l b,j , reflect its position back into the search space: If the position x i,j > u b,j , then reflect its position to If x i,j < l b,j , then reflect its position to
[0029] Finally, after the position of the sparrow is updated again, according to the formula update the velocity of the sparrow again, where, represents the velocity of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; represents the velocity of the i-th sparrow at the t-th moment in the j-th dimension; ℃ is a reflection coefficient; ω is the angular frequency; φ is the phase shift.
[0030] Furthermore, the specific process of updating the position of the vigilant is as follows:
[0031] (1) When f i = f g , the position formula of the vigilant is:
[0032]
[0033] where, f i represents the fitness function value of the i-th sparrow, and f g represents the globally optimal fitness function value obtained in the current iteration; fw Denote the global worst fitness function value obtained in the current iteration; Denote the global worst position obtained in the current iteration; K is a random number between (-1, 1) used to represent the moving direction of the sparrow; ε is a very small constant to avoid the denominator being zero;
[0034] (2) When f i > f g At this time, change the position formula of the vigilant to:
[0035]
[0036] Among them, Denote the global best position obtained in the current iteration; use the parameter related to the iteration number iter as the degree-of-freedom parameter q of the t-distribution; the degree-of-freedom parameter Is a constant, and ρ is a control coefficient.
[0037] Furthermore, the specific process of optimizing the spiking neural network by the ADJ strategy is as follows:
[0038] Optimize with the upper limit of the number of neurons n in the hidden layer of the spiking neural network being 100. The number of neurons in the hidden layer starts from 1 and increases in steps of 3. When the number of neurons in the hidden layer is 1 and each time the step size is increased, run the improved sparrow search algorithm to obtain the maximum fitness fitness * Of the spiking neural network with the corresponding number of neurons in the hidden layer, and use the maximum fitness fitness * The corresponding optimal position of the sparrow is real-number encoded as the weight w, threshold θ, and time constant τ of the spiking neural network;
[0039] During the process of increasing the step size, compare the maximum fitness fitness * (n) of the spiking neural network with the number of neurons n with the maximum fitness fitness * (n + 3) of the spiking neural network with the number of neurons n + 3. If fitness * (n) < fitness * (n + 3), then continue to increase the step size; if fitness * (n) > fitness * (n + 3), then randomly subtract one hidden layer neuron based on the n + 3 hidden layer neurons, dynamically adjust the weight w, threshold θ, and time constant τ, and obtain the fitness fitness * (n + 2) of the spiking neural network with n + 2 hidden layer neurons after dynamic adjustment. Compare the obtained fitness * (n + 2) with fitness* (n) Compare, if fitness * (n)<fitness * (n+2), then continue to increase the step size based on the n+2 hidden layer neurons. If fitness * (n)>fitness * (n+2), then record fitness * (n), based on the n+2 hidden layer neurons, we continue to randomly subtract one hidden layer neuron, and dynamically adjust the weight w, threshold θ, and time constant τ again to obtain the fitness of the pulse neural network with n+1 hidden layer neurons after dynamic adjustment. * (n+1), and increase the step size based on the n+1 hidden layer neurons;
[0040] When the number of hidden layer neurons required to continue increasing the step size is greater than the upper limit of the number of neurons, the maximum fitness with the largest value at this time is recorded and the optimization is stopped; finally, the maximum fitness corresponding to the spiking neural network with different numbers of hidden layer neurons is compared to obtain: fitness * (M n ) is the largest, that is, M n is the optimal number of hidden layer neurons, fitness * (M n ) The corresponding weights, thresholds and time constants are the optimal parameters of the spiking neural network.
[0041] Furthermore, the formula for dynamically adjusting the weight w is:
[0042]
[0043] in, To dynamically adjust the weights from the input layer to the hidden layer; is the weight from the hidden layer to the output layer after dynamic adjustment; w1 is the weight from the input layer to the hidden layer before dynamic adjustment; w2 is the weight from the hidden layer to the output layer before dynamic adjustment; a and b are control coefficients; |w i | is the sum of the absolute values of the removed neuron weights; N m Represents the total number of neurons in the current hidden layer; ∑ k≠j |w k | represents the sum of the weights of the remaining neurons;
[0044] The formula for dynamically adjusting the threshold θ is:
[0045]
[0046] Among them, θ t+1is the threshold of the neuron at time t+1; θ t is the threshold of the neuron before dynamic adjustment; ε * is the decay factor; θ min represents the minimum value of the threshold; θ max represents the maximum value of the threshold; K represents the value of the i-th input pulse, ∑ i k i is the sum of the input pulses at the current time step; N0 is the normalization factor;
[0047] The formula for dynamically adjusting the time constant τ is:
[0048]
[0049] where, U mem represents the membrane potential, τ0 is the base time constant; o is the adjustment coefficient; is the absolute value of the rate of change of the membrane potential.
[0050] Furthermore, if the M n ∈(90, 100), the upper limit of the number of neurons is increased by 10, and the step size is continuously increased based on the ADJ strategy to compare the fitness, and the fitness with the largest current value, fitness * (d) the number of neurons d and related parameters;
[0051] Record the current fitness fitness * (d), the fitness fitness when the number of neurons is d+3 * (d+3) and related parameters, randomly subtract 1 to 2 neurons from the neural network with the number of neurons d and the number of neurons d+3 respectively, and adjust the weights w, thresholds θ, and time constant τ dynamically to obtain the fitness fitness * (d-2), fitness * (d-1), fitness * (d+1), fitness * (d+2), compare fitness * (d), fitness * (d+3), fitness * (d-2), fitness * (d-1), fitness * (d+1), fitness * (d+2), take the number of neurons when the fitness * value is the largest as the number of optimal hidden layer neurons, and record the related parameters.
[0052] The beneficial effects of the present invention are as follows:
[0053] (1) By introducing the Tent chaotic sequence and the reverse learning strategy, the global search ability and diversity of the sparrow search algorithm are enhanced, and the problems of population aggregation and falling into local optima are avoided.
[0054] (2) By improving the formula of the discoverer in the sparrow search algorithm, introducing the concepts of atoms and velocities, and the method of dynamically adjusting the time constant, weight, and threshold, the adaptability and search efficiency of the algorithm under different battery states are improved.
[0055] (3) By combining the improved sparrow search algorithm with the pulsed neural network, the optimized pulsed neural network can more accurately estimate the SOC of the power battery.
[0056] (4) By using the ADJ strategy to dynamically adjust the number of hidden layer neurons, the overfitting phenomenon is avoided, and the generalization ability of the neural network is improved. Description of the Drawings
[0057] Figure 1 It is a flowchart of the method for estimating the battery SOC by the optimized pulsed neural network of the present invention.
[0058] Figure 2 It is a schematic diagram of the pulsed neural network structure of the present invention.
[0059] Figure 3 It is a flowchart of the improved sparrow search algorithm of the present invention. Detailed Embodiments
[0060] The present invention will be further described below in conjunction with the drawings and specific embodiments, but the protection scope of the present invention is not limited thereto.
[0061] As Figure 1 shown, a method for optimizing a pulsed neural network to estimate the battery SOC is specifically implemented according to the following steps:
[0062] Step 1, data acquisition: Obtain the state of charge of the power battery, i.e., the true value SOC real (t) of the battery SOC and the external characteristic data. The external characteristic data includes voltage, current, and temperature, and the external characteristic data is normalized for the subsequent optimization process of the pulsed neural network.
[0063] Step 2, construct a pulsed neural network structure based on the Leaky Integrate-and-Fire (LIF) model (as Figure 2As shown, in the figure, X1, X2, and X3 represent the voltage, current, and temperature of the input layer respectively, H1…Hn represent the number of neurons in the hidden layer, and Y1 represents the battery SOC of the output layer).
[0064] The expression of the output layer of the spiking neural network is:
[0065] U[t] = βU[t - 1] + (1 - β)I in [t] - S out [t - 1]θ
[0066] Among them, U[t] is the membrane potential at the current time step; U[t - 1] is the membrane potential at the previous time step; β is the decay factor of the membrane potential, usually related to the time constant τ, β = e -Δt / τ ; I in [t] is the input current at the current time step, usually the product of the input signal X[t] and the weight W, that is, I in [t] = WX[t]; S out [t - 1] is the output pulse signal at the previous time step, expressed as 0 or 1; θ is the threshold of the membrane potential; the generation condition of the output pulse signal S out [t] is: When the membrane potential U[t] exceeds the threshold θ, the neuron fires a pulse and resets the membrane potential. By counting the sum of S out [t] within a certain time, the pulse frequency can be obtained. The time average of the membrane potential values of the output layer is taken to obtain a continuous value.
[0067] Step 3, improved sparrow search algorithm.
[0068] Step 3.1, when initializing the population of the algorithm, introduce the Tent chaotic sequence and the reverse learning strategy to generate the initial position and initial velocity of the sparrows, so that the sparrow individuals can jump out of the local optimum during the optimization process and continue to search, in order to enhance the performance of the algorithm. Merge the population generated by the Tent chaotic sequence and its reverse population into a new population with a total of 2N. For each sparrow individual, there corresponds a Tent chaotic sequence individual and its reverse individual. By calculating the geometric center of these two individuals, the initial position and initial velocity of the sparrow individual are obtained. All sparrow individuals form a new population with a total of N. The specific process is as follows:
[0069] First of all, the Tent mapping is the basis for generating the Tent chaotic sequence, which determines the generation rules and characteristics of the sequence. The expression of the Tent mapping is as follows:
[0070]
[0071] Among them, z i+1To represent the position of the (i + 1)-th individual (or called particle, solution vector, etc.); z i is the position of the i-th individual; NT is the number of particles in the chaotic sequence; rand(0, 1) is a random number between [0, 1].
[0072] Secondly, the initialization of the reverse population of the population is defined as The expression is:
[0073]
[0074] where represents the new position of the i-th individual after mutation operation; rand represents a random number in the interval [0, 1]; respectively represent two coefficients related to the i-th individual at time t; S i represents the position of the i-th individual in the current iteration.
[0075] The position of the sparrow population in the search space is represented by the matrix X, as follows:
[0076]
[0077] The velocity of the sparrow population in the search space is represented by the matrix V, and the generated velocity shall not exceed the maximum velocity, as follows:
[0078]
[0079] Then, the position matrices X * and X # are generated through the Tent chaotic sequence and the reverse learning strategy, and the velocity matrices V * and V # are generated. The population generated by the Tent chaotic sequence and its reverse population are combined into a new population with a total of 2N. Each sparrow individual corresponds to an individual of the Tent chaotic sequence and an individual generated in reverse. For each sparrow individual, it corresponds to an individual of the Tent chaotic sequence and its reverse individual. By calculating the geometric center of these two individuals, the initial position and the initial velocity of the sparrow individual are obtained. All sparrow individuals form a new population with a total of N.
[0080] Step 3.2, through real number coding, encode the initial position of the sparrow in Step 3.1 into weights, thresholds, and time constants, so as to initialize the spiking neural network. Select the normalized mean absolute error between the SOC prediction value output by the initialized spiking neural network and the true SOC value as the parameter of the fitness function. The formula for the fitness fitness is:
[0081]
[0082] Among them, n represents the number of samples of the true value of SOC; y max is the maximum value of the true value of SOC; y min is the minimum value of the true value of SOC; is the predicted value of SOC; y i is the true value of SOC. The best individual position and the worst individual position are determined according to the fitness. The greater the fitness, the better the individual position, and the smaller the fitness, the worse the individual position.
[0083] Step 3.3, Update of sparrow positions
[0084] (1) Update the positions of the discoverers. In SSA, the search range of the discoverers is fixed and the method is single. It relies too much on the update method of the sparrow positions in the previous generation and cannot dynamically balance the exploration and exploitation capabilities. In this embodiment, the concept of atoms is introduced, sparrows are compared to atoms, and by adding the repulsive force and binding force between sparrows, the randomness and multi-dimensionality of the discoverers' movement are increased.
[0085] (1.1) When R2≥ST, update the positions of the discoverer sparrows according to the following formula:
[0086]
[0087] Among them, R2 is the early warning value, and its value range is [0,1]; ST is the safety valve threshold, and its value range is [0.5,1.0]; represents the position of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; is the position of the i-th sparrow at the t-th moment in the j-th dimension; Q is a standard normal distribution random number; L is a 1×d matrix, and d represents the number of parameters that each sparrow needs to optimize in each iteration.
[0088] (1.2) When R2 < ST, the discoverers are affected by the repulsive force from other individuals, and the repulsive force of each sparrow on the discoverers is:
[0089]
[0090] Among them, F is the atomic repulsive force, is the parameter for adjusting the magnitude of the atomic repulsive force, e is the base of the natural logarithm, α and n are constants related to the improved sparrow algorithm, and r is the distance between the discoverer and other individuals. By adding the repulsive force between sparrows, the movement of sparrows becomes diverse.
[0091] In order to make the sparrow search algorithm more in line with biological behavior and balance global and local search, this embodiment further adds the binding force between the population position center and the discoverers.
[0092] Calculate the central position of the population through the centroid algorithm, that is, by setting a neighborhood range, find all other sparrows within this range, and finally determine the neighbors around each sparrow. Calculate the average position of all neighbors by adding the positions of all non-repeating neighbors and then dividing by the number of non-repeating neighbors, so as to obtain the central position of the population. Denote the central position of the population as x centre , the central position will generate a binding force pointing to the center of the population for the discoverer, and the binding force G i,j The magnitude is:
[0093]
[0094] where β and p are coefficient factors; T is the current iteration number; is the central position of the population at time t; is the position of the i-th sparrow at time t in the j-th dimension.
[0095] Combining the repulsive force and the binding force, obtain the acceleration a of the sparrow i,j :
[0096]
[0097] where m i,j is the mass of the sparrow individual, defined as a constant; G i,j represents the binding force between the center of the population position and the discoverer; ∑F represents the resultant force of the repulsive force acting on the discoverer from each sparrow individual. In each iteration process, update the velocity and position of sparrow i according to the obtained acceleration, and the update formula is:
[0098]
[0099] where, is the velocity of the i-th sparrow at time t + 1 in the j-th dimension; is the position of the i-th sparrow at time t + 1 in the j-th dimension; is the velocity of the i-th sparrow at time t in the j-th dimension; is the position of the i-th sparrow at time t in the j-th dimension; is the acceleration of the i-th sparrow at time t in the j-th dimension; rand is a random number between [0, 1].
[0100] (2) Update the position of the followers. Update the position of the follower sparrows according to the following formula:
[0101]
[0102] where, To represent the position of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; To represent the position of the i-th sparrow at the t-th moment in the j-th dimension; L is a 1×d matrix representing the position update mechanism of the discoverer; Is the best position of the current discoverer; Is the globally worst position obtained in the current iteration; Q * Is a 1×d matrix where all elements are 1; matrix A is a 1×D vector, and the vector elements are randomly selected as 1 or -1, and satisfy the condition A + = A T (AA T ) -1 ; d represents the number of parameters that each sparrow needs to optimize in each iteration; D represents the total dimension of the search space; i > N / 2 means that the fitness ranking of the current sparrow is in the second half of the population (i.e., the fitness is lower), and it needs to fly to other places to forage.
[0103] After updating its position, this embodiment proposes that when the sparrow is in the worst position, that is, the position with the lowest fitness, the acceleration of the sparrow is updated by Cauchy mutation and the magnitude of the fitness. Specifically: when the i-th sparrow is in the worst position, Among them, Represents the acceleration of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; Represents the acceleration of the i-th sparrow at the t-th moment in the j-th dimension; Is the learning factor, usually taking values in the range of (0, 1], used to control the size of the update step; Cauchy(0, γ) is a random number generated from the Cauchy distribution, and γ is the scale parameter, Is the fitness function value of the i-th sparrow at the t-th moment in the j-th dimension. Then, the velocity and position of the i-th sparrow are updated according to the obtained acceleration.
[0104] After the acceleration is updated, if the position of the sparrow exceeds the upper boundary u b,j Or the lower boundary l b,j , its position can be reflected back into the search space. Specifically: if the position x of the i-th sparrow in the j-th dimension i,j > u b,j , then its position is reflected to If x i,j < l b,j , then its position is reflected to When the position of the sparrow is updated again, the velocity of the sparrow is updated according to the formula again, where, Represents the velocity of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; Denote the velocity of the \(i\)-th sparrow at the \(t\)-th moment in the \(j\)-th dimension; \(℃\) is a reflection coefficient, usually taking values in the range \((0, 1]\), which is used to control the reflection intensity; \(\omega\) is the angular frequency, controlling the period of the sine function, and can be adjusted according to the scale and complexity of the problem; \(t\) is the current moment; \(\varphi\) is the phase shift, which is used to increase randomness and usually takes values in the range \([0, 2\pi)\).
[0105] (3) Update the position of the vigilant sparrow.
[0106] When \(f\) i \(= f\) g The position formula of the vigilant sparrow is:[[]]
[0107]
[0108] Among them, \(f\) i represents the fitness function value of the \(i\)-th sparrow, \(f\) g represents the globally best fitness function value obtained in the current iteration; \(f\) w represents the globally worst fitness function value obtained in the current iteration; represents the globally worst position obtained in the current iteration; \(K\) is a random number between \((-1, 1)\) used to represent the moving direction of the sparrow; \(\varepsilon\) is a very small constant to avoid the denominator being zero.
[0109] When \(f\) i \(> f\) g The position formula of the vigilant sparrow is changed to:[[]]
[0110]
[0111] Among them, \(f\) i represents the fitness function value of the \(i\)-th sparrow, \(f\) g represents the globally best fitness function value obtained in the current iteration; represents the globally best position obtained in the current iteration; The parameter related to the iteration number \(iter\) is used as the degree-of-freedom parameter \(q\) of the \(t\)-distribution; The degree-of-freedom parameter \(N\) max is the maximum number of iterations, is a constant, and \(\rho\) is a control coefficient to prevent the denominator from being zero.
[0112] Step 3.4, based on the update of the sparrow position in Step 3.3, recalculate the fitness of each sparrow individual.
[0113] Step 3.5, if the iteration number of the sparrow search algorithm is less than the maximum number of iterations \(N\) max , continue to execute Step 3.3 and Step 3.4; otherwise, record the fitness of each sparrow individual in each iteration process, and compare to obtain the maximum fitness \(fitness\) *, and use the sparrow position at the maximum fitness * as the optimal position.
[0114] Step 4: Establish the ADJ strategy (Add and Delete and Judgment) based on the improved sparrow search algorithm to optimize the spiking neural network, including determining the optimal number of neurons in the hidden layer of the spiking neural network, and obtaining the optimal weights, thresholds, and time constants of the hidden layer when the number of neurons in the hidden layer is optimal.
[0115] The specific process of optimizing the spiking neural network by the ADJ strategy is as follows: Optimize with the upper limit of the number of neurons n in the hidden layer of the spiking neural network being 100. The number of neurons in the hidden layer starts from 1 and increases in steps of 3. When the number of neurons in the hidden layer is 1 and each time the step size is increased, run the improved sparrow search algorithm to obtain the maximum fitness fitness * corresponding to the spiking neural network with the corresponding number of neurons in the hidden layer, and use the maximum fitness fitness * to encode the real number of the optimal sparrow position as the weights, thresholds, and time constants of the spiking neural network. During the process of increasing the step size, compare the maximum fitness fitness * (n) of the spiking neural network with n neurons in the hidden layer with the maximum fitness fitness * (n + 3) of the spiking neural network with n + 3 neurons in the hidden layer. If fitness * (n) < fitness * (n + 3), then continue to increase the step size; if fitness * (n) > fitness * (n + 3), then randomly subtract one neuron from the hidden layer based on n + 3 neurons in the hidden layer, dynamically adjust the weights w, thresholds θ, and time constants τ, and obtain the fitness fitness * (n + 2) corresponding to the spiking neural network with n + 2 neurons in the hidden layer after dynamic adjustment. Compare the obtained fitness * (n + 2) with fitness * (n). If fitness * (n) < fitness * (n + 2), then continue to increase the step size based on n + 2 neurons in the hidden layer. If fitness * (n) > fitness * (n + 2), then record fitness *(n), and randomly subtract one hidden layer neuron on the basis of n + 2 hidden layer neurons, and re-dynamically adjust the weight w, threshold θ, and time constant τ to obtain the fitness of the spiking neural network with n + 1 hidden layer neurons after dynamic adjustment * (n + 1), and increase the step size on the basis of n + 1 hidden layer neurons. When the number of hidden layer neurons required to continue increasing the step size is greater than the upper limit of the number of neurons, record the maximum fitness with the largest value at this time and stop the optimization. Finally, compare the maximum fitness corresponding to the spiking neural networks with different numbers of hidden layer neurons recorded to obtain: fitness * (M n ) has the largest value, that is, M n is the optimal number of hidden layer neurons, and fitness * (M n ) corresponds to the weights, thresholds, and time constants of the optimal parameters of the spiking neural network. In this way, the phenomenon of overfitting can be avoided, which helps to improve the generalization ability of the neural network.
[0116] In addition, (1) Dynamically adjust the weight w, threshold θ, and time constant τ. The specific content is as follows:
[0117] (1.1) Consider the weight w and the total number of current neurons N m , and dynamically adjust the size of the weight w. The dynamic scaling factor T is obtained through the following formula i :
[0118]
[0119] Among them, |w i | is the sum of the absolute values of the weights of the neurons to be removed; N m represents the total number of current hidden layer neurons; ∑ k≠j |w k | represents the sum of the weights of the remaining neurons, and a and b are control coefficients.
[0120] Separate the calculation of the weights from the input layer to the hidden layer and the weights from the hidden layer to the output layer. The dynamic scaling factors T1 and T2 of the weights from the input layer to the hidden layer and from the hidden layer to the output layer are obtained through the above method, and then the final weight value is obtained through the following formula:
[0121]
[0122] Among them, is the weight from the input layer to the hidden layer after dynamic adjustment; is the weight from the hidden layer to the output layer after dynamic adjustment; w1 is the weight from the input layer to the hidden layer before dynamic adjustment, that is, before randomly subtracting a neuron; w2 is the weight from the hidden layer to the output layer before dynamic adjustment, that is, before randomly subtracting a neuron.
[0123] (1.2) Utilize historical information and introduce an activation function to dynamically adjust the threshold θ. To make the dynamic adjustment of the threshold related to the previous threshold, a decay factor ε can be introduced * , similar to the decay of the membrane potential in the LIF model. The formula is as follows:
[0124]
[0125] where, θ t+1 is the threshold of the neuron after dynamic adjustment; θ t is the threshold of the neuron before dynamic adjustment; ε * is the decay factor, and its value range is between [0, 1]; a smaller ε * indicates that the threshold adapts to new inputs faster, while a larger ε * indicates that the threshold changes more smoothly; θ min represents the minimum value of the threshold, which is the lower limit of the threshold during the dynamic adjustment process; θ max represents the maximum value of the threshold, which is the upper limit of the threshold during the dynamic adjustment process; The Sigmoid function is suitable for scenarios that require smooth transitions. where K represents the value of the i-th input pulse; ∑ i k i is the sum of input pulses at the current time step; N0 is the normalization factor, which is used to control the input range of the activation function.
[0126] (1.3) This embodiment proposes to dynamically adjust the time constant based on the rate of change of the membrane potential, which can enhance the adaptability of the spiking neural network to input signals. The core idea of this method is to adjust the size of the time constant according to the change speed of the membrane potential, thereby optimizing the response characteristics of the neuron. The dynamic adjustment formula of the time constant τ is:
[0127]
[0128] where, U mem represents the membrane potential, τ0 is the base time constant, which represents the time constant when there is no input signal; o is the adjustment coefficient, which is used to control the dynamic adjustment amplitude of the time constant; is the absolute value of the rate of change of the membrane potential, which represents the change speed of the membrane potential per unit time.
[0129] Combined with the dynamically adjusted time constant, the update formula of the membrane potential is:
[0130]
[0131] Among them, U mem (t + Δt) is the membrane potential at the next time step; U mem (t) is the membrane potential at the current time step; Δt is the time step; R is the membrane resistance; I in (t) is the input current at the current time step; τ(U mem (t)) is the time constant dynamically adjusted according to the current membrane potential.
[0132] (2) To avoid the extreme value of the number of neurons from appearing near the upper limit number, this embodiment puts forward the idea: judge whether the optimal number M of neurons in the current hidden layer n appears at the end of the upper limit of the number of neurons. If M n ∈(90, 100), the upper limit is increased by 10. Continue to increase the step size and compare the fitness based on the ADJ strategy to obtain the fitness fitness * (d) of the number of neurons d and related parameters.
[0133] (3) To determine whether there are other extreme values near the point of the number of neurons d, this embodiment calculates the points near the d point. The specific steps are as follows: record the current fitness fitness * (d), the fitness fitness * (d + 3) when the number of neurons is d + 3, and related parameters. Randomly subtract 1 to 2 neurons from the neural networks with the number of neurons d and the number of neurons d + 3 respectively, and dynamically adjust the weight w, threshold θ, and time constant τ to obtain the fitness fitness * (d - 2), fitness * (d - 1), fitness * (d + 1), fitness * (d + 2). Compare fitness * (d), fitness * (d + 3), fitness * (d - 2), fitness * (d - 1), fitness * (d + 1), fitness * (d + 2). Take the number of neurons when fitness * is the largest as the optimal number of neurons in the hidden layer, and record the related parameters.
[0134] Step 5: First, import the measured data of the external characteristics of the power battery into the optimized pulsed neural network; secondly, take the average value of the membrane potential within a certain time window as the independent variable x, and fit the relationship between the independent variable and the true value of SOC through the following formula:
[0135] SOC real (t) = h·x 7 + g·x 6 + f·x 5 + a·x 4 + b·x 3 + c·x 2 + d·x + e
[0136] The above non - linear mapping formula is applicable to the case where the relationship between the output and SOC is relatively complex, and finally obtain the parameters a, b, c, d, e, f, g, h; finally, substitute the membrane potential value output by the pulsed neural network into the fitting formula to obtain the finally predicted SOC.
[0137] The described embodiments are the preferred embodiments of the present invention, but the present invention is not limited to the above embodiments. Without departing from the substantial content of the present invention, any obvious improvements, substitutions or modifications that those skilled in the art can make all belong to the protection scope of the present invention.
Claims
1. A method for optimizing the estimation of battery SOC by a spiking neural network, characterized in that: Obtain the true value SOC of the state of charge (SOC) of the power battery through the ampere-hour integration method real (t) and external characteristic data; construct a pulse neural network structure based on the LIF model; introduce the concepts of atomic repulsive force and binding force and the Cauchy mutation to improve the sparrow search algorithm; establish an ADJ strategy to optimize the pulse neural network based on the improved sparrow search algorithm Import the measured data of the external characteristics of the power battery into the optimized pulse neural network, and obtain the finally predicted SOC through non-linear mapping.
2. The method for estimating the SOC of a battery by using the optimized spiking neural network according to claim 1, wherein, The improved sparrow search algorithm is specifically as follows: First, introduce the Tent chaotic sequence and the reverse learning strategy to generate the initial position and initial velocity of the sparrow individuals; Second, encode the initial position of the sparrow into weights, thresholds, and time constants through real number encoding, so as to initialize the pulse neural network, and calculate the fitness based on the initialized pulse neural network; Then, introduce the concepts of atomic repulsive force and binding force to update the positions of the discoverers in the sparrow population, update the positions of the followers in the sparrow population through Cauchy mutation and the magnitude of the fitness, and update the positions of the vigilant in the sparrow population; Based on the update of the positions of the discoverers, followers, and vigilant in the sparrow population, recalculate the fitness of the sparrow individuals; Finally, if the iteration number of the sparrow search algorithm is less than the maximum iteration number N max , continue to update the sparrow population position and calculate the fitness of each sparrow individual. Otherwise, record the fitness of each sparrow individual during each iteration, and compare to obtain the maximum fitness fitness * , and use the sparrow position at the maximum fitness fitness * as the optimal position.
3. The method for estimating the battery SOC by using the optimized spiking neural network according to claim 2, wherein The initial position X° and initial velocity V° of the sparrow individuals are: Among them, X * , X # is the position matrix generated by the Tent chaotic sequence and the reverse learning strategy, and V * , V # is the velocity matrix generated by the Tent chaotic sequence and the reverse learning strategy.
4. The method for estimating the battery SOC by optimizing the spiking neural network according to claim 2, wherein The formula for the fitness is: where n represents the number of samples of the true value of SOC; y max is the maximum value of the true value of SOC; y min is the minimum value of the true value of SOC; is the predicted value of SOC; y i is the true value of SOC.
5. The method for estimating the SOC of a battery by using an optimized spiking neural network according to claim 2, wherein The specific process of updating the position of the discoverer is: (1) When R2≥ST, update the position of the discoverer sparrow according to the following formula: Among them, R2 is the warning value; ST is the safety valve value; represents the position of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; represents the position of the i-th sparrow at the t-th moment in the j-th dimension; Q is a random number of a standard normal distribution; L is a 1×d matrix, where d represents the number of parameters that each sparrow needs to optimize in each iteration; (2) When R2<ST, update the position of the discoverer sparrow according to the following formula: Among them, is the velocity of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; is the velocity of the i-th sparrow at the t-th moment in the j-th dimension; rand is a random number between [0, 1]; is the acceleration of the i-th sparrow at the t-th moment in the j-th dimension, and the acceleration a of the sparrow i,j The calculation formula is: Among them, m i,j is the mass of a sparrow individual; G i,j represents the binding force between the center of the population position and the discoverer; ∑F represents the resultant force of the repulsive force exerted on the discoverer by each sparrow individual; is a parameter for adjusting the magnitude of the atomic repulsive force, e is the base of the natural logarithm, α and n are constants related to the improved sparrow algorithm, r is the distance between the discoverer and other individuals; β and p are coefficient factors; T is the current iteration number; is the population center position at time t.
6. The method for estimating the SOC of a battery by using the optimized spiking neural network according to claim 2, wherein The specific process of updating the position of the follower is: First, update the position of the follower sparrow according to the following formula: Among them, represents the position of the $i$-th sparrow at the $(t + 1)$-th moment in the $j$-th dimension; represents the position of the $i$-th sparrow at the $t$-th moment in the $j$-th dimension; $L$ is a $1\times d$ matrix; is the best position of the current discoverer; is the globally worst position obtained in the current iteration; $Q$ * is a $1\times d$ matrix; matrix $A$ is a $1\times D$ vector; $i > N / 2$ indicates that the fitness ranking of the current sparrow is in the second half of the population, $N$ represents the total number of the sparrow population, $d$ represents the number of parameters to be optimized by each sparrow in each iteration; $D$ represents the total dimension of the search space; Secondly, after updating its position, when the i-th sparrow is in the worst position, update its acceleration according to the formula where, represents the acceleration of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; represents the acceleration of the i-th sparrow at the t-th moment in the j-th dimension; is the learning factor; Cauchy(0,γ) is a random number generated from the Cauchy distribution, and γ is the scale parameter, is the fitness function value of the i-th sparrow at the t-th moment in the j-th dimension; Then, after updating its acceleration, if the position of the sparrow exceeds the upper bound u b,j or the lower bound l b,j , reflect its position back into the search space: If the position x of the i-th sparrow in the j-th dimension i,j >u b,j , then reflect its position to If x i,j <l b,j , then reflect its position to Finally, after the position of the sparrow is updated again, according to the formula update the velocity of the sparrow again, where represents the velocity of the i-th sparrow at the (t + 1)-th moment in the j-th dimension; represents the velocity of the i-th sparrow at the t-th moment in the j-th dimension; ℃ is a reflection coefficient; ω is the angular frequency; ρ is the phase offset.
7. The method for estimating the battery SOC by optimizing the spiking neural network according to claim 2, wherein The specific process of updating the position of the vigilant is: (1) When f i = f g the position formula of the vigilant is: Among them, f i represents the fitness function value of the i-th sparrow, and f g represents the globally optimal fitness function value obtained in the current iteration; f w represents the globally worst fitness function value obtained in the current iteration; represents the position of the globally worst in the current iteration; K is a random number between (-1, 1) used to represent the direction of sparrow movement; ε is a very small constant to avoid division by zero; (2) When f i > f g , change the position formula of the vigilant to: Among them, represents the globally optimal position obtained in the current iteration; the parameter related to the iteration number iter is used as the degree-of-freedom parameter q of the t-distribution; the degree-of-freedom parameter is a constant, and ρ is the control coefficient.
8. The method for estimating the SOC of a battery by optimizing a spiking neural network according to claim 2, wherein, The specific process of optimizing the pulse neural network by the ADJ strategy is: Optimize with the upper limit of the number of neurons \(n\) in the hidden layer of the spiking neural network being 100. The number of neurons in the hidden layer starts from 1 and increases in steps of 3. When the number of neurons in the hidden layer is 1 and each time the step size is increased, run the improved sparrow search algorithm to obtain the maximum fitness \(fitness\) of the spiking neural network corresponding to the hidden layer with the corresponding number of neurons. * And take the maximum fitness \(fitness\) * The real number encoding of the optimal sparrow position corresponding to it is used as the weights \(w\), thresholds \(\theta\), and time constants \(\tau\) of the spiking neural network; During the process of increasing the step size, compare the maximum fitness * (n) of the spiking neural network with n neurons with the maximum fitness * (n + 3) of the spiking neural network with n + 3 neurons. If fitness * (n) < fitness * (n + 3), then continue to increase the step size; if fitness * (n) > fitness * (n + 3), then randomly subtract one hidden layer neuron based on n + 3 hidden layer neurons, dynamically adjust the weights w, thresholds θ, and time constants τ, and obtain the fitness * (n + 2) of the spiking neural network with n + 2 hidden layer neurons after dynamic adjustment. Compare the obtained fitness * (n + 2) with fitness * (n). If fitness * (n) < fitness * (n + 2), then continue to increase the step size based on n + 2 hidden layer neurons. If fitness * (n) > fitness * (n + 2), then record fitness * (n), randomly subtract one hidden layer neuron based on n + 2 hidden layer neurons again, dynamically adjust the weights w, thresholds θ, and time constants τ, and obtain the fitness * (n + 1) of the spiking neural network with n + 1 hidden layer neurons after dynamic adjustment, and increase the step size based on n + 1 hidden layer neurons; When the number of hidden layer neurons required to continue increasing the step size is greater than the upper limit of the number of neurons, record the maximum fitness with the largest value at this time and stop the optimization; finally, compare the maximum fitness corresponding to the pulse neural networks with different numbers of hidden layer neurons recorded to obtain: fitness * (M n ) has the largest value, that is, M n is the optimal number of hidden layer neurons, and fitness * (M n ) corresponds to the optimal parameters of the pulse neural network, namely the weights, thresholds, and time constants.
9. The method for estimating the battery SOC by optimizing the spiking neural network according to claim 8, wherein The formula for dynamically adjusting the weight w is: Among them, is the weight from the input layer to the hidden layer after dynamic adjustment; is the weight from the hidden layer to the output layer after dynamic adjustment; w1 is the weight from the input layer to the hidden layer before dynamic adjustment; w2 is the weight from the hidden layer to the output layer before dynamic adjustment; a and b are control coefficients; |w i | is the sum of the absolute values of the neuron weights to be removed; N m represents the total number of neurons in the current hidden layer; ∑ k≠j |w k | represents the sum of the weights of the remaining neurons; The formula for dynamically adjusting the threshold θ is: Among them, θ t+1 is the threshold of the neuron at time t + 1; θ t is the threshold of the neuron before dynamic adjustment; ε * is the decay factor; θ min represents the minimum value of the threshold; θ max represents the maximum value of the threshold; K represents the value of the i-th input pulse, and ∑ i k i is the sum of the input pulses at the current time step; N0 is the normalization factor; The formula for dynamically adjusting the time constant τ is: Among them, U mem represents the membrane potential, τ0 is the base time constant; o is the adjustment coefficient; is the absolute value of the membrane potential change rate.
10. The method for estimating the battery SOC by optimizing the spiking neural network according to claim 8, wherein, If the said M n ∈(90, 100), the upper limit of the number of neurons is increased by 10, and continue to increase the step size based on the ADJ strategy to compare fitness to obtain the fitness value with the largest current value, fitness * (d) the number of neurons d and related parameters; Record the current fitness again * (d), the fitness when the number of neurons is d + 3 * (d + 3) and related parameters. Randomly subtract 1 to 2 neurons from the neural networks with the number of neurons being d and d + 3 respectively, and adjust the weight w, threshold θ, and time constant τ dynamically to obtain the fitness * (d - 2), fitness * (d - 1), fitness * (d + 1), fitness * (d + 2), compare the fitness * (d), fitness * (d + 3), fitness * (d - 2), fitness * (d - 1), fitness * (d + 1), fitness * (d + 2), take the number of neurons when the fitness * has the maximum value as the number of optimal hidden layer neurons, and record the relevant parameters.