Battery state-of-charge estimation method based on SSA optimization integrated deep learning
By adopting SSA-optimized CNN-LSTM network and model integration strategy in battery SOC estimation, the problem of insufficient SOC estimation accuracy in the prior art is solved, and higher estimation accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411903311.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-22
AI Technical Summary
The existing battery SOC estimation method has insufficient estimation accuracy or even failed under the influence of environmental changes, individual differences and battery aging, and the prediction effect of a single model in complex environments is not ideal.
The CNN-LSTM network based on SSA optimization is adopted to optimize the network hyperparameters through the sparrow search algorithm, and a model integration strategy based on Euclidean distance and cosine similarity is designed to improve the stability and migration of the model.
It significantly improves the accuracy and robustness of battery SOC estimation, and can provide more accurate prediction results in complex environments.
Smart Images

Figure CN119861288A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of battery state of charge estimation, and in particular to a battery state of charge estimation method based on SSA optimization integrated deep learning. Background Art
[0002] With the development of renewable energy and electric vehicles, batteries are increasingly used in modern science and technology. Among them, battery state estimation is an important part of achieving effective battery management. Accurate SOC estimation is a prerequisite for implementing battery management strategies such as charge and discharge control, balance management, and thermal management. It can not only improve the efficiency of battery use, but also extend the life of the battery and ensure its safety. Traditional SOC estimation methods mainly include open circuit voltage method, ampere-hour meter method, Kalman filter method, etc. Although these methods are effective in practical applications, they are often affected by factors such as environmental changes, individual differences, and battery aging, resulting in insufficient estimation accuracy or even failure.
[0003] In recent years, the rapid development of machine learning technology has provided new ideas for battery SOC estimation. Using data-driven methods, the dynamic characteristics of batteries can be learned from a large amount of historical data, thereby improving the accuracy of predictions. Among them, convolutional neural networks (CNNs) and long short-term memory networks (LSTMs) have been widely used in battery SOC estimation due to their powerful feature extraction and time series modeling capabilities. However, the limitations of a single model make its prediction effect unsatisfactory in complex environments. Summary of the invention
[0004] The purpose of the present invention is to provide a battery state of charge estimation method based on SSA optimization integrated deep learning, which can fully explore the advantages of each sub-model and significantly improve the accuracy and robustness of battery SOC estimation.
[0005] In order to achieve the above object, the technical solution adopted by the present invention is: a battery state of charge estimation method based on SSA optimization integrated deep learning, comprising the following steps: Step 1: Preprocess the battery data set; Step 2: Build a CNN-LSTM network, train the network model based on battery data, and use the sparrow search algorithm to optimize some hyperparameters of the network; Step 3: Establish the CNN-LSTM network model optimized by sparrow search in step 2 for feature extraction and time series prediction; Step 4: Train multiple models for data sets in different environments, and design a model integration strategy to increase the stability and transferability of the model. The model integration strategy calculates the weight of each sub-model based on the Euclidean distance and cosine similarity between the input data and the model training set.
[0006] Preferably, the preprocessing in step 1 includes normalizing the data and flattening it into 3 dimensions.
[0007] Preferably, step 2 includes sequentially performing random individual updates of individual positions, follower updates, alerter updates, and building a network evaluation model effect. If the model performs well, the model is saved and the process proceeds to step 3. If the model performance does not meet the requirements, step 2 is continued.
[0008] Preferably, the CNN layer of the CNN-LSTM network model in step 3 performs spatial feature extraction, and LSTM is used to learn the temporal information of the data; the network structure includes the following parts: Convolutional layer: extracts input features through convolution operations, optimizing the number of filters and step size; BN layer: used to speed up the training process and prevent gradient disappearance or gradient explosion; Pooling layer: The pooling operation is used to reduce the size of the feature map, retain the main features, and optimize the pooling window and step size; LSTM layer: used to process the characteristics of time series and capture the long-term and short-term dependencies in the sequence through the LSTM layer; Fully connected layer: maps features to the output space and generates the final prediction value.
[0009] Preferably, the CNN-LSTM network model in step 3 uses an Adam optimizer for network training, and sets training parameters including maximum training generations, learning rate, and regularization coefficient. After each training, the prediction result is obtained by denormalizing the network output to obtain the actual SOC value.
[0010] Preferably, in step 3, the fun function is used to pass the sparrow search optimization parameters to the CNN-LSTM network, and the predicted values of the training set and the test set are evaluated by the sum of the differences between the predicted values and the labels to evaluate the model effect.
[0011] Preferably, in step 3, the randran function is used to generate random numbers within the range of parameters to be optimized, thereby reducing the search cost and enabling the algorithm to optimize to suitable parameters more quickly.
[0012] Preferably, in step 3, the Range_revision function is used to check the returned parameters after each change of fitness to avoid the parameters not conforming to the settings of the neural network parameters.
[0013] Preferably, in step 4, the calc_reeor function is used to evaluate the model effect, and the mean absolute error, root mean square error, mean percentage error and determination coefficient of the prediction results of the training set and the test set are calculated to evaluate the effect of the optimized parameters on the data set; the Weight function is used to calculate how much weight should be assigned to each model.
[0014] Preferably, in step 4, after calculating the Euclidean distance and the cosine similarity, the total value of the two normalized separately is used as the main indicator for data weight allocation.
[0015] The beneficial effects of the present invention are:
[0016] This scheme optimizes the CNN-LSTM network through the SSA algorithm. With the help of the powerful optimization ability of the SSA algorithm, a more accurate model can be obtained; the integrated learning strategy designed based on Euclidean distance and cosine similarity can fully explore the advantages of each sub-model and significantly improve the accuracy and robustness of battery SOC estimation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is the flow chart of the SSA algorithm of the present invention.
[0019] Figure 2 This is a convolutional layer structure diagram of the present invention.
[0020] Figure 3 This is a CNN-LSTM network structure diagram of the present invention.
[0021] Figure 4 This is a structural diagram of the integrated deep learning algorithm based on SSA optimized CNN-LSTM of the present invention.
[0022] Figure 5 This is the test set regression diagram of the present invention.
[0023] Figure 6 This is a comparison chart of the prediction results of the test set.
[0024] Figure 7 is the error histogram of the test set. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0026] The present invention discloses a battery state of charge estimation method based on SSA optimization integrated deep learning. The embodiment includes the following steps: Step 1: Preprocess the battery data set; Step 2: Build a CNN-LSTM network, train the network model based on battery data, and use the sparrow search algorithm to optimize some hyperparameters of the network; Step 3: Establish the CNN-LSTM network model optimized by sparrow search in step 2 for feature extraction and time series prediction; Step 4: Train multiple models for data sets in different environments, and design a model integration strategy to increase the stability and transferability of the model. The model integration strategy calculates the weight of each sub-model based on the Euclidean distance and cosine similarity between the input data and the model training set.
[0027] Multiple different data sets are selected to increase the stability and transferability of the model. The preprocessing in step 1 includes normalizing the data and flattening it into 3 dimensions.
[0028] like Figure 1 As shown, step 2 includes sequentially performing individual random updates of individual positions, follower updates, alerter updates, and building a network evaluation model effect. If the model performs well, save the model and proceed to step 3. If the model performance does not meet the requirements, continue to execute step 2.
[0029] SSA Algorithm
[0030] (1) Explorer location update:
[0031] Among them, t is the current iteration number, M is the maximum number of iterations, represents the position of the i-th sparrow in the current iteration, α is a random number in the interval [0-1], R2 is the warning value, R2∈[0,1], ST is the safety value, ST∈[0.5,1], Q is a random number that obeys the normal distribution, L is a 1*d matrix, each element of the matrix is 1, if R2<ST, it means there are no predators around, and the explorer enters the wide search mode, if R2≥ST, it means that some sparrows in the population have discovered the predator and sounded the alarm, and all sparrows must fly to a safe place to find food.
[0032] (2) Follower location update:
[0033] when When , the sparrows with lower fitness did not get food, so they needed to get more food; woeseis the worst position globally. A represents a 1*d matrix whose elements are randomly assigned 1 or -1. + =A T (AA T ) -1 ,The other cases indicate that the sparrow randomly searches for a position near the current optimal position.
[0034] While the sparrows are foraging, some of them will be responsible for vigilance. When they find danger, they will take anti-predator actions: abandon the food and move to a new location. Sparrows at the periphery of the population are vulnerable to attacks by predators and need to constantly adjust their positions, while sparrows in the center of the population will approach their neighboring companions to reduce their danger zone. In each generation, S individuals are randomly selected from the population for warning, and their position update formula is shown as follows
[0035] When f i ≠f g When f , the sparrows are at the edge of the population and are vulnerable to foragers, and are now flying towards the optimal sparrows; when f i =f g When , the sparrow is in a dangerous position, far away from the worst sparrow position. Where β is the step size control parameter, which is a random number that obeys a normal distribution with a mean of 0 and a variance of 1. K is a random number with a value between [-1,1], indicating the direction in which the sparrow moves. f i is the current adaptation of the sparrow individual g 、f ω are the current global best and worst fitness values respectively, and ε is a very small constant to prevent the denominator from being 0.
[0036] The CNN layer of the CNN-LSTM network model in step 3 performs spatial feature extraction, and LSTM is used to learn the temporal information of the data. Figure 2 As shown, the network structure includes the following parts: Convolutional layer: extracts input features through convolution operations, optimizing the number of filters and step size; BN layer: used to speed up the training process and prevent gradient disappearance or gradient explosion; Pooling layer: The pooling operation is used to reduce the size of the feature map, retain the main features, and optimize the pooling window and step size; LSTM layer: used to process the characteristics of time series and capture the long-term and short-term dependencies in the sequence through the LSTM layer; Fully connected layer: maps features to the output space and generates the final prediction value.
[0037] like Figure 3As shown, the CNN-LSTM network model in step 3 uses the Adam optimizer for network training, and the training parameters are set including the maximum training generation, the learning rate, and the regularization coefficient. After each training, the prediction result is obtained by denormalizing the network output to obtain the actual SOC value.
[0038] like Figure 4 As shown, in step 4, after calculating the Euclidean distance and the cosine similarity, the total value of the two normalized separately is used as the main indicator for data weight allocation.
[0039] (1) Euclidean distance
[0040] Euclidean distance is suitable for measuring the absolute difference between two data points in value, especially when the data is continuous and has a certain scale. Euclidean distance can reflect the gap between these data in each dimension. Its advantages are: it provides a clear numerical distance and is easy to interpret. The disadvantage is: if the feature scales of different dimensions are different, the accuracy of Euclidean distance information will be affected. Therefore, it is usually necessary to standardize or normalize the data before calculation so that the scales of each dimension are consistent.
[0041] (2) Cosine similarity
[0042] Cosine similarity is applicable to high-dimensional sparse data, text data, etc., and focuses on measuring the directionality of data. In the context of three-dimensional data, cosine similarity can evaluate whether the distribution patterns of two sets of data in each dimension are similar, that is, whether their directions in three-dimensional space are similar. Its advantages are: it is not affected by the dimension or scale of the data, and can focus on the directionality and relative relationship of the data. The disadvantage is: it cannot consider the size of the specific value, and only focuses on the directionality.
[0043] In order to avoid data imbalance causing Euclidean distance or cosine similarity to account for too large a proportion, after calculating the Euclidean distance and cosine similarity, the total value of the two normalized and added is used as the main indicator for data weight allocation. After processing the data, use the exponential decrease y(t) = e -λt Generate weights. The final weights are
[0044] The main functions involved
[0045] (1) fun function:
[0046] The SSA optimized parameters are passed to the CNN-LSTM network, and the predicted values of the training set and the test set are evaluated by the sum of the differences between the predicted values and the labels to evaluate the model effect.
[0047] (2) Range_revision function:
[0048] After each fitness change, the returned parameters are checked to prevent the parameters from not meeting the neural network parameter settings. The specific content is: the parameters that the neural network requires to be integers are rounded off after each parameter change. If the parameter is less than the minimum predetermined range: If the parameter is greater than the maximum predetermined range: In this way, when the parameters exceed the expected range, the parameters can be returned to the range while retaining the approximate position of the parameters within the range, so as not to change the parameters drastically and affect the parameter optimization effect.
[0049] (3)calc_reeor function:
[0050] Evaluate the model effect and calculate the mean absolute error, root mean square error, average percentage error and determination coefficient of the prediction results of the training set and the test set to evaluate the effect of the optimized parameters on the data set.
[0051] (4)Weight function:
[0052] The weights that should be assigned to each sub-model are calculated using the exponential decay method. The weight of the closest model is increased, and the weight of the farther model is decreased.
[0053] Model training and testing results
[0054] Based on the Severson dataset, the SOC of the battery is estimated using the integrated deep learning algorithm based on SSA optimized CNN-LSTM designed by the present invention. The steps are as follows:
[0055] (1) Ten sets of data are stratified and sampled from a set of data. The first eight sets are used as training sets, and the adjacent data are used as test sets.
[0056] (2) The data is normalized and flattened into 3D data before being passed to the neural network.
[0057] (3) Initialize the algorithm, give the number of sparrows P = 20, the number of evolutions M = 10; set the optimization parameter threshold.
[0058] (4) Eight different models were obtained after eight cycles. The prediction errors of the training set and test set are shown in Tables 1 and 2, respectively. Table 1 Performance of each model on the training set MSE RMSE MAE R2 Model 1 0.0375 0.0480 0.0413 0.9846 Model 2 0.0297 0.0339 0.0353 0.9892 Model 3 0.0338 0.0513 0.0392 0.9822 Model 4 0.0474 0.0642 0.0576 0.9709 Model 5 0.0472 0.0600 0.0518 0.9749 Model 6 0.0337 0.0439 0.0372 0.9863 Model 7 0.0295 0.0401 0.0324 0.9887 Model Eight 0.0317 0.0425 0.0363 0.9873 Table 2 Performance of each model on the test set MSE RMSE MAE R2 Model 1 0.0526 0.0683 0.0678 0.9683 Model 2 0.1159 0.1620 0.1358 0.8230 Model 3 0.0550 0.0669 0.0580 0.9684 Model 4 0.0519 0.0701 0.0630 0.9658 Model 5 0.0506 0.0648 0.0603 0.9702 Model 6 0.0827 0.1131 0.0892 0.9100 Model 7 0.1367 0.1661 0.1628 0.8063 Model Eight 0.1244 0.1697 0.1346 0.7975
[0059] The test set uses the next set of data in the stratified sampling data. It can be seen that Model 2, Model 6, Model 7 and Model 8 perform poorly on the test set.
[0060] The test set regression graph during the training process and the comparison between the test set predicted value and the true value can be seen in Figure 5 and Figure 6 . Figure 7 It is an error histogram. Most of the data are near the 0 error point, so the error between the predicted value and the true value is small, and most of the data are on the left side of the 0 error point, so the predicted value is small.
[0061] The weight of the sub-model is obtained by the Weight function, and 1188 sets of data in the data set are predicted to obtain all the prediction error values. In order to evaluate the overall trend and distribution characteristics of these more than 1000 data, we extracted the following statistics, as shown in the table Table 3 Central tendency index MSE RMSE MAE R2 Maximum 0.1265 0.1727 0.1795 0.9877 Minimum 0.0345 0.0430 0.0371 0.7055 median 0.0464 0.0556 0.0554 0.9786 average value 0.0464 0.0565 0.0555 0.9770
[0062] The coefficient of determination R 2 The proportion of those less than 0.95 is 0.0254, that is, the coefficient of determination between the predicted value and the true value of the data set is concentrated between 0.9500 and 0.9877. It can be seen that even if a single model does not perform well on the test set, the prediction accuracy increases significantly after the model integration strategy is adopted.
[0063] It should be noted that the parts not described in detail in the above embodiments are all prior art.
[0064] The above description is only a preferred embodiment of the present invention and does not constitute any form of limitation to the present invention. Although the present invention has been disclosed as a preferred embodiment as above, it is not intended to limit the present invention. Any technician familiar with the profession can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention should be covered within the protection scope of the present invention.
Claims
1. A battery state of charge estimation method based on SSA optimization integrated deep learning, characterized in that: The following steps are involved: Step 1: Preprocess the battery data set; Step 2: Build a CNN-LSTM network, train the network model based on battery data, and use the sparrow search algorithm to optimize some hyperparameters of the network; Step 3: Establish the CNN-LSTM network model optimized by sparrow search in step 2 for feature extraction and time series prediction; Step 4: Train multiple models for data sets in different environments, and design a model integration strategy to increase the stability and transferability of the model. The model integration strategy calculates the weight of each sub-model based on the Euclidean distance and cosine similarity between the input data and the model training set.
2. The method for estimating the battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: The preprocessing in step 1 includes normalizing the data and flattening it into 3 dimensions.
3. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: The step 2 includes sequentially performing individual random updates of individual positions, follower updates, warning updates, and building a network evaluation model effect. If the model performs well, the model is saved and the step 3 is entered. If the model performance does not meet the requirements, the step 2 is continued.
4. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: The CNN layer of the CNN-LSTM network model in step 3 performs spatial feature extraction, and LSTM is used to learn the temporal information of the data; the network structure includes the following parts: Convolutional layer: extracts input features through convolution operations, optimizing the number of filters and step size; BN layer: used to speed up the training process and prevent gradient disappearance or gradient explosion; Pooling layer: The pooling operation is used to reduce the size of the feature map, retain the main features, and optimize the pooling window and step size; LSTM layer: used to process the characteristics of time series and capture the long-term and short-term dependencies in the sequence through the LSTM layer; Fully connected layer: maps features to the output space and generates the final prediction value.
5. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: The CNN-LSTM network model in step 3 uses the Adam optimizer for network training, and sets training parameters including the maximum training generation, learning rate, and regularization coefficient. After each training, the prediction result is obtained by denormalizing the network output to obtain the actual SOC value.
6. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: In step 3, the fun function is used to pass the sparrow search optimization parameters to the CNN-LSTM network, and the prediction values of the training set and the test set are evaluated by the sum of the differences between the prediction values and the labels to evaluate the model effect.
7. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: In step 3, the randran function is used to generate random numbers within the range of parameters to be optimized, which reduces the search cost and enables the algorithm to optimize to the appropriate parameters more quickly.
8. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: In step 3, the Range_revision function is used to check the returned parameters after each change of the fitness to avoid the parameters not meeting the setting of the neural network parameters.
9. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: In step 4, the calc_reeor function is used to evaluate the model effect, and the mean absolute error, root mean square error, average percentage error and determination coefficient of the prediction results of the training set and the test set are calculated to evaluate the effect of the optimized parameters on the data set; the Weight function is used to calculate how much weight should be assigned to each model.
10. The method for estimating battery state of charge based on SSA optimization integrated deep learning according to claim 1, characterized in that: In step 4, after calculating the Euclidean distance and the cosine similarity, the total value of the two normalized respectively is used as the main indicator for data weight allocation.
Citation Information
Cited By
Flow management and control data determination method and device based on electric power project
CN120996542A
Model training method, battery SOC estimation method, electronic equipment and storage medium
CN121522468A