In recent years, the rapid growth of electric vehicles has fundamentally transformed the automotive landscape, driving global efforts toward sustainable energy solutions. At the heart of this revolution lies the lithium-ion battery, a critical power source renowned for its high energy density, long cycle life, and low self-discharge rate. Accurate prediction of the State of Charge (SOC) in lithium-ion batteries is paramount for battery management systems, as it provides real-time insights into remaining driving range, optimizes charge-discharge strategies, enhances battery longevity, and ensures operational safety. However, SOC cannot be measured directly; it must be inferred from measurable parameters such as voltage, current, and temperature, posing significant challenges due to the nonlinear, dynamic, and multi-frequency characteristics of battery data. Traditional methods, including coulomb counting and open-circuit voltage approaches, often suffer from noise sensitivity and environmental dependencies, while model-based techniques rely heavily on precise electrochemical modeling, which can be complex and computationally intensive. Data-driven approaches, particularly deep learning models, have emerged as powerful alternatives by learning complex mappings from data without explicit physical models. Yet, many existing neural networks struggle to capture multi-scale frequency information in time-series data, leading to issues like temporal drift and reduced robustness under varying conditions. To address these limitations, we propose an advanced hybrid model that integrates frequency-domain analysis, sequence-to-sequence learning with attention mechanisms, and genetic algorithm optimization for superior SOC prediction in lithium-ion batteries.

The core innovation of our approach lies in the synergistic combination of a Frequency-Domain Features Extractor (FDFE), a Sequence-to-Sequence (Seq2Seq) network enhanced with attention mechanisms, and a Genetic Algorithm (GA) for hyperparameter tuning. Lithium-ion battery signals, such as voltage and current, exhibit rich periodic and multi-frequency components that are often obscured in time-domain analysis. By leveraging frequency-domain transformations, we can uncover hidden patterns and improve feature representation. The FDFE employs the Discrete Cosine Transform (DCT) to convert voltage and current subsequences from the time domain to the frequency domain. For a given subsequence \(x = [x_0, x_1, \dots, x_{m-1}]\) of length \(m\), the DCT is computed as:
$$y_j = \sum_{i=0}^{m-1} x_i \cdot \cos\left[\frac{\pi}{m}\left(i + \frac{1}{2}\right) j\right]$$
where \(y_j\) represents the \(j\)-th frequency component. This transformation effectively decorrelates the signal, making frequency components independent and reducing redundancy. The extracted frequency features are then normalized using ReLU and Sigmoid activation functions, resulting in a refined feature set \(X’_f\). These frequency-domain features are concatenated with time-domain features \(X_t\) (e.g., voltage, current, temperature) to form a comprehensive input feature vector \(X = \text{Concat}(X’_f, X_t)\). This hybrid representation enriches the model’s ability to capture both temporal and spectral dynamics, which is crucial for accurate SOC estimation in lithium-ion batteries under diverse operating conditions.
To process the sequential nature of battery data, we employ a Seq2Seq architecture built with Long Short-Term Memory (LSTM) networks. LSTM units address the vanishing gradient problem in traditional RNNs and are well-suited for modeling long-term dependencies. The encoder LSTM processes the input feature sequence \(X\) and generates a hidden state sequence \(X’ = [h_0, h_1, \dots, h_{m-1}]\). The internal computations of an LSTM cell at time step \(t\) are defined by the following equations:
$$f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f)$$
$$i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i)$$
$$\tilde{C}_t = \tanh(W_C \cdot [h_{t-1}, x_t] + b_C)$$
$$C_t = f_t \odot C_{t-1} + i_t \odot \tilde{C}_t$$
$$o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o)$$
$$h_t = o_t \odot \tanh(C_t)$$
where \(f_t\), \(i_t\), and \(o_t\) are the forget, input, and output gates, respectively; \(C_t\) is the cell state; \(h_t\) is the hidden state; \(\sigma\) denotes the sigmoid function; \(\odot\) represents element-wise multiplication; and \(W\) and \(b\) are learnable weights and biases. The encoder’s output states serve as input to a multi-head attention layer, which dynamically assigns weights to different time steps, focusing on the most relevant information for SOC prediction. For each attention head \(i\), the query \(Q_i\), key \(K_i\), and value \(V_i\) are derived from \(X’\) using linear transformations:
$$Q_i = X’ \cdot W^Q_i, \quad K_i = X’ \cdot W^K_i, \quad V_i = X’ \cdot W^V_i$$
The attention output for head \(i\) is computed as:
$$\text{Attent}_i(Q_i, K_i, V_i) = \text{softmax}\left(\frac{Q_i \cdot K_i^T}{\sqrt{d_k}}\right) \cdot V_i$$
where \(d_k\) is the dimensionality of the key vectors. The outputs from all heads are concatenated and linearly transformed to produce the attention-weighted sequence \(X’_A\):
$$X’_A = \text{MultiHead}(Q, K, V) = \text{Concat}(\text{Attent}_1, \text{Attent}_2, \dots, \text{Attent}_h) \cdot W^O$$
This attention mechanism enhances the model’s ability to capture long-range dependencies and prioritize critical features in the lithium-ion battery data. The decoder LSTM then takes \(X’_A\) along with previous hidden and cell states to generate the final hidden state \(h’_m\), which is passed through a fully connected layer to predict the SOC value:
$$\text{SOC}_m = \text{FC}(h’_m)$$
To optimize the model’s hyperparameters, such as the number of LSTM neurons, attention key dimensions, and learning rate, we utilize a Genetic Algorithm (GA). GA is a population-based optimization technique inspired by natural selection, which efficiently explores the hyperparameter space to find configurations that maximize prediction accuracy. The algorithm initializes a random population, evaluates each individual’s fitness (e.g., based on validation loss), and iteratively applies selection, crossover, and mutation operations to evolve better solutions. For crossover, we use a two-point crossover strategy: given two parent individuals \(P_1 = [p_{11}, p_{12}, \dots, p_{1k}]\) and \(P_2 = [p_{21}, p_{22}, \dots, p_{2k}]\), two crossover points \(\alpha\) and \(\beta\) are randomly selected, and gene segments between them are swapped to produce offspring. Mutation is introduced via Gaussian mutation:
$$O_{\text{Mutated}} = O_{\text{Original}} + \mathcal{N}(0, \sigma^2)$$
where \(\mathcal{N}(0, \sigma^2)\) is a normally distributed random variable. This process continues for a predefined number of generations, ensuring that the GA-FDFE-Seq2Seq model is tailored for robust SOC prediction across varying conditions.
For experimental validation, we employed a publicly available dataset comprising lithium-ion battery cycling tests under multiple environmental temperatures (ranging from -20°C to 40°C) and diverse driving cycles, including urban, highway, and mixed profiles. The dataset records voltage, current, temperature, discharge capacity, and energy at intervals of 0.1 seconds during discharge processes. We preprocessed the data using min-max normalization to scale features to the range [0, 1], and applied a sliding window technique with a window length of 64 time steps and a stride of 1 to generate sequential samples. The model was trained on a subset of driving cycles and evaluated on separate test sets to assess generalization. Performance was measured using three key metrics: Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and the Coefficient of Determination (R²), defined as:
$$\text{MAE} = \frac{1}{n} \sum_{i=1}^{n} |\text{SOC}_i – \hat{\text{SOC}}_i|$$
$$\text{RMSE} = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (\text{SOC}_i – \hat{\text{SOC}}_i)^2}$$
$$R^2 = 1 – \frac{\sum_{i=1}^{n} (\text{SOC}_i – \hat{\text{SOC}}_i)^2}{\sum_{i=1}^{n} \left(\text{SOC}_i – \frac{1}{n} \sum_{j=1}^{n} \text{SOC}_j\right)^2}$$
where \(\hat{\text{SOC}}_i\) is the predicted SOC, \(\text{SOC}_i\) is the true SOC, and \(n\) is the total number of samples. The model was implemented using TensorFlow and Keras, optimized with the Adam optimizer, and trained with early stopping to prevent overfitting.
The GA-FDFE-Seq2Seq model demonstrated exceptional prediction accuracy across all tested conditions. Below, we summarize the results in a comprehensive table that compares the model’s performance under different temperatures and driving cycles. The table highlights the consistency and reliability of our approach in estimating SOC for lithium-ion batteries.
| Driving Cycle | Metric | 40°C | 25°C | 10°C | 0°C | -10°C | -20°C | Average |
|---|---|---|---|---|---|---|---|---|
| Highway Cycle | MAE (%) | 0.099 | — | 0.072 | 0.149 | 0.148 | 0.094 | 0.112 |
| RMSE (%) | 0.123 | — | 0.084 | 0.174 | 0.164 | 0.105 | 0.130 | |
| R² (%) | 99.997 | — | 99.998 | 99.995 | 99.994 | 99.996 | 99.996 | |
| Urban Cycle | MAE (%) | 0.050 | 0.086 | 0.243 | 0.096 | 0.092 | 0.071 | 0.106 |
| RMSE (%) | 0.092 | 0.106 | 0.270 | 0.106 | 0.118 | 0.088 | 0.130 | |
| R² (%) | 99.998 | 99.998 | 99.987 | 99.998 | 99.997 | 99.997 | 99.996 | |
| Mixed Cycle 1 | MAE (%) | 0.046 | 0.078 | 0.052 | 0.127 | 0.071 | 0.055 | 0.072 |
| RMSE (%) | 0.065 | 0.098 | 0.063 | 0.146 | 0.095 | 0.069 | 0.089 | |
| R² (%) | 99.999 | 99.998 | 99.999 | 99.996 | 99.997 | 99.998 | 99.998 | |
| Aggressive Cycle | MAE (%) | 0.068 | 0.096 | 0.084 | 0.079 | 0.186 | 0.113 | 0.104 |
| RMSE (%) | 0.087 | 0.120 | 0.103 | 0.094 | 0.209 | 0.125 | 0.123 | |
| R² (%) | 99.998 | 99.998 | 99.998 | 99.998 | 99.991 | 99.994 | 99.996 |
Overall, the GA-FDFE-Seq2Seq model achieved an average MAE of 0.099%, RMSE of 0.118%, and R² of 99.997% across all scenarios, underscoring its high precision and robustness. Notably, the model maintained excellent performance even at extreme temperatures (e.g., -20°C), where lithium-ion battery dynamics become highly nonlinear and challenging to predict. The integration of frequency-domain features allowed the model to capture periodic patterns that are often missed by time-domain-only approaches, while the attention mechanism enabled focused learning on critical time steps. Furthermore, the genetic algorithm optimized hyperparameters effectively, contributing to the model’s adaptability and superior results compared to baseline methods.
To contextualize our findings, we compared the GA-FDFE-Seq2Seq model against several state-of-the-art deep learning models for SOC prediction in lithium-ion batteries, including CNN-LSTM, EMD-LSTM-Attention, PSO-LSTM, and PSO-TCN-Attention. All models were evaluated under identical conditions to ensure a fair comparison. The results, summarized in the table below, demonstrate the clear advantages of our proposed approach in terms of accuracy and error reduction.
| Model | Metric | 40°C | 25°C | 10°C | 0°C | -10°C | -20°C | Average |
|---|---|---|---|---|---|---|---|---|
| CNN-LSTM | MAE (%) | 0.772 | 0.252 | 0.782 | 0.417 | 0.776 | 0.346 | 0.558 |
| RMSE (%) | 0.859 | 0.305 | 0.886 | 0.545 | 0.918 | 0.407 | 0.653 | |
| R² (%) | 99.887 | 99.985 | 99.871 | 99.947 | 99.827 | 99.936 | 99.909 | |
| EMD-LSTM-Attention | MAE (%) | 0.290 | 0.530 | 0.419 | 0.492 | 0.867 | 1.302 | 0.650 |
| RMSE (%) | 0.424 | 0.872 | 0.539 | 0.626 | 1.213 | 1.570 | 0.874 | |
| R² (%) | 99.967 | 99.880 | 99.940 | 99.930 | 99.643 | 98.795 | 99.693 | |
| PSO-LSTM | MAE (%) | 0.118 | 0.133 | 0.238 | 0.283 | 0.144 | 0.351 | 0.211 |
| RMSE (%) | 0.147 | 0.149 | 0.268 | 0.306 | 0.177 | 0.386 | 0.239 | |
| R² (%) | 99.996 | 99.996 | 99.983 | 99.983 | 99.993 | 99.946 | 99.982 | |
| PSO-TCN-Attention | MAE (%) | 0.581 | 1.038 | 0.665 | 0.705 | 0.799 | 0.666 | 0.742 |
| RMSE (%) | 0.727 | 1.253 | 0.910 | 0.816 | 1.062 | 0.836 | 0.934 | |
| R² (%) | 99.918 | 99.772 | 99.851 | 99.887 | 99.766 | 99.751 | 99.824 | |
| GA-FDFE-Seq2Seq | MAE (%) | 0.066 | 0.087 | 0.113 | 0.113 | 0.124 | 0.083 | 0.098 |
| RMSE (%) | 0.092 | 0.108 | 0.130 | 0.130 | 0.147 | 0.097 | 0.117 | |
| R² (%) | 99.998 | 99.998 | 99.996 | 99.997 | 99.995 | 99.996 | 99.997 |
The comparative analysis reveals that our GA-FDFE-Seq2Seq model consistently outperforms all baseline models across temperature ranges. For instance, at 40°C, the average MAE of our model is 0.066%, which represents a 44.1% improvement over the best baseline (PSO-LSTM) and a 91.5% improvement over the weakest (CNN-LSTM). Similarly, at 0°C, the MAE of 0.113% is 60.1% lower than that of PSO-LSTM and 84% lower than PSO-TCN-Attention. These gains underscore the effectiveness of incorporating frequency-domain features and attention mechanisms, which collectively enhance the model’s capacity to handle the complex, non-stationary behavior of lithium-ion batteries. Moreover, the genetic algorithm plays a crucial role in fine-tuning hyperparameters, ensuring optimal performance without manual intervention. The high R² values (consistently above 99.99%) indicate an excellent fit between predicted and true SOC, reinforcing the model’s reliability for real-world applications in electric vehicles and energy storage systems.
In conclusion, we have developed a novel GA-FDFE-Seq2Seq model for accurate and robust State of Charge prediction in lithium-ion batteries. By integrating frequency-domain feature extraction via DCT, sequence-to-sequence learning with attention mechanisms, and genetic algorithm-based hyperparameter optimization, the model captures both temporal and spectral dynamics of battery data, leading to superior prediction accuracy under diverse operating conditions. Experimental results demonstrate that our approach achieves errors below 0.1% on average and outperforms existing deep learning models, making it a promising solution for advanced battery management systems. Future work may explore the integration of additional sensor data, adaptation to battery aging effects, and deployment in real-time embedded platforms to further enhance the practicality of lithium-ion battery SOC estimation for sustainable energy applications.
