Battery state of charge prediction method, apparatus, device, medium, and program product
By utilizing the encoder and decoder structure of the Transformer model and combining it with the discharge sequence data of lithium-ion batteries, historical and real-time features are extracted, solving the problem of low accuracy in predicting the state of charge of lithium-ion batteries and achieving more accurate battery state estimation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHN ENERGY NEW ENERGY TECHNOLOGY RESEARCH INSTITUTE CO LTD
- Filing Date
- 2026-02-09
- Publication Date
- 2026-06-09
AI Technical Summary
The accuracy of predicting the state of charge of lithium-ion batteries is low. Due to the high nonlinearity of lithium-ion batteries and the influence of environmental factors, existing methods are difficult to accurately estimate the remaining capacity and lifespan of batteries.
The encoder and decoder structure of the Transformer model is adopted. By acquiring the discharge sequence data of the battery, the discharge time series features of historical discharge data are extracted and combined with real-time discharge data for prediction. This process mines the time series relationship and nonlinear mapping to prevent the loss of key features.
It improves the accuracy of state of charge prediction, enhances the precision and stability of the battery management system, and reduces the requirements for battery modeling accuracy and historical data volume.
Smart Images

Figure CN122172022A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of battery technology, and in particular to a method, apparatus, device, medium, and program product for predicting the state of charge of a battery. Background Technology
[0002] Lithium-ion batteries are widely used in industry, transportation, aerospace, and other fields due to their advantages such as high specific energy, high specific power, long lifespan, and low cost. The state of charge (SOC) of a lithium-ion battery is a crucial parameter characterizing the operating state of a lithium-ion battery system. While SOC directly reflects the remaining capacity of the battery, the maximum SOC also reflects, to some extent, the remaining lifespan of the battery. Therefore, lithium battery SOC estimation is a vital function of the Battery Management System (BMS). Accurate SOC estimation is of great significance for improving battery safety and ensuring the stable operation of the battery system.
[0003] Currently, lithium-ion batteries are used in various industries, with different operating conditions and states. Lithium-ion batteries are inherently highly nonlinear and easily affected by environmental factors, resulting in low accuracy in predicting the state of charge. Summary of the Invention
[0004] Therefore, it is necessary to provide a battery state of charge prediction method, apparatus, device, medium, and program product that can improve the accuracy of battery state of charge prediction in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides a method for predicting the state of charge of a battery, including:
[0006] Acquire discharge sequence data of the target battery, the discharge sequence data including real-time discharge data and historical discharge data prior to the real-time discharge data;
[0007] The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time sequence features of the historical discharge data.
[0008] The discharge timing features and the real-time discharge data are input together into the decoder of the target state of charge prediction model. Guided by the real-time discharge data, the state of charge prediction result of the target battery is output.
[0009] In one embodiment, the step of inputting the discharge timing features and the real-time discharge data into the decoder of the target state of charge prediction model, and outputting the target battery's state of charge prediction result under the guidance of the real-time discharge data, includes:
[0010] The real-time discharge data is processed by the decoder to extract time-series features and obtain conditional time-series features.
[0011] The conditional timing features are fused with the discharge timing features to obtain fused timing features;
[0012] Based on the fused timing features, the predicted state of charge of the target battery is output.
[0013] In one embodiment, fusing the conditional timing features with the discharge timing features to obtain fused timing features includes:
[0014] Using the discharge timing features as the query vector and the condition timing features as the key-value pairs, multi-head attention processing is performed to obtain multiple attention outputs;
[0015] The attention output is weighted and summed to obtain the fused temporal features.
[0016] In one embodiment, the step of outputting the predicted state of charge of the target battery based on the fused timing features includes:
[0017] The fused temporal features are decoded and transformed using the first feedforward neural network in the decoder to obtain decoded temporal information;
[0018] By using a fully connected layer connected to the output of the first feedforward neural network, regression processing is performed on the decoded timing information to output the predicted state of charge of the target battery within a preset time step.
[0019] In one embodiment, the step of inputting the historical discharge data into the encoder of the target state of charge prediction model and extracting the discharge time-series features of the historical discharge data includes:
[0020] The historical discharge data is upscaled using the input layer and multiple attention heads in the encoder to extract high-dimensional time-series information from the historical discharge data.
[0021] The high-dimensional time series information is reduced in dimensionality by a second feedforward neural network connected to the output of the multi-attention head, thereby obtaining the discharge time series characteristics of the historical discharge data.
[0022] In one embodiment, acquiring the discharge sequence data of the target battery includes:
[0023] Determine a data buffer for storing the discharge data of the target battery;
[0024] The discharge sequence data of the target battery is obtained from the data buffer through a sliding time window with a preset window length.
[0025] Secondly, this application also provides a battery state of charge prediction device, comprising:
[0026] A sequence data acquisition module is used to acquire discharge sequence data of a target battery, wherein the discharge sequence data includes real-time discharge data and historical discharge data prior to the real-time discharge data;
[0027] The encoding feature extraction module is used to input the historical discharge data into the encoder of the target state of charge prediction model and extract the discharge time sequence features of the historical discharge data.
[0028] The prediction result output module is used to input the discharge timing features and the real-time discharge data into the decoder of the target state of charge prediction model, and output the state of charge prediction result of the target battery under the guidance of the real-time discharge data.
[0029] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0030] Acquire discharge sequence data of the target battery, the discharge sequence data including real-time discharge data and historical discharge data prior to the real-time discharge data;
[0031] The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time sequence features of the historical discharge data.
[0032] The discharge timing features and the real-time discharge data are input together into the decoder of the target state of charge prediction model. Guided by the real-time discharge data, the state of charge prediction result of the target battery is output.
[0033] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0034] Acquire discharge sequence data of the target battery, the discharge sequence data including real-time discharge data and historical discharge data prior to the real-time discharge data;
[0035] The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time sequence features of the historical discharge data.
[0036] The discharge timing features and the real-time discharge data are input together into the decoder of the target state of charge prediction model. Guided by the real-time discharge data, the state of charge prediction result of the target battery is output.
[0037] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0038] Acquire discharge sequence data of the target battery, the discharge sequence data including real-time discharge data and historical discharge data prior to the real-time discharge data;
[0039] The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time sequence features of the historical discharge data.
[0040] The discharge timing features and the real-time discharge data are input together into the decoder of the target state of charge prediction model. Guided by the real-time discharge data, the state of charge prediction result of the target battery is output.
[0041] The aforementioned battery state-of-charge (POC) prediction method, apparatus, device, medium, and program products acquire discharge sequence data of the target battery, including real-time discharge data and historical discharge data preceding the real-time discharge data. The historical discharge data is input into the encoder of the target POC prediction model to extract the discharge time-series features. The discharge time-series features and real-time discharge data are then input into the decoder of the target POC prediction model. Guided by the real-time discharge data, the POC prediction result of the target battery is output. Based on the target POC prediction model containing an encoder and decoder structure, the historical discharge data in the discharge sequence data is encoded and extracted. Event sequence relationships within the historical discharge data are mined to obtain discharge time-series features. Using real-time discharge data as a guiding condition, these features are directly input into the decoder along with the discharge time-series features. This prevents the loss of key features of the real-time discharge data during the encoding process, thereby improving the accuracy of the output POC prediction result. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a diagram illustrating the application environment of a battery state-of-charge prediction method in one embodiment.
[0044] Figure 2 This is a flowchart illustrating a battery state of charge prediction method in one embodiment;
[0045] Figure 3 This is a flowchart illustrating the process of inputting discharge timing features and real-time discharge data into the decoder of the target state of charge prediction model in one embodiment, and outputting the target battery's state of charge prediction result under the guidance of the real-time discharge data.
[0046] Figure 4 This is a flowchart illustrating the battery state of charge prediction method in another embodiment;
[0047] Figure 5 This is a structural block diagram of a battery state of charge prediction device in one embodiment;
[0048] Figure 6 An internal structural diagram of a computer device in one embodiment.
[0049] Figure 7 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0051] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0052] Currently, commonly used SOC estimation methods in related technologies include the ampere-hour integral method, the open-circuit voltage method, Kalman filtering and its extended algorithms, and data-driven neural network methods. These methods mostly use historical operating data of lithium-ion batteries to build models, establishing a mapping relationship between various state parameters of the lithium-ion battery and its SOC. After the model is built, it provides real-time SOC estimates based on real-time operating data, thereby achieving accurate state-of-charge estimation of the lithium-ion battery.
[0053] Both the ampere-hour integral method and the open-circuit voltage method have high requirements for the initial state of charge (SOC) of the battery and are easily affected by initial conditions and sensor accuracy, leading to reduced accuracy in SOC estimation. The Kalman filter algorithm uses the idea of optimal estimation, inferring the battery's operating state at the next moment based on the battery's state at the previous moment, but it requires high accuracy from the battery model. Currently, lithium-ion batteries are used in various industries with different operating conditions and states. Lithium-ion batteries themselves are highly nonlinear and easily affected by environmental factors; therefore, the accuracy of the Kalman filter algorithm is limited by the accuracy of the battery modeling. Data-driven neural network algorithms build models by mining historical battery operating parameters. In practical applications, real-time monitoring parameters from the BMS are input into the model to obtain an SOC estimate. However, data-driven methods have certain requirements for the amount of historical data, and model training carries the risk of overfitting.
[0054] Based on this, this application provides a method for predicting the state of charge (SOC) of a battery. The method uses discharge sequence data as input to the model encoder, focusing on the temporal relationship of the input information. Real-time discharge data at the estimated time is used as conditional information input to the model decoder to deeply explore the nonlinear relationship between the temporal input information and SOC. The encoder extracts features from the input sequence, and the high-dimensional temporal features output and the nonlinear mapping mined by the decoder are used together as the basis for decoding output, resulting in an accurate estimate of SOC.
[0055] The battery state-of-charge prediction method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 acquires the discharge sequence data of the target battery, including real-time discharge data and historical discharge data preceding the real-time discharge data. The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time-series features of the historical discharge data. The discharge time-series features and real-time discharge data are input together into the decoder of the target state of charge prediction model, and the state of charge prediction result of the target battery is output under the guidance of the real-time discharge data. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, and tablets. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0056] In one exemplary embodiment, such as Figure 2 As shown, a method for predicting the state of charge of a battery is provided, and this method is applied to... Figure 1 The following steps are used as an example of the terminal in the example, including steps 202 to 206.
[0057] Step 202: Obtain the discharge sequence data of the target battery. The discharge sequence data includes real-time discharge data and historical discharge data prior to the real-time discharge data.
[0058] The target battery refers to the battery for which state of charge (SOC) prediction is performed. Discharge sequence data refers to the time-series data generated by the target battery during its discharge state. In chronological order, discharge sequence data can include real-time discharge data and historical discharge data preceding the real-time data. Real-time discharge data refers to the latest available discharge data within the current time window. Discharge sequence data can be obtained from the target battery's Battery Management System (BMS). During the detection process, multiple samples can be taken within a single time window to form a time-seriesd discharge sequence. Depending on the physical meaning of the data, discharge sequence data can include data such as current, voltage, and temperature. Among these, real-time current has a strong correlation with the future SOC of the battery; therefore, real-time discharge data can be used, allowing for more accurate SOC prediction in subsequent condition-guided processes.
[0059] For example, when the condition for predicting the state of charge of the target battery is triggered, the discharge sequence data detected by the BMS of the target battery is acquired and stored. If the time series length of the discharge sequence data reaches the preset length, the discharge sequence data is segmented, and the latest discharge sequence data is used as real-time discharge data, while the data before the real-time discharge data is used as historical discharge data.
[0060] In one embodiment, acquiring discharge sequence data of a target battery includes: determining a data buffer for storing discharge data of the target battery; and acquiring discharge sequence data of the target battery from the data buffer through a sliding time window with a preset window length.
[0061] A data buffer is a storage space for storing the discharge data of the target battery. It can store a certain amount of discharge sequence data. Once the stored data is used up, the storage space can be freed up by deleting this data, awaiting the next new data write. The discharge sequence data detected by the BMS can be synchronously stored in the data buffer for use in the state of charge (SCC) prediction process. Multiple data buffers can be set to store discharge sequence data from different time periods. A sliding time window is a window that moves with time to collect data; the preset window length represents the time interval between its start and end positions. During the SCC prediction process for the target battery, the storage position of the data buffer is determined, and the latest real-time discharge data, as well as historical discharge data preceding the real-time discharge data within the preset window length, are collected through the sliding time window.
[0062] A data buffer is set up for data flow, and a sliding time window can obtain accurate discharge sequence data, providing accurate data support for subsequent model predictions.
[0063] Step 204: Input the historical discharge data into the encoder of the target state of charge prediction model and extract the discharge time sequence features of the historical discharge data.
[0064] A target state of charge (SOC) prediction model refers to a trained model that can predict the SOC of a battery. In this embodiment, the SOC prediction model can use the Transformer model as its basic architecture, including an encoder and a decoder. The encoder is mainly responsible for extracting encoded features, while the decoder is mainly responsible for decoding and restoring features, outputting the predicted value. Discharge time-series features refer to the temporal correlation features contained in historical discharge data. Although the battery exhibits high nonlinearity during discharge, and the SOC cannot be directly observed, it can be indirectly observed through changes in current, voltage, etc., to uncover the characteristics of SOC changes over time. Within a certain historical time period, discharge time-series features can be used to characterize this process.
[0065] For example, the encoder of the target state of charge prediction model includes an input layer and an encoding block. The encoding block contains a multi-head attention mechanism and a feedforward neural network module. Historical discharge data is input into the input layer of the encoder and subjected to dimensionality upscaling. For each attention head in the multi-head attention mechanism, self-attention calculation is performed based on the high-dimensional information after dimensionality upscaling. The outputs of each attention head are concatenated and linearly transformed. The result obtained by the linear transformation is input into the feedforward neural network module to encode the discharge time-series features containing contextual information.
[0066] In one embodiment, historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time-series features of the historical discharge data, including: performing dimensionality upscaling on the historical discharge data through the input layer and multi-attention head in the encoder to extract the high-dimensional time-series information of the historical discharge data; and performing dimensionality reduction on the high-dimensional time-series information through a second feedforward neural network connected to the output end of the multi-attention head to obtain the discharge time-series features of the historical discharge data.
[0067] The input layer is the starting layer of the encoder and can be a linear layer. A multi-attention head refers to a module operating based on a multi-attention mechanism, containing multiple self-attention heads. Dimensionality increase processing refers to the processing operation that increases the data dimension. High-dimensional temporal information refers to temporal-related information with a higher dimension than the original data. The second feedforward neural network refers to the feedforward neural network in the encoder. Dimensionality reduction processing refers to the processing operation that reduces the data dimension. The encoder in this embodiment may contain an input layer and two identical coding blocks. Each coding block contains a multi-head attention structure and a second feedforward neural network. The multi-head attention structure and the second feedforward neural network are connected using residual connections and normalization processing.
[0068] For example, the linear layer of the encoder can upscale the input historical discharge data to 32 dimensions to mine high-dimensional temporal information of the historical discharge data. The linear layer in the multi-head attention structure upscales the high-dimensional temporal information output by the encoder input layer to 64 dimensions to mine the input data from different dimensions. The second feedforward neural network reduces the output of the multi-head attention structure to 32 dimensions to reduce the influence of high-dimensional noise and obtain discharge temporal features.
[0069] Dimensionality upscaling enriches the dimensions of data, allowing for data mining from more diverse perspectives. Subsequent dimensionality reduction can then mitigate the impact of high-dimensional noise introduced by the upscaling process.
[0070] Step 206: Input the discharge timing features and real-time discharge data into the decoder of the target state of charge prediction model, and output the state of charge prediction result of the target battery under the guidance of the real-time discharge data.
[0071] This embodiment improves upon the basic Transformer model. The decoder input includes not only the discharge timing features output by the encoder but also real-time discharge data, which can be further defined as real-time current data. Taking real-time current data as an example, its correlation with battery SOC is high. Directly inputting real-time current data into the decoder can prevent the loss of key features that may occur during the encoding process. Real-time current data can serve as conditional information, combining with the discharge timing features of historical discharge data during the decoder's decoding output to obtain a more accurate SOC estimate.
[0072] For example, real-time discharge data is converted into conditional information. During the decoding process of the decoder for discharge time-series features, the data of each type in the discharge time-series features are weighted according to the conditional information, the confidence ratio of different types of data is adjusted, and the state of charge prediction result of the target battery is output.
[0073] In the aforementioned battery state of charge (SOC) prediction method, discharge sequence data of the target battery is acquired, including real-time discharge data and historical discharge data preceding the real-time discharge data. The historical discharge data is input into the encoder of the target SOC prediction model to extract the discharge time-series features. These features, along with the real-time discharge data, are then input into the decoder of the target SOC prediction model. Guided by the real-time discharge data, the SOC prediction result for the target battery is output. Based on the target SOC prediction model, which includes an encoder and decoder structure, the historical discharge data in the discharge sequence data is encoded and extracted. Event sequence relationships within the historical discharge data are mined to obtain discharge time-series features. Using real-time discharge data as a guiding condition, these features are directly input into the decoder along with the discharge time-series features. This prevents the loss of key features of the real-time discharge data during the encoding process, thereby improving the accuracy of the output SOC prediction result.
[0074] In one exemplary embodiment, such as Figure 3 As shown, the discharge timing features and real-time discharge data are input into the decoder of the target state of charge prediction model. Under the guidance of the real-time discharge data, the target battery's state of charge prediction result is output, including steps 302 to 306.
[0075] Step 302: The real-time discharge data is processed by a decoder to extract time series features and obtain conditional time series features.
[0076] Time series feature extraction refers to the operation of extracting the inherent temporal correlations contained in real-time discharge data in sequence form. Conditional temporal features are features that characterize the temporal correlations within the sequence of real-time discharge data. The decoder may include a decoder input layer and a decoding block. The decoding block contains two multi-head attention structures and a first feedforward neural network, with residual connections and normalization processing between different structures. The decoder structure and parameters are consistent with the encoder, with a linear layer dimension of 32 in the input layer, a linear layer dimension of 64 in the multi-head attention mechanism, and a feedforward neural network dimension of 32.
[0077] Step 304: The conditional timing features and the discharge timing features are fused to obtain the fused timing features.
[0078] The fused temporal features combine the temporal relationships of real-time discharge data represented by conditional temporal features and the temporal relationships of historical discharge data represented by discharge temporal features. In the decoder of the target state of charge prediction model, fused temporal features can be obtained by performing fusion processing through a decoding block connected to the decoder input layer. For example, an embedding layer connected to the output of the input layer is set in the decoder. The conditional temporal features are input into the embedding layer to generate embedding condition information. This embedding condition information is then concatenated into the discharge temporal features to obtain the fused temporal features.
[0079] In one embodiment, the conditional time-series features and discharge time-series features are fused to obtain fused time-series features, including: using the discharge time-series features as query vectors and the conditional time-series features as key-value pairs, performing multi-head attention processing to obtain multiple attention outputs; and performing weighted summation processing on the attention outputs to obtain fused time-series features.
[0080] The decoder's decoding block can include two multi-head attention structures. The first multi-head attention structure is used to uncover the intrinsic relationships between different positions in the conditional time-series features, while the second multi-head attention structure combines the intrinsic relationships between the discharge time-series features and the conditional time-series features. In the first multi-head attention structure, the discharge time-series features are used as the query vector. After processing such as time-series aggregation and global average pooling, their dimensions are fixed. The conditional time-series features are used as key-value pairs, and cross-multi-head attention calculations are performed to obtain the attention outputs of each sub-attention head. The attention weights on the discharge time-series features can be dynamically adjusted according to the real-time current conditions. After weighted summation, the fused time-series features are obtained, realizing condition-guided feature selection. Residual connection or gated fusion strategies can also be used to integrate conditional features with the original context information. Residual fusion can maintain the integrity of the original information, while the gating mechanism balances the contributions of both through learnable weights, achieving adaptive feature weighting.
[0081] The fused temporal features obtained after fusion can focus on multiple temporal relationships, adjust weights under conditional guidance, and capture the state changes of the target battery in a timely manner.
[0082] Step 306: Based on the fused time-series features, output the predicted state of charge of the target battery.
[0083] In the decoder, the output of the multi-head attention structure can be connected to a feedforward neural network. The fused temporal features are input into the feedforward neural network, and nonlinearity is introduced through the activation function. The output is mapped to the predicted state of charge in one-dimensional space.
[0084] In one embodiment, based on the fused timing features, the output of the target battery's state of charge prediction result includes:
[0085] The first feedforward neural network in the decoder performs decoding transformation on the fused time-series features to obtain decoded time-series information; the fully connected layer connected to the output of the first feedforward neural network performs regression processing on the decoded time-series information to output the predicted state of charge of the target battery within a preset time step.
[0086] The first feedforward neural network refers to the feedforward neural network in the decoder. Decoding transformation refers to the operation of restoring the feature information contained in the fused temporal features. Decoded temporal information is information characterizing the temporal relationships contained in the decoded fused temporal features. The length of the preset time step can be set according to actual conditions. The state-of-charge prediction result with the preset time step can be sequence data similar in form to discharge sequence data, containing state-of-charge prediction data within the time window to be predicted.
[0087] By inputting the fused temporal features into the first feedforward neural network, the nonlinear relationship between the discharge sequence data and the State of Charge (SOC) can be fitted. This SOC is then connected to a fully connected layer to obtain a one-dimensional time series SOC estimate. For example, the dimension of the fully connected layer can be 8, meaning it outputs SOC estimates for 8 time steps. The result of the first time step can be taken as the final state of charge prediction result.
[0088] In this embodiment, by setting the model output result to be longer than the evaluation result, information from the past and the future can be considered simultaneously to better explore the contextual relationships between data at different locations in the time series and improve the accuracy of SOC estimation.
[0089] In one exemplary embodiment, such as Figure 4 As shown, the method includes steps S1 to S5.
[0090] S1. Obtain battery discharge data under different operating conditions and construct time-series input samples. Time-series changes in voltage and current during discharge under four different operating conditions of lithium batteries can be obtained from public datasets as one-dimensional time-series input samples, and the samples can be distinguished according to the operating conditions.
[0091] S2. The time-series input samples are split using a sliding window to construct training and test sets. The window length can be set to 1. Time-series data under each operating condition are split separately, using two conditions as the training set and the remaining two as the test set. Data collected under different operating conditions may have distributional differences, causing a model trained on one condition to perform worse on another. Using data from multiple operating conditions for training helps uncover general patterns during battery discharge, and using two additional conditions for validation allows for high-performance diagnostics of the target battery across a wide operating range.
[0092] S3. Construct a Conditional Transformer Model. The Conditional Transformer model may include an encoder and decoder based on an attention mechanism. Historical time-series data is input to the encoder for feature extraction. The encoded result, along with real-time current data, is input to the decoder for further analysis. A fully connected layer is then connected to output a SOC estimate. The attention mechanism encoder may include an encoder input layer and two encoding blocks. Each encoding block contains a multi-head attention mechanism module and a feedforward neural network module. Residual connections and normalization processing are added between the modules. The encoding blocks use the multi-head attention mechanism to mine the correlation between time-series data, achieving long-sequence data mining. The feedforward neural network fits the nonlinear relationship between the input and SOC, extracting a high-dimensional representation of the input data. The decoder includes a decoder input layer and a decoding block. The decoding block contains two multi-head attention mechanism modules and a feedforward neural network module. Residual connections and normalization processing are added between the modules. The first multi-head attention mechanism module in the decoding block is used to explore the intrinsic relationship between different positions of the conditional input sequence. The second multi-head attention mechanism module combines the high-dimensional representation of the data extracted by the encoder with the intrinsic relationship between the conditional input sequences. The input feedforward neural network fits the nonlinear relationship between all inputs and SOC. Finally, the output fully connected layer obtains the estimate of SOC.
[0093] S4. Train the conditional Transformer model using the training set as input. During training, the error is obtained through forward propagation, and the parameters are optimized through backpropagation until the model error converges.
[0094] S5. Input the test set into the trained conditional Transformer model, perform SOC estimation, and evaluate the model's test performance based on the error evaluation index.
[0095] The model error can be expressed using the mean square error (MSE) loss function, and its expression can be found in Formula 1 below.
[0096] Formula 1: .
[0097] in, The mean square error of the estimated value, To assess sample size, For the true value, This is an estimated value.
[0098] Error evaluation metrics can include three: Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Mean Absolute Percentage Error (MAPE), which can be referred to in Formulas 2 to 4 below.
[0099] Formula 2: .
[0100] Formula 3: .
[0101] Formula 4: .
[0102] in, The mean absolute error of the estimated value, The root mean square error of the estimated value, The mean percentage error of the estimated value, To assess sample size, For the true value, This is an estimated value.
[0103] By leveraging the multi-head attention mechanism to mine time-series data, a conditional Transformer model is built to deeply mine and extract features from historical time-series data. Combined with conditional input, an accurate estimate of SOC is obtained, reducing the blindness of feature extraction and improving the accuracy of SOC estimation. The data-driven neural network modeling method effectively reduces the need for battery-related professional knowledge.
[0104] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0105] Based on the same inventive concept, this application also provides a battery state of charge prediction device for implementing the battery state of charge prediction method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more battery state of charge prediction device embodiments provided below can be found in the limitations of the battery state of charge prediction method described above, and will not be repeated here.
[0106] In one exemplary embodiment, such as Figure 5 As shown, a battery state of charge prediction device 500 is provided, including: a sequence data acquisition module 501, an encoded feature extraction module 502, and a prediction result output module 503, wherein:
[0107] The sequence data acquisition module 501 is used to acquire the discharge sequence data of the target battery. The discharge sequence data includes real-time discharge data and historical discharge data prior to the real-time discharge data.
[0108] The encoding feature extraction module 502 is used to input historical discharge data into the encoder of the target state of charge prediction model and extract the discharge time sequence features of the historical discharge data.
[0109] The prediction result output module 503 is used to input the discharge timing characteristics and real-time discharge data into the decoder of the target state of charge prediction model, and output the state of charge prediction result of the target battery under the guidance of the real-time discharge data.
[0110] In an exemplary embodiment, the prediction result output module 503 is further configured to: extract time series features from real-time discharge data using a decoder to obtain conditional time series features; fuse the conditional time series features with the discharge time series features to obtain fused time series features; and output the state of charge prediction result of the target battery based on the fused time series features.
[0111] In an exemplary embodiment, the prediction result output module 503 is further configured to: perform multi-head attention processing using discharge time-series features as query vectors and conditional time-series features as key-value pairs to obtain multiple attention outputs; and perform weighted summation processing on the attention outputs to obtain fused time-series features.
[0112] In an exemplary embodiment, the prediction result output module 503 is further configured to: decode and transform the fused time-series features through the first feedforward neural network in the decoder to obtain decoded time-series information; and perform regression processing on the decoded time-series information through a fully connected layer connected to the output of the first feedforward neural network to output the predicted state of charge of the target battery within a preset time step.
[0113] In an exemplary embodiment, the encoding feature extraction module 502 is further configured to: perform dimensionality upscaling on the historical discharge data through the input layer and multi-attention head in the encoder to extract the high-dimensional time series information of the historical discharge data; and perform dimensionality downscaling on the high-dimensional time series information through a second feedforward neural network connected to the output end of the multi-attention head to obtain the discharge time series features of the historical discharge data.
[0114] In an exemplary embodiment, the sequence data acquisition module 501 is further configured to: determine a data buffer for storing discharge data of the target battery; and acquire discharge sequence data of the target battery from the data buffer through a sliding time window with a preset window length.
[0115] Each module in the aforementioned battery state of charge prediction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0116] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores discharge sequence data of the target battery. The I / O interfaces are used for information exchange between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements a battery state-of-charge prediction method.
[0117] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a battery state-of-charge prediction method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0118] Those skilled in the art will understand that Figure 6 and Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0119] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the method embodiments described above.
[0120] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0121] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the method embodiments described above.
[0122] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0123] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0124] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for predicting the state of charge of a battery, characterized in that, The method includes: Acquire discharge sequence data of the target battery, the discharge sequence data including real-time discharge data and historical discharge data prior to the real-time discharge data; The historical discharge data is input into the encoder of the target state of charge prediction model to extract the discharge time sequence features of the historical discharge data. The discharge timing features and the real-time discharge data are input together into the decoder of the target state of charge prediction model. Guided by the real-time discharge data, the state of charge prediction result of the target battery is output.
2. The method according to claim 1, characterized in that, The step of inputting the discharge timing features and the real-time discharge data into the decoder of the target state of charge prediction model, and outputting the target battery's state of charge prediction result under the guidance of the real-time discharge data, includes: The real-time discharge data is processed by the decoder to extract time-series features and obtain conditional time-series features. The conditional timing features are fused with the discharge timing features to obtain fused timing features; Based on the fused timing features, the predicted state of charge of the target battery is output.
3. The method according to claim 2, characterized in that, The step of fusing the conditional timing features with the discharge timing features to obtain fused timing features includes: Using the discharge timing features as the query vector and the condition timing features as the key-value pairs, multi-head attention processing is performed to obtain multiple attention outputs; The attention output is weighted and summed to obtain the fused temporal features.
4. The method according to claim 2, characterized in that, The step of outputting the state of charge prediction result of the target battery based on the fused time-series features includes: The fused temporal features are decoded and transformed using the first feedforward neural network in the decoder to obtain decoded temporal information; By using a fully connected layer connected to the output of the first feedforward neural network, regression processing is performed on the decoded timing information to output the predicted state of charge of the target battery within a preset time step.
5. The method according to claim 1, characterized in that, The step of inputting the historical discharge data into the encoder of the target state of charge prediction model and extracting the discharge time-series features of the historical discharge data includes: The historical discharge data is upscaled using the input layer and multiple attention heads in the encoder to extract high-dimensional time-series information from the historical discharge data. The high-dimensional time series information is reduced in dimensionality by a second feedforward neural network connected to the output of the multi-attention head, thereby obtaining the discharge time series characteristics of the historical discharge data.
6. The method according to any one of claims 1 to 5, characterized in that, The acquisition of the discharge sequence data of the target battery includes: Determine a data buffer for storing the discharge data of the target battery; The discharge sequence data of the target battery is obtained from the data buffer through a sliding time window with a preset window length.
7. A battery state of charge prediction device, characterized in that, The device includes: A sequence data acquisition module is used to acquire discharge sequence data of a target battery, wherein the discharge sequence data includes real-time discharge data and historical discharge data prior to the real-time discharge data; The encoding feature extraction module is used to input the historical discharge data into the encoder of the target state of charge prediction model and extract the discharge time sequence features of the historical discharge data. The prediction result output module is used to input the discharge timing features and the real-time discharge data into the decoder of the target state of charge prediction model, and output the state of charge prediction result of the target battery under the guidance of the real-time discharge data.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.