Lithium ion battery life prediction method based on ms-tcn-trf
By employing the MS-TCN-Trf method, which combines multiple health indicator extraction, autoencoder compression, variational mode decomposition, and the Transformer model, the nonlinearity and noise issues of lithium-ion battery degradation curves are addressed, achieving high-precision and stable prediction of lithium-ion battery life.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN NORMAL UNIVERSITY
- Filing Date
- 2026-03-20
- Publication Date
- 2026-05-22
AI Technical Summary
The capacity degradation curve of lithium-ion batteries has nonlinear and non-stationary characteristics. Local capacity rebound and random noise phenomena mask the true degradation pattern, making it difficult for a single model to accurately characterize long-term degradation behavior. In addition, multiple feature inputs have redundancy and information redundancy, which affects the long-term prediction stability and accuracy of SOH/RUL.
We employ an MS-TCN-Trf-based approach to extract various health indicators from charge and discharge data. We then use stacked autoencoders for feature compression, variational mode decomposition for noise reduction, and a multi-scale temporal convolutional network and Transformer model for temporal modeling. Finally, we combine attention mechanisms and whale optimization algorithms for optimization to achieve joint prediction of SOH/RUL.
It improves the accuracy and robustness of lithium-ion battery lifetime prediction, and can stably and accurately predict SOH and RUL under complex nonlinear degradation environments. It also reduces feature redundancy and enhances the ability to model long-range dependencies.
Smart Images

Figure CN121878508B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of new energy vehicle battery management technology, and in particular to a method for predicting the lifespan of lithium-ion batteries based on MS-TCN-Trf. Background Technology
[0002] Lithium-ion batteries are widely used in new energy vehicles and other fields due to their high energy density, lightweight, and long cycle life. As the core power source for electric vehicles, the safety and reliability of lithium-ion batteries have become key technical issues. To achieve battery health monitoring, most vehicles are equipped with a Battery Management System (BMS) to estimate the battery's State of Health (SOH) and predict its Remaining Useful Life (RUL). Accurate assessment of SOH and RUL is crucial for ensuring the safe operation of the battery system and improving resource utilization efficiency.
[0003] Because the internal electrochemical reaction process of lithium-ion batteries is complex and the degradation mechanisms are numerous and coupled, mechanism-based modeling methods (such as electrochemical models and equivalent circuit models) often produce large errors in practical applications. Furthermore, they require remodeling and parameter identification under different battery types, operating conditions, and environmental conditions, resulting in high application costs and limited versatility.
[0004] In contrast, data-driven methods, which rely primarily on historical operational data for training and depend less on prior mechanistic knowledge, have gradually become one of the mainstream solutions for battery health management. For example, some studies extract health indicators (HIs) from curves of charge / discharge voltage, current, and temperature, and combine them with Gaussian Process Regression (GPR) to predict RUL; other studies combine methods such as particle filtering (PF) to reduce the impact of sample degradation and missing data; in addition, convolutional neural networks (CNNs) are used for SOH estimation to leverage their feature extraction capabilities, but some methods only focus on single-loop mapping relationships without fully considering the time-series characteristics of SOH; and some studies construct adaptive sliding window LSTM networks to capture long-term dependencies.
[0005] Currently, in the field of lithium-ion battery lifetime prediction, some studies have proposed using Variational Mode Decomposition (VMD) to decompose battery degradation features, in order to reduce noise interference and enhance the characterization of degradation trends. Other studies have used Multi-Scale Temporal Convolutional Networks (MS-TCN) to extract features from degradation sequences, in order to capture local variation patterns at different time scales. In addition, the Transformer model, with its self-attention mechanism, has advantages in long-range dependency modeling and is gradually being introduced into battery SOH / RUL prediction. At the same time, in order to improve the model's ability to focus on key degradation information, researchers have further introduced an attention mechanism to adaptively weight important features, thereby improving the accuracy and stability of lifetime prediction.
[0006] Question 1: The capacity degradation curve of lithium-ion batteries usually has nonlinear and non-stationary characteristics, and may exhibit local capacity rebound (capacity regeneration) and random noise. These factors can mask the true degradation pattern, making it difficult for a single model to accurately characterize long-term degradation behavior, thus affecting the long-term prediction stability and accuracy of SOH / RUL.
[0007] Question 2: In practical applications, it is often necessary to extract multiple health indicators from the charging and discharging process. However, there may be strong correlations and information redundancy between different indicators. If they are directly used as inputs at the same time, it is easy to cause feature overlap and increase the complexity of model construction, thereby reducing training efficiency and overall performance. In addition, data-driven models are highly dependent on the coverage and quality of training data. If there is a lack of effective feature fusion and dimensionality reduction processing, the generalization ability of the model may still be affected. Summary of the Invention
[0008] Data-driven deep learning methods are of great significance in the field of lithium-ion battery lifetime prediction. These methods can learn the complex nonlinear relationships between degradation features, state of health (SOH), and remaining useful life (RUL). However, existing methods struggle to stably extract effective degradation information when degradation signal noise and local fluctuations are present, and they suffer from redundancy in handling multiple feature inputs and insufficient modeling of long-range dependencies. To address these issues, this invention proposes a lithium-ion battery lifetime prediction method based on MS-TCN-Trf. This method first extracts multiple health indicators (HIs) from the original charge-discharge data, then uses a stacked autoencoder (SAE) to compress and obtain a single master health feature. Subsequently, variational mode decomposition (VMD) is used to decompose the master health feature to reduce noise and extract trend components. Finally, an MS-TCN-Trf composite prediction model is constructed to perform time-series modeling and lifetime prediction on the decomposition results, thereby improving the accuracy and robustness of SOH / RUL prediction. This includes:
[0009] S1: Data preprocessing and health indicator extraction: Extract four health indicators HI from the raw charge and discharge data and form a feature dataset;
[0010] S2: Feature compression, using a stacked autoencoder (SAE) to compress the four HIs into a one-dimensional master health feature;
[0011] S3: Signal decomposition, Variational Mode Decomposition (VMD) is used to decompose the main health features to obtain multiple modal components and residual signals;
[0012] S4: Construct the MS-TCN-Trf composite model and train it for prediction, obtain the SOH prediction curve, and determine the RUL prediction result based on the threshold.
[0013] Furthermore, the data preprocessing and health indicator extraction proposed in step S1 include:
[0014] S1-1: Divide the data into segments according to the full cycle, and extract the charging segment and discharging segment data respectively. The capacity is obtained from the discharging segment and used as the basic data for SOH / RUL labeling.
[0015] S1-2: In the charging segment, the first health index HI1_TH is calculated based on the voltage threshold crossing time. HI1_TH is the time difference between the voltage rising from the initial time tV0 to the upper limit voltage of 4.2V, i.e., HI1_TH=t_{Vmax}-t_{V0}, where t_{Vmax} is obtained by linear interpolation to obtain the time when the voltage first crosses from less than 4.2V to greater than or equal to 4.2V.
[0016] S1-3: In the charging segment, the second health index HI2_TR is calculated based on the voltage threshold crossing time. HI2_TR is the time difference for the voltage to rise from 3.8V to 4.1V, i.e., HI2_TR=t_{V=4.1}-t_{V=3.8}, where t_{V=3.8} and t_{V=4.1} are both obtained by linear interpolation to obtain the time of the first crossing of the corresponding threshold.
[0017] S1-4: During the discharge segment, calculate the third health index HI3_TT, where HI3_TT is the time when the temperature reaches its peak during the discharge process, that is, HI3_TT is the time t corresponding to the maximum value of the temperature sequence T during the discharge segment;
[0018] S1-5: In the discharge segment, the fourth health index HI4_TD is calculated based on the voltage threshold drop crossover time. HI4_TD is the time difference between the voltage drop from 3.8V to 3.4V, i.e., HI4_TD = t'3.4 - t'3.8, where t'3.8 and t'3.4 are obtained by linear interpolation to obtain the time when the voltage drops from above the threshold to below or equal to the threshold for the first time.
[0019] S1-6: Combine HI1_TH, HI2_TR, HI3_TT, HI4_TD and Capacity obtained from each loop to form a feature dataset, which will be used for subsequent feature compression and lifetime prediction.
[0020] Furthermore, the specific content of step S2 includes:
[0021] S2-1: Use the 4-dimensional health index vector X=[HI1_TH,HI2_TR,HI3_TT,HI4_TD] obtained in step S1 as the input of the autoencoder, and standardize it to reduce the impact of dimensional differences on training;
[0022] S2-2: Construct a two-stage stacked autoencoder (SAE), where the first-stage autoencoder encodes the 4-dimensional input into an m-dimensional hidden layer and reconstructs the 4-dimensional output, which is used to learn the nonlinear combination representation of the four HIs.
[0023] S2-3: The hidden representation of the first-level autoencoder is used as the input of the second-level autoencoder. The second-level autoencoder further encodes it into a 1D hidden representation and reconstructs the output. Finally, the output of the 1D hidden layer of the second-level autoencoder is used as the main health feature HI_principal, and together with the capacity, it forms the data sequence required for subsequent decomposition and prediction.
[0024] Furthermore, the specific content of step S3 includes:
[0025] S3-1: Mirror the main health feature sequence HI_principal to reduce boundary effects, and convert the extended sequence to the frequency domain;
[0026] S3-2: Set the VMD decomposition parameters, including the penalty factor α=2000, the update rate parameter τ=0.25, the number of modes K=4, the convergence threshold tol=1e-7 and the maximum number of iterations max_iter=5000, and use the alternating direction multiplier method in the frequency domain to iteratively update each modal component and its center frequency.
[0027] S3-3: After iterative convergence, the frequency domain modal components are restored to the time domain through inverse Fourier transform to obtain K modal components, which are then sorted from low to high center frequency. The component corresponding to the lowest center frequency is defined as the residual signal Residual, and the remaining components are denoted as IMF1, IMF2, and IMF3 in sequence. The output is used for subsequent lifetime prediction.
[0028] Furthermore, the specific content of step S4 includes:
[0029] S4-1: Constructing supervised learning labels required for lifetime prediction. First, calculate the health status (SOH) from the capacity sequence Capacity, where SOH is defined as the ratio of the current cycle capacity to the initial cycle capacity.
[0030] ,
[0031] The lifetime termination threshold is set to eol_soh = 0.8. The cycle number corresponding to the first time SOH(t) ≤ eol_soh is recorded as the lifetime termination point EOL. The remaining lifetime RUL is defined as the difference between EOL and the current cycle time t.
[0032] ,
[0033] This allows us to obtain the true values of SOH and RUL at each cycle time point, which serve as the evaluation benchmark for model training and testing.
[0034] S4-2: To improve the training stability of the prediction model, the residual signal Residual obtained in step S3 is standardized. The mean μ and standard deviation σ of Residual are calculated, and the normalized sequence Residual_norm is obtained as follows:
[0035] ,
[0036] Simultaneously, μ and σ are saved for subsequent inverse normalization recovery of prediction results;
[0037] S4-3: A sliding window approach is used to construct training samples. The historical window length `lookback` and the prediction step size `horizon` are defined, where `lookback` represents the number of historical time steps used for model input, and `horizon` represents the number of future time steps predicted by the model output. The `Residual_norm` sequence is traversed from `t=lookback` to `t=len(Residual_norm)-horizon`. At each time `t`, the interval `[t-lookback,t)` is extracted as the input sample `X`, and the interval `[t,t+horizon)` is extracted as the output label `Y`, thus constructing sample pairs `(X,Y)`. The shape of the input sample `X` is `(N, lookback,1)`, and the shape of the output label `Y` is `(N, horizontal,1)`, where `N` is the number of samples.
[0038] S4-4: Construct an MS-TCN-Trf composite prediction model and perform forward prediction. The model includes an MS-TCN module, a Transformer encoder module, an attention pooling module, and a fully connected prediction module. The MS-TCN module consists of multi-branch dilated one-dimensional convolutions. Each branch uses a different dilation rate d to extract multi-scale local degradation features, and then fuses and projects these features with 1×1 convolutions to obtain temporal features of a unified dimension. Subsequently, the Transformer encoder module establishes global correlations between time steps of the sequence through a multi-head self-attention mechanism and extracts long-term dependency features. The attention pooling module adaptively weights and converges the Transformer output features to obtain a global degradation representation vector, which is then input into the fully connected layer to output the future horizontal step Residual_norm prediction sequence.
[0039] The MS-TCN module includes a dilated convolution branch, and the calculation formula for the dilated convolution branch is as follows:
[0040] ,in, This indicates the input degenerate feature sequence at time step The value at that location, Indicates that the expansion rate is time steps in the convolution branch Corresponding output features; The size of the one-dimensional convolution kernel. The expansion rate; and These represent the first and second parts of the dilated convolution branch, respectively. Each convolutional kernel weight parameter and bias term, Represents a nonlinear activation function;
[0041] The self-attention calculation formula for the Transformer encoder is as follows:
[0042] ,in, and These represent the query matrix, key matrix, and value matrix obtained by linear mapping of the input features, respectively. This represents the dot product operation between the query matrix and the transpose of the key matrix. This represents the dimension of the key vector. Used to normalize relevance scores into attention weights;
[0043] The attention pooling module uses the following weighted aggregation method for temporal features:
[0044] ,in, This indicates the Transformer encoder at time step The output feature vector, For a learnable weight parameter vector, This represents the attention weight at the corresponding time step. The time step length of the input sequence. This is the weighted converged global feature vector;
[0045] S4-8: The mean squared error loss function is used to constrain the error between the predicted sequence and the true sequence, and the network parameters are updated through backpropagation. The formula for calculating the loss function is as follows:
[0046] ,
[0047] in, The future horizontal step Residual_norm prediction sequence output by the model. The actual Residual_norm sequence;
[0048] S4-9: Perform inverse normalization on the Residual_norm prediction sequence output by the model to obtain the Residual prediction sequence Residual_pred:
[0049] ,
[0050] The Residual_pred is then converted into a future SOH prediction curve using a linear mapping method, and the linear mapping relationship is as follows:
[0051] ,
[0052] a and b are obtained by least squares fitting at the corresponding time points of the training samples;
[0053] S4-10: Calculate the RUL prediction value based on the future SOH prediction curve. Search for the position Δt in the SOH prediction sequence of the future horizontal step to first satisfy SOH≤eol_soh. When such a position exists, use Δt as the predicted RUL. When no threshold crossing occurs in the future horizontal step, use the horizontal step as the predicted RUL output, thereby realizing the prediction of the remaining lifespan of the lithium-ion battery.
[0054] S4-11: Output and save the prediction results and evaluation indicators. Calculate the mean absolute error (MAE) and root mean square error (RMSE) of the RUL prediction. At the same time, calculate the prediction error of the future SOH curve as the SOH prediction accuracy indicator. Save the prediction results as a CSV file and the parameters and indicators as a text file for easy subsequent analysis and comparison verification.
[0055] Furthermore, the network structure of the MS-TCN module in step S4-4 includes:
[0056] The MS-TCN module employs a multi-branch parallel structure. Each branch contains a one-dimensional dilated convolutional layer, a ReLU activation layer, and a Dropout layer to extract local degradation features at different time scales. The dilation rate d of each branch's convolutional layer is set to dilations=(1,2,4,8) to form receptive fields at different scales, thereby simultaneously capturing the short-term fluctuation patterns and medium-term trends of the degradation sequence. Subsequently, the outputs of each branch are concatenated in the channel dimension, and the concatenated high-dimensional features are mapped to a unified dimension d_model through a 1×1 convolutional layer, achieving multi-scale feature fusion and reducing the computational complexity of the subsequent Transformer module.
[0057] Furthermore, the network structure of the Transformer encoder module in step S4-4 includes:
[0058] The Transformer encoder consists of several stacked TransformerEncoderLayers, each including a multi-head self-attention sub-layer and a feedforward neural network sub-layer. The number of multi-head attention heads is set to nhead, the hidden feature dimension is set to d_model, and d_model is required to be divisible by nhead. The feedforward network layer dimension is set to 4×d_model, and Dropout is introduced between sub-layers to enhance generalization ability. At the same time, residual connections and layer normalization mechanisms are used to ensure stable convergence of the network during long sequence training and improve the ability to express long-term degradation dependencies.
[0059] Furthermore, the structure of the attention pooling module in step S4-4 includes:
[0060] The attention pooling module contains a linear mapping layer that processes the temporal features output by the Transformer. The scores are mapped to scalar weights, and the attention weights at each time step are obtained through the softmax function. The global degradation representation vector is obtained by weighted summation of features at all time steps. This structure can adaptively highlight key degradation segments that contribute more to lifetime prediction, giving the model stronger feature selection and noise resistance when outputting future degradation trends.
[0061] Furthermore, the structure of the fully connected prediction module in step S4-4 includes:
[0062] The global feature vector obtained by attention pooling is input into the fully connected prediction module. The prediction module contains two linear mapping layers. The first layer maps the feature dimension to d_model and performs ReLU activation and Dropout operation. The second layer outputs a prediction vector of length horizontal, thereby obtaining the Residual_norm prediction sequence for the next horizontal step, realizing multi-step degradation trend prediction.
[0063] Furthermore, the purpose of Residual sequence normalization in step S4-2 includes:
[0064] Since the residual sequence has different numerical scales under different batteries and different operating conditions, directly inputting it into the model will cause unstable gradient updates and slow training convergence. Therefore, this invention uses the mean μ and standard deviation σ for standardization to make the input sequence have a zero mean and unit variance distribution, thereby improving the stability of network training and avoiding the excessive influence of individual outliers on the prediction results.
[0065] Furthermore, the significance of constructing the sliding window sample in step S4-3 includes:
[0066] By using a sliding window approach, the univariate degradation sequence is reconstructed into supervised learning sample pairs (X, Y), where the input X contains lookback historical time steps and the label Y contains future horizontal time steps. This allows the model to output a prediction of the degradation trend over a future period based on learning the historical degradation patterns, avoiding the problem of gradual error accumulation caused by performing only single-step predictions.
[0067] Furthermore, the method for dividing the training set, validation set, and test set in step S4 includes:
[0068] All the constructed supervised samples are divided into training set, validation set and test set in chronological order, with the training set accounting for 0.7, the validation set accounting for 0.15, and the test set accounting for 0.15. The training set is used for model parameter learning, the validation set is used for performance evaluation of the hyperparameter optimization process, and the test set is used for final prediction accuracy evaluation, thereby ensuring the reliability and objectivity of the lifetime prediction results.
[0069] Furthermore, the optimization algorithm in step S4 includes:
[0070] The method introduces the Whale Optimization Algorithm (WOA) to automatically optimize the key hyperparameters of the MS-TCN-Trf composite model. These key hyperparameters include: lookback, horizon, d_model, nhead, num_layers, dropout, lr, and batch_size. The Transformer module includes a Transformer structure that satisfies the following constraint: the model dimension d_model is divisible by the number of attention heads nhead. The fitness function is constructed primarily based on the remaining lifetime error (RUL) of the validation set, combined with the state of health (SOH) error.
[0071] The present invention has the following beneficial effects:
[0072] (1) By extracting multiple health indicators from the charging and discharging process and using SAE for nonlinear feature fusion and compression, the redundancy between multiple features is effectively reduced, and the compactness and effectiveness of feature expression are improved.
[0073] (2) By introducing VMD to decompose the main health features, noise interference can be effectively suppressed and degradation information at different scales can be separated, thereby enhancing the characterizability of degradation trends;
[0074] (3) By constructing a composite model that includes MS-TCN and Transformer, we can make full use of MS-TCN's ability to extract multi-scale local temporal features and Transformer's ability to model long-range dependencies, thereby improving the ability to characterize the battery degradation process.
[0075] (4) By introducing Attention to adaptively weight key degradation features, the model’s ability to focus on important information is enhanced, thereby improving the accuracy of prediction results;
[0076] (5) By integrating multiple models and signal processing methods, and combining WOA to automatically optimize key hyperparameters, the prediction accuracy and stability of the model under different working conditions are further improved.
[0077] (6) The method of the present invention can simultaneously achieve joint prediction of SOH and RUL, and still has good robustness and generalization ability in complex nonlinear degradation environment. Attached Figure Description
[0078] To more clearly illustrate the technical solution in this specification, the accompanying drawings used in the technical solution will be briefly introduced below.
[0079] Figure 1 This is the overall architecture of the battery life prediction model based on MS-TCN-Trf proposed in this invention;
[0080] Figure 2 This is a schematic diagram illustrating the SOH prediction results of the method of the present invention on battery sample B0005 of the NASA lithium-ion battery dataset, wherein, Figure 2 (a) shows the SOH prediction results of the composite model proposed in this invention. Figure 2 (b) Comparison of prediction results between the MS-TCN model alone, the Transformer model alone, and the composite model of this invention;
[0081] Figure 3 This is a visualization of the SOH prediction task of the model proposed in this invention on battery sample B0006 in the NASA lithium-ion battery dataset;
[0082] Figure 4 Visualization of MAE and RMSE metrics from SOH prediction experiments performed on NASA lithium-ion battery datasets B0005 and B0006. Detailed Implementation
[0083] This invention proposes a lithium-ion battery lifetime prediction method based on MS-TCN-Trf, and conducts lifetime prediction experiments on a publicly available battery cycling dataset. The method is used to train and test the data to verify its SOH prediction accuracy and RUL prediction generalization performance.
[0084] like Figure 1 As shown, the method of this invention first processes the raw data and constructs a multidimensional health index, which is then fused using SAE to obtain a comprehensive health index HI. Subsequently, VMD is used to decompose HI and extract the residual signal as the input to the prediction model. The prediction model consists of MS-TCN, Transformer, and Attention mechanisms, used to mine multi-scale temporal features and key degradation information. The model output is mapped by SOH to achieve the prediction of remaining battery life (RUL).
[0085] The first step involves data preprocessing and extraction of health indicators (HIs) to construct a degradation feature sequence suitable for lifetime prediction. First, the original charge-discharge experimental data of the battery is read, and each cycle is segmented and sorted into charging (type=charge) and discharging (type=discharge) segments according to a full cycle. Then, based on the voltage threshold crossing time and the peak discharge temperature time, four health indicators (HIs) are extracted from each cycle to form a feature dataset. HI1 is the time difference TH when the charging voltage first reaches the upper limit voltage of 4.2V; HI2 is the time difference TR when the charging voltage rises from 3.8V to 4.1V; HI3 is the time TT when the discharge temperature reaches its maximum value; and HI4 is the time difference TD when the discharge voltage drops from 3.8V to 3.4V. The threshold crossing time is calculated using linear interpolation to improve the accuracy of the threshold arrival time. Finally, the capacity corresponding to each cycle and the above four HIs are combined to form a feature data table arranged by cycle number.
[0086] The second step involves using a stacked autoencoder (SAE) to compress the 4D HI features and extract a one-dimensional principal health feature. The 4D HI vector obtained in step 0021 is used as input and trained layer-by-layer through a two-stage autoencoder: the first-stage autoencoder encodes the 4D HI into an m-dimensional latent representation and reconstructs the 4D input to minimize reconstruction error; the second-stage autoencoder further encodes the m-dimensional latent representation into a one-dimensional representation and reconstructs the m-dimensional input. The one-dimensional representation output by the second-stage autoencoder is used as the principal health feature HI_principal, thereby achieving non-linear fusion from multiple health indicators to a single health feature, reducing redundancy and highlighting core features related to capacity degradation.
[0087] The third step involves using Variational Mode Decomposition (VMD) to decompose the principal health feature to suppress noise and extract multi-scale degradation information. The principal health feature HI_principal obtained in step 0022 is used as the input signal. The number of modes K is set to 4. An iterative solution based on ADMM is used to update each modal component and its center frequency in the frequency domain, and four components are output after the convergence condition is met. The components are sorted from low to high center frequency, with the lowest center frequency component used as the residual signal Residual, and the remaining components denoted as IMF1, IMF2, and IMF3 respectively. Simultaneously, the decomposition results are reconstructed and verified to ensure that IMF1+IMF2+IMF3+Residual can approximately reconstruct HI_principal, thereby obtaining stable degradation trend components and providing input for subsequent lifetime prediction.
[0088] The fourth step involves constructing and training an MS-TCN-Trf composite prediction model to achieve the joint output of SOH and RUL. First, the residual sequence is used as the model input signal, and the residual is standardized. Then, a sliding window approach is used to reconstruct the supervised learning samples, setting the historical window length as "lookback," meaning the residual from the past lookback time steps is used as the input sample X. Simultaneously, the prediction step size is set as "horizon," meaning the residual from the next horizontal time steps is used as the output label Y, thus constructing multi-step prediction sample pairs (X,Y). The input samples are fed into the MS-TCN module for multi-scale dilated convolution feature extraction. MS-TCN employs a multi-branch dilation rate structure to capture local degradation patterns at different time scales. The MS-TCN output is then fed into a Transformer encoder to establish long-range dependencies. Next, an attention pooling module adaptively weights and converges the features from each time step to obtain a global degradation feature vector. Finally, a fully connected prediction layer outputs the predicted residual sequence for the next horizontal step. The model uses mean squared error as the training loss function and gradient pruning is employed to improve training stability. After completing the Residual prediction, the predicted sequence is denormalized to restore the true scale, and a mapping relationship between Residual and SOH is established by linear fitting: SOH≈a·Residual+b. The future Residual prediction sequence is converted into a future SOH prediction curve. When the future SOH prediction curve first drops to the threshold eol_soh=0.8, the corresponding step number is the RUL prediction result, thus realizing lifetime prediction.
[0089] like Figure 2 As shown, Figure 2 (a) Visualization of SOH prediction results on the test set using the composite model proposed in this invention; the blue curve in the figure represents the historical true SOH, the orange curve represents the future true SOH, the green dashed line is the SOH predicted by the model, the blue horizontal dashed line represents the end-of-life threshold EOL (SOH=0.80), and the magnified view is used to show the prediction differences in the region near EOL. Figure 2(b) Visualization results comparing the MS-TCN model alone, the Transformer model alone, and the composite model proposed in this invention are presented. In the figure, the blue curve represents the historical true SOH, the orange curve represents the future true SOH, the green dashed line is the SOH predicted by the MS-TCN model alone, the red dashed line is the SOH predicted by the Transformer model alone, the purple dashed line is the SOH predicted by the composite model proposed in this invention, and the blue horizontal dashed line represents the end-of-life threshold EOL (SOH=0.80). Through comparison, it can be clearly observed that compared with the baseline methods of MS-TCN alone or Transformer alone, the composite model proposed in this invention predicts the true curve more closely in the critical degradation stage, can more accurately depict the SOH decline trend, and maintains more stable prediction accuracy in long-term prediction scenarios.
[0090] like Figure 3 As shown in the figure, the blue curve represents the actual SOH during the battery's historical cycling process, the orange curve represents the actual SOH in the future cycling stage, the green dashed line represents the SOH predicted by the model, and the horizontal dashed line represents the end-of-life threshold (EOL, SOH = 0.80). It can be observed that the model proposed in this invention can accurately track the overall degradation trend of battery SOH and maintain good predictive consistency even near the end of its lifespan, verifying the effectiveness and stability of this method in battery health state prediction.
[0091] The fifth step involves introducing the Whale Optimization Algorithm (WOA) to automatically optimize key hyperparameters of the composite model to improve prediction performance. Using the validation set error as the fitness metric, WOA searches for hyperparameters such as lookback, horizon, d_model, nhead, num_layers, dropout, lr, and batch_size. The optimal hyperparameter combination is obtained while satisfying the Transformer structural constraint (d_model is divisible by nhead). Subsequently, the model is retrained on both the training and validation sets using the optimal hyperparameters, and the final prediction results are output on the test set to ensure model performance and generalization ability.
[0092] The sixth step is to evaluate and compare the prediction results. The predicted RUL values at each time point in the test set are compared with the actual RUL values. The mean absolute error (MAE) and root mean square error (RMSE) of the RUL predictions are calculated. Simultaneously, the MAE and RMSE of the future SOH prediction curves are calculated to measure the fitting ability to the degradation trend. The prediction results are saved as a CSV file, and the optimal hyperparameters and evaluation metrics are saved as a text file for subsequent visualization and cross-sectional comparison.
[0093] like Figure 4As shown, the proposed method achieved high prediction accuracy under different battery sample conditions. Specifically, the predicted SOH MAE for B0005 was 0.0072 and the RMSE was 0.0091, while for B0006 the MAE was 0.0139 and the RMSE was 0.0168. Experimental results demonstrate that this method can stably and accurately characterize the evolution trend of battery SOH under different degradation conditions, exhibiting good generalization ability.
[0094] Target dataset: This invention can be validated on publicly available battery cycle life datasets, such as battery samples in the NASA lithium-ion battery dataset (e.g., B0005, B0006, etc.). The dataset contains information such as voltage, current, temperature, and cycle capacity during a complete charge-discharge cycle, which can be used to extract health indicators and construct a capacity degradation sequence. In this embodiment, the battery cycle number is used as the time step, and the capacity is used as the basis for SOH calculation. The HI is extracted, the model is trained, and the life prediction results are output according to the aforementioned steps.
[0095] In summary, this invention proposes a lithium-ion battery lifetime prediction method based on MS-TCN-Trf and experimentally verifies it. The innovations of this method lie in: constructing a multi-source degradation characterization using four health indicators and obtaining the main health feature through nonlinear feature fusion using SAE; further employing VMD to decompose the degradation signal into multiple scales and extracting more stable residual signals as prediction inputs; and integrating MS-TCN's multi-scale local feature extraction capability, Transformer's long-term dependency modeling capability, and attention mechanism's key segment adaptive weighting capability at the prediction model level, combined with WOA for automatic optimization of key hyperparameters, thereby improving SOH prediction accuracy and RUL prediction robustness.
Claims
1. A lithium-ion battery lifetime prediction method based on MS-TCN-Trf, characterized in that, A composite model is constructed, comprising a VMD module, an MS-TCN module, a Transformer module, an SAE module, and an Attention mechanism module. The core of the composite model is a temporal network composed of MS-TCN and Transformer. SAE is used to compress the health metric HI, and the modality decomposition capability of VMD and the Attention mechanism are combined to enhance the representation of key degradation features, thereby improving the overall performance of the composite model. Specifically, the method includes the following: S1: Data preprocessing and health indicator extraction: Extract four health indicators HI from the raw charge and discharge data and form a feature dataset; S2: Feature compression, using a stacked autoencoder (SAE) to compress the four HIs into a one-dimensional master health feature; S3: Signal decomposition, Variational Mode Decomposition (VMD) is used to decompose the main health features to obtain multiple modal components and residual signals; S4: Construct the MS-TCN-Trf composite model and train it for prediction, obtain the SOH prediction curve, and determine the RUL prediction result based on the threshold.
2. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 1, characterized in that, The specific operations of step S1 include: S1-1: Divide the data into segments according to the full cycle, and extract the charging segment and discharging segment data respectively. The capacity is obtained from the discharging segment and used as the basic data for SOH / RUL labeling. S1-2: In the charging segment, the first health index HI1_TH is calculated based on the voltage threshold crossing time. HI1_TH is the time difference between the voltage rising from the initial time tV0 to the upper limit voltage of 4.2V, i.e., HI1_TH=t_{Vmax}-t_{V0}, where t_{Vmax} is obtained by linear interpolation to obtain the time when the voltage first crosses from less than 4.2V to greater than or equal to 4.2V. S1-3: In the charging segment, the second health index HI2_TR is calculated based on the voltage threshold crossing time. HI2_TR is the time difference for the voltage to rise from 3.8V to 4.1V, i.e., HI2_TR=t_{V=4.1}-t_{V=3.8}, where t_{V=3.8} and t_{V=4.1} are both obtained by linear interpolation to obtain the time of the first crossing of the corresponding threshold. S1-4: During the discharge phase, calculate the third health index HI3_TT, where HI3_TT is the time when the temperature reaches its peak during the discharge process, i.e., HI3_TT is the time t corresponding to the maximum value of the temperature sequence T during the discharge phase. S1-5: In the discharge segment, the fourth health index HI4_TD is calculated based on the voltage threshold drop crossover time. HI4_TD is the time difference between the voltage drop from 3.8V to 3.4V, i.e., HI4_TD = t'3.4 - t'3.8, where t'3.8 and t'3.4 are obtained by linear interpolation to obtain the time when the voltage drops from above the threshold to below or equal to the threshold for the first time. S1-6: Combine HI1_TH, HI2_TR, HI3_TT, HI4_TD and Capacity obtained from each loop to form a feature dataset, which will be used for subsequent feature compression and lifetime prediction.
3. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 1, characterized in that, The specific operations of step S2 include: S2-1: Use the 4-dimensional health index vector X=[HI1_TH,HI2_TR,HI3_TT,HI4_TD] obtained in step S1 as the input of the autoencoder, and standardize it to reduce the impact of dimensional differences on training; S2-2: Construct a two-stage stacked autoencoder (SAE), where the first-stage autoencoder encodes the 4-dimensional input into an m-dimensional hidden layer and reconstructs the 4-dimensional output, which is used to learn the nonlinear combination representation of the four HIs. S2-3: The hidden representation of the first-level autoencoder is used as the input of the second-level autoencoder. The second-level autoencoder further encodes it into a 1D hidden representation and reconstructs the output. Finally, the output of the 1D hidden layer of the second-level autoencoder is used as the main health feature HI_principal, and together with the capacity, it forms the data sequence required for subsequent decomposition and prediction.
4. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 1, characterized in that, The specific operations of step S3 include: S3-1: Mirror the main health feature sequence HI_principal to reduce boundary effects, and convert the extended sequence to the frequency domain; S3-2: Set the VMD decomposition parameters, including the penalty factor α=2000, the update rate parameter τ=0.25, the number of modes K=4, the convergence threshold tol=1e-7 and the maximum number of iterations max_iter=5000, and use the alternating direction multiplier method in the frequency domain to iteratively update each modal component and its center frequency. S3-3: After iterative convergence, the frequency domain modal components are restored to the time domain through inverse Fourier transform to obtain K modal components, which are then sorted from low to high center frequency. The component corresponding to the lowest center frequency is defined as the residual signal Residual, and the remaining components are denoted as IMF1, IMF2, and IMF3 in sequence. The output is used for subsequent lifetime prediction.
5. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 1, characterized in that, The specific operations of step S4 include: S4-1: Constructing supervised learning labels required for lifetime prediction. First, calculate the health status (SOH) from the capacity sequence Capacity, where SOH is defined as the ratio of the current cycle capacity to the initial cycle capacity. The lifetime termination threshold is set to eol_soh = 0.
8. The cycle number corresponding to the first time SOH(t) ≤ eol_soh is recorded as the lifetime termination point EOL. The remaining lifetime RUL is defined as the difference between EOL and the current cycle time t. This allows us to obtain the true SOH and true RUL values at each cycle time point, which serve as the evaluation benchmark for model training and testing. S4-2: To improve the training stability of the prediction model, the residual signal Residual obtained in step S3 is standardized. The mean μ and standard deviation σ of Residual are calculated, and the normalized sequence Residual_norm is obtained as follows: Meanwhile, μ and σ are saved for subsequent inverse normalization recovery of prediction results; S4-3: A sliding window approach is used to construct training samples. The historical window length `lookback` and the prediction step size `horizon` are defined, where `lookback` represents the number of historical time steps used for model input, and `horizon` represents the number of future time steps predicted by the model output. The `Residual_norm` sequence is traversed from `t=lookback` to `t=len(Residual_norm)-horizon`. At each time `t`, the interval `[t-lookback,t)` is extracted as the input sample `X`, and the interval `[t,t+horizon)` is extracted as the output label `Y`, thus constructing sample pairs `(X,Y)`. The shape of the input sample `X` is `(N, lookback,1)`, and the shape of the output label `Y` is `(N, horizontal,1)`, where `N` is the number of samples. S4-4: Construct an MS-TCN-Trf composite prediction model and perform forward prediction. The model includes an MS-TCN module, a Transformer encoder module, an attention pooling module, and a fully connected prediction module. The MS-TCN module consists of multi-branch dilated one-dimensional convolutions. Each branch uses a different dilation rate d to extract multi-scale local degradation features, and then fuses and projects these features with 1×1 convolutions to obtain temporal features of a unified dimension. Subsequently, the Transformer encoder module establishes global correlations between time steps of the sequence through a multi-head self-attention mechanism and extracts long-term dependency features. The attention pooling module adaptively weights and converges the Transformer output features to obtain a global degradation representation vector, which is then input into the fully connected layer to output the future horizontal step Residual_norm prediction sequence. The MS-TCN module includes a dilated convolution branch, and the calculation formula for the dilated convolution branch is as follows: ,in, This indicates the input degenerate feature sequence at time step The value at that location, Indicates that the expansion rate is time steps in the convolution branch Corresponding output features; The size of the one-dimensional convolution kernel. The expansion rate; and These represent the first and second parts of the dilated convolution branch, respectively. Each convolutional kernel weight parameter and bias term, Represents a non-linear activation function; The self-attention calculation formula for the Transformer encoder is as follows: ,in, and These represent the query matrix, key matrix, and value matrix obtained by linear mapping of the input features, respectively. This represents the dot product operation between the query matrix and the transpose of the key matrix. The dimension of the key vector. Used to normalize relevance scores into attention weights; The attention pooling module uses the following weighted aggregation method for temporal features: ,in, This indicates the Transformer encoder at time step The output feature vector, For a learnable weight parameter vector, This represents the attention weight at the corresponding time step. The time step length of the input sequence. This is the weighted converged global feature vector.
6. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 5, wherein the network structure of the MS-TCN module in step S4-4 is as follows: The MS-TCN module adopts a multi-branch parallel structure. Each branch contains a one-dimensional dilated convolutional layer, a ReLU activation layer, and a Dropout layer. The dilation rate d of each branch's convolutional layer is set to dilations=(1,2,4,8) to form receptive fields of different scales. Then, the outputs of each branch are concatenated in the channel dimension, and the concatenated high-dimensional features are mapped to a unified dimension d_model through a 1×1 convolutional layer, thereby realizing multi-scale feature fusion and reducing the computational complexity of the subsequent Transformer module.
7. In the lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 5, the network structure in the Transformer encoder module of step S4-4 is as follows: The Transformer encoder consists of several stacked TransformerEncoderLayer layers. Each layer includes a multi-head self-attention sub-layer and a feedforward neural network sub-layer. The number of multi-head attention heads is set to nhead, the dimension of the hidden features is set to d_model, and d_model is required to be divisible by nhead. The dimension of the feedforward network layer is set to 4×d_model, and Dropout is introduced between sub-layers to enhance generalization ability. Residual connections and layer normalization mechanisms are also used.
8. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 5, wherein the network structure in the attention pooling module of step S4-4 is as follows: The attention pooling module contains a linear mapping layer that processes the temporal features output by the Transformer. The scores are mapped to scalar weights, and the attention weights at each time step are obtained through the softmax function. The global degradation representation vector is obtained by weighted summation of features at all time steps.
9. The lithium-ion battery lifetime prediction method based on MS-TCN-Trf according to claim 1, wherein the optimization algorithm for step S4 is as follows: The method introduces the Whale Optimization Algorithm (WOA) to automatically optimize the key hyperparameters of the MS-TCN-Trf composite model. These key hyperparameters include: The Transformer module includes a Transformer structure that satisfies the following constraints: the model dimension d_model is divisible by the number of attention heads nhead; and the fitness function is constructed primarily based on the remaining lifetime error (RUL) of the validation set and combined with the state of health (SOH) error.