1. Introduction
As the growth in global novel energy vehicles accelerates, battery-related technologies have become a central area of research. The SOC is among the most crucial parameters for batteries [
1]. It expresses the remaining charge in a battery. Precise SOC estimation helps prevent overcharging and over-discharging, ensuring the healthy operation of batteries, which holds great importance [
2].
Numerous researchers have recently explored SOC estimation. The open-circuit voltage method calculates the battery’s SOC using its terminal voltage when in an open-circuit state [
3]. This method offers high estimation accuracy, but it necessitates that the battery remains idle for an extended period to attain voltage stability, posing significant challenges in practical application [
4]. To tackle this issue, some researchers have introduced the coulomb counting method [
5]. This approach estimates the battery’s SOC by integrating current and time, which is relatively straightforward to implement [
6]. However, as it may lead to error accumulation [
7], other studies have suggested the use of the Kalman filtering technique [
8]. The Kalman filtering method implementing the minimum mean squared error concept, the MSE between the estimated value and observed value is minimized to update system parameters [
9], achieving optimal battery SOC estimation [
10]. Prashant Shrivastava and colleagues proposed a dual forgetting factor-based adaptive extended Kalman filter for SOC estimation and developed a combined estimation approach for SOC and State of Energy (SOE) [
11]. Zhi Cheng He and others suggested a novel method for online SOC estimation that combines an adaptive extended Kalman filter with a parameter identification algorithm grounded in adaptive recursive least squares [
12]. Experiment results indicate that this method accurately estimates battery SOC and exhibits strong robustness [
13]. Dong-Ji Xuan and his team proposed an improved central difference transform Kalman filtering technique based on the square root second-order central difference transform. Experiments demonstrate that the algorithm converges rapidly and provides high estimation accuracy [
14]. In comparison to other methods, it is particularly suited for battery SOC estimation when significant current fluctuations are present, but its estimation accuracy heavily relies on the battery equivalent model.
In recent years, due to neural networks’ excellent adaptability to nonlinear systems, numerous researchers worldwide have investigated battery SOC estimation using neural networks. How et al. [
15] employed a deep neural network (DNN) for estimating SOC, demonstrating that increasing the number of hidden layers in the DNN can reduce the error rate. Mohammad et al. [
16] combined an autoencoder neural network with a Long Short-Term Memory (LSTM) neural network for high-precision battery SOC estimation. Yang et al. [
17] suggested an RNN with gated recurrent units for SOC estimation. Feng et al. [
18] designed a novel structure for a standard RNN to estimate battery SOC. 19. Hannan et al. [
19] utilized a deep fully convolutional network model for SOC estimation. Chen et al. [
20] proposed a method based on the autoregressive LSTM network and Moving Horizon Estimation. Jiao et al. [
21] examined a Gated Recurrent Unit RNN-based momentum gradient technique for estimating battery SOC. Ephrem et al. [
22] employed an RNN with LSTM for accurate SOC estimation in li-ion batteries. Bian et al. [
23] suggested a stacked bidirectional LSTM neural network for SOC estimation.
Moreover, as hyperparameters influence neural network estimation outcomes, several researchers have proposed combining optimization algorithms with neural networks to improve battery SOC estimation accuracy. Che et al. [
24] implemented a self-adaptive weight Particle Swarm Optimization (SWPSO) algorithm for training the Dynamic RNN (DRNN). The results show that the SWPSO algorithm enhances error convergence speed and avoids local optima. Ren et al. [
25] utilized a Particle Swarm Optimization-based LSTM neural network (PSO-LSTM) for SOC estimation.
Although many researchers have adopted neural networks or combined them with other methods for SOC estimation and effectively controlled errors, there are still some challenges in SOC estimation under specific conditions: On one hand, while the estimation errors in some of the studies can be lower than 5%, their research focuses on constant current discharge or periodic variable current discharge with mild variations. In such a discharge scenario, the samples and test data show good consistency, so it is of low difficulty to estimate the battery SOC, and the experiment results have higher estimation accuracy. However, in this study, intermittent constant current discharge is used, as shown in Figures, wherein dramatic fluctuations in current lead to increased estimation difficulties. On the other hand, few studies pay attention to the estimation of battery SOC at low battery SOC value. When the SOC value of the battery is low, the external characteristics of the battery, such as battery voltage characteristics and internal characteristics, are completely different from those seen when the SOC value of the battery is high, showing a sharp nonlinear change, which leads to the difficulty of estimation.
The limitations of the above-mentioned methods are mainly as follows. Firstly, almost all the methods do not involve SOC estimation when the SOC value is low. When the SOC value is low, the external characteristics of the battery, such as battery voltage characteristics and internal characteristics, are completely different from those seen under the condition of high SOC value, showing a sharp nonlinear change, which leads to increases in the difficulty of estimation. Secondly, manually adjusting and assigning network parameters will add more uncertainty factors, ultimately affecting the effectiveness of the model.
In order to solve the above problems, this paper proposes adding a self-attention mechanism and SMA optimization algorithm to a GRU neural network. Firstly, using RNN to process time series is an effective method for estimating battery SOC, and, compared with the traditional Back Propagation (BP) neural network method, the data input to the neural network are more abundant, which can improve the overall estimation ability. Secondly, a self-attention mechanism is added to the GRU neural network, which can make the GRU neural network notice the data that have a greater influence on the current SOC estimation value, thus improving the estimation accuracy; when the SOC value is low, the voltage drops sharply. At this time, the self-attention mechanism can give greater weight to the data that have a great influence on the current SOC estimation, to correct the SOC estimation. Finally, the Slime Mould Algorithm (SMA) is used to optimize the parameters of the GRU neural network to further improve the stability and estimation effect of the GRU neural network. Because the neural network fits the whole SOC curve, it will pay more attention to integrity by fitting the appropriate weights with data, but the SMA is used to find the optimal parameters, and the evaluation criterion is error. The smaller the neural network error, the higher the adaptability of the SMA and the better the parameters. Therefore, when the error estimation error increases when the SOC value is low, the adaptability of the SMA will become lower, so the SMA goes back to find more suitable parameters, thus further reducing the estimation error of the battery when the SOC value is low.
In this paper, the novel method is tested in two condition data sets, and, compared with the traditional BP neural network method, it is found that the novel method greatly reduces the SOC estimation error. Moreover, when the SOC value is low, the SOC estimation error of the traditional method increases obviously, but the SOC estimation error of the novel method decreases instead of increasing, and there is little difference with the overall error, which shows the advantages of the novel method.
The rest of this paper is as follows.
Section 2 describes the battery discharge data. In
Section 3, a GRU neural network battery SOC estimation model with a self-attention mechanism is proposed.
Section 4 presents the experiment analysis. In
Section 5, the method and experiment analysis of optimizing the neural network parameters using the SMA are put forward.
Section 6 summarizes this paper.
3. Network Structure
In order to solve the problem that the traditional Back Propagation (BP) method has low SOC estimation accuracy and the estimation error increases sharply when the SOC value is low, a recurrent neural network SOC estimation method with self-attention mechanism is proposed. As shown in
Figure 6, where C
t−1 is the weight shared from the previous time to the next time, h
t is the output of the current recurrent part, h
t* is the output of the current time recurrent neural network after attention correction, a
t is the feature weight calculated by the self-attention mechanism at the current time, and SOC
t is the estimated SOC value at the current time.
3.1. Serializing the Discharge Data
According to the input format of the recurrent neural network, the data are serialized, and each sample after processing contains both current and historical discharge data. As shown in
Figure 7, X
t = [U
t, I
t] is the discharge data at one moment. When the sequence length is set to n, the input samples are [X
t−n+1, X
t−n+2, …, X
t].
3.2. Using Recurrent Neural Network to Estimate Battery SOC
Recurrent neural networks are unique structures that retain previous information and utilize it for current output calculations. However, conventional RNNs often suffer from vanishing or exploding gradients. To address this issue, this study employs LSTM networks or their variant, GRU, both of which possess information filtering capabilities.
In contrast to conventional recurrent neural networks, the LSTM model incorporates a unique gating structure in each repeating module, as depicted in
Figure 8. The gate serves as an information filter, composed of a sigmoid layer and an element-by-element multiplication. The sigmoid layer produces values ranging from 0 to 1, indicating the amount allowed to pass through. A value of 0 signifies no passage, while 1 permits full passage. LSTM contains three gates as follows:
Forget gate: determines the extent of information retention at the current moment;
Input gate: regulates the amount of information preserved from the current input to the unit;
Output gate: affects the amount of information from the current time unit released externally.
The GRU is a modified version of the LSTM network. It combines the forget gate and input gate into a single update gate, thus simplifying the structure and speeding up the training compared to the LSTM network. The GRU neural network structure, depicted in
Figure 9, comprises only two gates: the update gate and the reset gate. The update gate controls how much information from the previous moment is carried into the current moment, while the reset gate determines the extent to which information from the prior moment is disregarded.
3.3. Adding Self-Attention Mechanism to Recurrent Neural Network
The input samples contain discharge data at multiple times, and each set of data has different effects on the neural network. The essence of the self-attention mechanism is to ensure the neural network can notice the data that have a great influence on the output results, so that it can learn more useful information. Since the neural network involves the transmission of many numbers, and the characteristics of the voltage and current in the discharge data are also composed of numbers, changing the weight of these features can make the neural network notice the features it needs to pay attention to.
A self-attention layer is added after the network layer of the recurrent neural network, and the output of the recurrent neural network contains the characteristics of each moment, which is used as the input of the self-attention layer. After axis inversion, a fully connected layer is added and the SoftMax activation function is used. Because the SoftMax function maps the outputs of multiple neurons into the (0, 1) interval, the weight of each moment can be calculated after several operations, and then the dimension can be restored after axis inversion. Finally, this set of weights is multiplied by the eigenvalues, and the original feature combination of the recurrent neural network becomes a weighted feature combination.
In the continuous cycle, the characteristics of each moment are behind the weight, and the weight of the moment that has a greater impact on the current result will be greater than that of other moments, so the neural network will pay more attention to these moments.
5. Adding Optimization Algorithm
The Slime Mould Algorithm (SMA) is an innovative heuristic algorithm that mirrors the foraging behavior and morphological transformations of slime mould. Introduced by Li Shimin et al. in 2020, it boasts several benefits such as straightforward principles, minimal adjustment parameters, robust optimization capabilities, and ease of implementation. Slime mould organisms primarily derive nutrition from external organic substances, with food concentration impacting the propagating wave created by the biological oscillator and the cytoplasmic flow rate. The SMA employs this foraging behavior for function optimization.
5.1. Algorithm Principle
This algorithm has three parts. During the first stage, known as the food approach phase, slime moulds move towards food based on airborne scents. Their approach behavior is represented by Formulas (2) and (3).
where X(t + 1) and X(t) represent the position of slime moulds in the t + 1 and t iterations, respectively, X
b(t) represents the position with the highest food concentration (optimal position) in the iteration t, and X
A(t) and X
B(t) represent two randomly selected slime moulds in the tth iteration; the range of vb is [−a,a], a = arctanh(1 − (t/T)), t is the current iteration number, and T is the maximum iteration number; the range decreases linearly from 1 to 0; r is a random number between 0 and 1; p = tanh(|S(i)
−DF|), where i = 1, 2, …, N, S(i) represents the fitness value of the ith slime mould, DF represents the optimal fitness value in all iterations, and N represents the population size of slime moulds; and W represents the weight of the slime moulds. As shown in Formulas (4)–(6).
The second stage is warp food. In this stage, individual positions are updated according to changes in the optimal position X
b and the fine-tuning of vb vc and W. The second stage involves food encircling, simulating the contraction pattern of slime mould veins. A higher food concentration results in stronger biological oscillator waves and faster cytoplasmic flows. The slime mould approach behavior update formula for this stage is shown in Formulas (7)–(9), where condition represents the individuals in the first half of the fitness list, bF and wF represent the best and worst fitness values in the current iteration, respectively, and ‘Sort Index’ represents the sorted fitness value sequence.
where rand and r represent the random values generated between 0 and 1, ub and lb represent the upper and lower bounds of the search space, respectively, and z represents the proportion of randomly distributed slime moulds.
The third stage is oscillation. In this stage, slime moulds use the propagating wave generated by the biological oscillator to modify the cytoplasmic flow speed. They simulate vein width changes through vb, vc, and W, allowing slime moulds to approach food more slowly when the food concentration is low and more quickly when high-quality food is found.
The algorithm flow chart is shown in
Figure 22; the specific steps are as follows:
Step 1: Set parameters, initialize the population, and calculate fitness;
Step 2: Calculate the weight W and parameter a;
Step 3: Generate a random number r and compare it with z. If r is smaller than z, update the position according to the Formula (7); otherwise update the parameter p, vb, vc; compare r with parameter p, if r is smaller than p, update the position according to the Formula (8), otherwise update the position according to the Formula (9);
Step 4: Recalculate the fitness and update the global optimal solution;
Step 5: Judge whether the termination condition is satisfied: if yes, output the global optimal solution; otherwise, repeat Steps 2 to 5.
5.2. Fusion of Algorithm and Neural Network
The SMA is integrated with the neural network, utilizing the neural network’s MSE as the fitness for the SMA. The optimized parameters comprise the number of GRU neurons (GRU-neurons), the count of fully connected layer neurons (fc-neurons), epochs, and batch size. The search range for these four parameters has upper limits of [150, 30, 32] and lower limits of [30, 5, 1]. We set the population number of the optimization algorithm to 15, the search dimension to 4, and the initial value of the position parameter z to 0.03.
As shown in
Figure 23, the SMA is used to optimize the network parameters as follows:
Parameter initialization. Set the position parameters, initialize the population, and randomly generate Myxomycetes × [GRU-neurons, Fc-neurons, Batch_size];
Calculate the fitness value of everything, and select the individual with the lowest fitness value as the current optimal solution. As shown in Formula (10), the fitness value of Myxomycetes is the mean squared error of the neural network.
- 3.
After updating the position of everything according to the flow of the SMA, the fitness value is recalculated and the optimal solution is updated;
- 4.
Judging the end condition. If satisfied, the algorithm ends and outputs the optimization result;
- 5.
Establishing and training the neural network with parameters optimized by SMA.
5.3. Experiment Analysis after Adding SMA
Figure 24 and
Figure 25 show the comparison between the estimated SOC value and the real SOC value after optimization of the SMA.
Table 8 shows the parameter optimization results.
Table 9 shows the numerical results. Under the DST condition, the optimal parameter group is [136, 28, 17]. The maximum error is reduced from 6.99% to 4.52% and the mean squared error is reduced from 0.62 to 0.38. Under the UDDS condition, the optimal parameter group is [130, 13, 10]. The maximum error is reduced from 3.30% to 2.78%, and the mean squared error is reduced from 0.47 to 0.22.
5.4. Experiment Analysis When the SOC Value Is Low after Adding SMA
Figure 26 and
Figure 27 show the comparison between the estimated SOC value and the real SOC value.
Table 10 shows the numerical results. Compared with the estimation error of SOC greater than 20%, the estimation error when the SOC value is low is also reduced.
Figure 28 and
Figure 29 show the comparison between the estimated SOC value and the real SOC value.
Table 11 shows the numerical results. Under the UDDS condition, the error is still further reduced after adding the optimization algorithm, and the performance of the original method under high and low SOC value conditions is not changed by adding the optimization algorithm. The improved method still has advantages in SOC estimation when the SOC value is low.
6. Conclusions
To enhance SOC estimation accuracy under complex conditions, particularly when the SOC value of the battery is low, this study introduces an SOC estimation approach that utilizes the slime mould algorithm for optimizing recurrent neural networks. This technique is evaluated under two discharge conditions, DST and UDDS, and is compared with the traditional BP neural network; three findings are summarized.
First, the main body of the novel method is the GRU neural network. When the features of the input data are few, it is very effective to increase the diversity of the input data by processing the time series with the recurrent neural network. Compared with the traditional BP network, the novel method greatly improves the accuracy of SOC estimation, and the error is limited to within 5%. Secondly, when dealing with discharge data with strong nonlinear characteristics, the self-attention mechanism can show obvious advantages. The addition of the self-attention mechanism effectively solves the problem that the SOC estimation error rises sharply due to the drastic change in discharge data when the battery SOC value is low. Thirdly, the SMA optimization algorithm can improve the overall SOC estimation ability without changing the network characteristics. The experiment results show that the novel proposed network has more advantages for SOC estimation when the battery SOC value is low before and after adding the optimization algorithm, and that the SMA optimizes the number of neurons and batch size of neural network, overcomes the randomness of manually determining parameters, and improves the prediction ability of neural network.
The experiment results show that, compared with the traditional BP neural network method, the battery SOC estimation method based on the slime mould algorithm and recursive neural network greatly reduces the error. The estimation error of the traditional BP neural network increases obviously when the battery SOC value is low, but the estimation error of the novel method decreases instead of increasing in this case, which is a major feature of the novel method.
The limitation of the novel method is that, on the one hand, the optimization algorithm is easy to fall into local optimum, and when the SMA initializes the population, the individuals are randomly distributed in the range, so the distribution is not uniform. The quality of the initial population is very important to the optimization algorithm, so the SMA may fall into a minimum point in the iteration and it is difficult to jump out. On the other hand, if the battery life is not considered, the capacity of the battery will decrease with frequent charging and discharging, which will affect the SOC estimation of the battery.
In future work, firstly, the initial population of the SMA will be improved by using the chaotic mapping method, and the individuals of Myxomycetes can be more evenly distributed in the search range by using the characteristics of uniform distribution of chaotic states, thus improving the convergence speed and optimization ability of the SMA. Secondly, the battery life factor in SOC estimation can be considered, and the phenomenon of battery life reduction by reducing battery capacity can be simulated.