A Short-Term Charging Load Forecasting Method for Electric Vehicles Based on an LSTM-GNN Combined Model
By combining the LSTM-GNN combined model with graph neural networks and data preprocessing techniques, the shortcomings of nonlinearity and spatiotemporal relationships in electric vehicle charging load prediction are addressed, enabling accurate prediction of short-term loads at electric vehicle charging stations and improving the model's adaptability and accuracy.
Patent Information
- Application Number
- CN202410185294.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-19
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-02-19
AI Technical Summary
Existing electric vehicle charging load forecasting methods have shortcomings in handling nonlinear and spatiotemporal relationships, making it difficult to accurately extract time-series data features. Furthermore, the models have poor generalization ability and cannot effectively reflect short-term load changes at electric vehicle charging stations.
We employ an LSTM-GNN combined model, adding GraphSAGE and SAGEConv network layers from the graph neural network clustering architecture, and combining temperature and date information to construct a sliding window dataset for feature extraction and prediction. We use mean normalization, one-hot encoding, and normalization to process the data and optimize the network loss function to accelerate convergence.
It improves the accuracy and adaptability of electric vehicle charging load forecasting, enabling more accurate prediction of charging load changes in different regions. By combining meteorological and date information, it enhances the model's expressive power and prediction accuracy.
Smart Images

Figure CN118070841B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electric vehicle charging load prediction technology, and specifically to a method for predicting short-term charging load of electric vehicles based on an LSTM-GNN combined model. Background Technology
[0002] As a crucial mode of transportation in the era of clean energy transition, electric vehicles are experiencing increasing demand, and their charging stations are being widely deployed. However, the integration of new loads into the grid, coupled with the unpredictable nature of electric vehicle user charging behavior, presents significant challenges to short-term forecasting of charging loads at electric vehicle charging stations. Therefore, forecasting electric vehicle charging loads has become a critical task for more effectively managing the power system, improving grid reliability, and optimizing energy utilization.
[0003] Currently, common technologies and methods in the field of electric vehicle charging load forecasting mainly include time series analysis, such as ARIMA models, recurrent neural networks (RNNs), and long short-term memory (LSTM) networks; as well as regression analysis, artificial neural networks, ensemble learning, deep learning, and spatiotemporal relationship modeling. These involve multiple variables and various influencing factors, and new methods still need to be continuously explored and optimized to adapt to the evolving needs of electric vehicle charging infrastructure and power systems.
[0004] Existing load forecasting models and methods include "electric vehicle charging load forecasting method and system based on improved LSTM neural network" and "electric vehicle charging load forecasting based on data-driven methods".
[0005] Chinese Patent: "Electric Vehicle Load Prediction Method and System Based on Improved LSTM Neural Network" (Application No.: CN202310612121.0); its main feature is the use of an algorithm model combining LSTM and traditional neural networks. It uses the BPTT method to train the LSTM neural network model using the training set data. Its main drawbacks can be summarized as difficulty in parameter tuning, feature engineering construction, and sample imbalance. Regarding the difficulty in parameter tuning, this includes issues with the learning rate, hidden layer size, and time step length. This can complicate model optimization, which can be improved by introducing automatic parameter tuning methods. For the feature engineering construction problem, LSTM models typically require carefully designed input features; this can be improved by constructing more in-depth feature engineering or considering more advanced feature extraction techniques. Regarding the sample imbalance problem, in electric vehicle charging load prediction, there may be significant imbalances in charging load across different time periods. This imbalance can be addressed by using an appropriate loss function or considering sampling techniques. Meanwhile, the BPTT method also suffers from long sequence problems, local update problems, sparse gradient problems, and hyperparameter sensitivity problems; this backpropagation algorithm also has significant room for improvement.
[0006] Chinese patent: "Data-driven electric vehicle charging load prediction" (application number: 202310960127.7), its main feature is the establishment of a data-driven electric vehicle charging load prediction model system. At the same time, it completes the decorrelation analysis of the initial evaluation index set through subjective analysis method. Its main drawbacks and shortcomings can be summarized as data quality and missing values, model interpretability, spatiotemporal relationship modeling, and nonlinear relationship modeling. Regarding data quality and missing values, data-driven methods are highly sensitive to the quality and completeness of input data. Missing values, outliers, or inaccurate data can negatively impact prediction performance, leaving room for improvement. As for model interpretability, data-driven methods are often considered black-box models, making their prediction process difficult to explain. In some application scenarios, model interpretability is crucial; improvements can be made by using more interpretable models or introducing interpretive techniques to explain the model's decision-making process. For spatiotemporal relationship modeling problems, electric vehicle charging load is influenced by multiple factors, including time, weather, and user behavior. Better modeling of spatiotemporal relationships is key to improving prediction accuracy. Improvements can include introducing more complex spatiotemporal modeling methods and extracting more spatiotemporal features. For nonlinear relationship modeling problems, charging load prediction often involves complex nonlinear relationships. Improvements can include using more complex model structures, such as deep learning models, to better capture nonlinear patterns.
[0007] Traditional modeling methods, limited by the lack of real-world data, mostly rely on mathematical principles for modeling and simulation to generate data and behavioral simulations that approximate reality. However, such predictions have limitations and are subject to randomness. (References include:)
[0008] Zhao Shuqiang, Zhou Jingren, Li Zhiwei, et al. Electric vehicle charging demand analysis method based on travel chain theory [J]. Electric Power Automation Equipment, 2017, 37(8):105-112;
[0009] Zhang Weige, Jie Feixiang, Huang Mei, et al. Research on short-term load forecasting method for fast-charging bus charging stations [J]. Power System Protection and Control, 2013, 41(4):61-66;
[0010] Deng Yixuan, Huang Yuping, Huang Zhouchun. Prediction of electric vehicle charging and discharging capacity based on random forest algorithm [J]. Automation of Electric Power Systems, 2021, 45(21):181-188;
[0011] Traditional single time series analysis and machine learning methods have shortcomings in analyzing spatiotemporal relationships and complex correlations. The models have poor generalization ability and are limited in handling non-stationarity and data feature extraction, making it impossible to accurately extract effective features from time series data. Summary of the Invention
[0012] To address the aforementioned issues, this invention proposes a short-term electric vehicle charging load prediction method based on an LSTM-GNN combined model. This prediction method can effectively predict the electric vehicle charging load in different typical regions and can be combined with the actual temperature and date variation trends, demonstrating good adaptability.
[0013] The technical solution adopted in this invention is as follows:
[0014] A method for predicting short-term charging load for electric vehicles based on an LSTM-GNN combined model includes the following steps:
[0015] Step 1: Collect charging load data, temperature data, and date data for electric vehicle charging stations, and preprocess them to construct a sliding window dataset;
[0016] Step 2: Improve the LSTM model by adding the GraphSAGE and SAGEConv network layers of the graph neural network clustering architecture to obtain the LSTM-GNN model;
[0017] Step 3: Input the sliding window dataset from Step 1 into the LSTM-GNN model from Step 2, train the model in the LSTM layer and fully connected layer, then construct graph data containing nodes, edges, and weights based on the model parameters, extract features, and output them to the GraphSAGE and SAGEConv network layers of the graph neural network clustering architecture for training; Step 4: Use the validation set as input to input into the trained LSTM-GNN model to predict the charging load of electric vehicles.
[0018] Step 1 includes the following steps:
[0019] Step 1.1: Collect historical charging load data of electric vehicle charging stations, perform average processing, and then distribute the historical charging load data to 24 hours of each day, with a sampling interval of 1 hour.
[0020] The mean-averaging method used is hourly mean-averaging, and the specific steps are as follows:
[0021] Define the time period: Define the time period for which you want to average the hours. This can be a day, a month, a year, or any other time span.
[0022] Calculate the hourly sum: For the charging load values in each hour, calculate their sum.
[0023] To calculate the hourly average, divide the sum of each hour by the number of hours in that time period.
[0024] The purpose of hourly averaging is to capture the average trend of each hour in time series data, making it easier for the model to understand and predict the overall changes in charging load;
[0025] Step 1.2: Collect historical temperature data, whether it is a weekend, and the day of the week for the electric vehicle charging station location. Perform one-hot encoding processing and finally normalize the representation. At the same time, remove some abnormal data points and missing values in the historical data to eliminate the problem of non-standard data affecting the model accuracy.
[0026] One-hot encoding is primarily used to convert categorical variables into binary representations so that machine learning models can better understand and process them. The general steps are as follows:
[0027] 1) Determine the number of categories: Determine how many different categories there are in the categorical variables of the input feature data.
[0028] 2) Assign an index: Assign a unique integer index to each category.
[0029] 3) Create a zero matrix: Create a zero matrix of size (number of samples, number of categories).
[0030] 4) Fill the matrix: For each feature sample, set the index position of the corresponding category to 1, and set the rest to 0.
[0031] Normalization is primarily used to scale numerical variables to a similar range to prevent certain features from having an excessive impact on model training. This invention uses Min-Max normalization, whose main goal is to scale the data to the range of 0-1. The formula is as follows:
[0032]
[0033] Where: X represents the sample data before normalization; X normalized For normalized sample data; X max and X min These are the maximum and minimum values in the sample data before normalization, respectively.
[0034] In step 1, since the prediction method of this invention predicts the charging load of the charging station within one hour, and the historical charging load data exported by the charging station is mainly charging user order data, the Pandas package in Python is used to filter and clean the data. Each row only retains the charging load and charging start and end time information. Specifically, the irrelevant information columns in the CSV file are deleted using the Python language in the Pandas package. Then, the average method is used to split the load of each time into the charging load of 24 hours per day, that is, 24 time periods. Specifically, the hourly average method is used to distribute the daily electric vehicle charging load evenly over the 24 hours of the day.
[0035] In step 1, the original charging load dataset will also contain some null values. Since the charging load data for electric vehicles at charging stations has periodic characteristics, the null values can be filled based on the high consistency of similar day types. The specific method is shown in the following formula, where y k Fill in the missing time points with data; y k-1 The charging load value at the same time on the same date of the previous week; y k+1 This refers to the charging load value at the same time on the same week date in the following week.
[0036]
[0037] To accelerate the convergence of the network loss function and improve model training speed, one-hot encoding is required for date and holiday data, and normalization is needed for historical charging load and temperature data. In step 1, the sliding window dataset is a data processing method used for time series analysis and forecasting. Its basic idea is to extract multiple subsequences from a time series by sliding a fixed-size window, with each subsequence used for model building or analysis. This helps capture short-term patterns and trends in the series. Specifically, the generation process of the sliding window dataset is as follows:
[0038] ①. Select the window size and step size.
[0039] ②. Starting from the beginning of the time series, slide the window at intervals of 1 / 2.
[0040] ③. For each window, extract the observations within the time window to form a subsequence.
[0041] ④. Repeat the above process until you slide to the end of the time series.
[0042] In this invention, the window size is set to 24 hours. The step size is set to 1 hour; the subsequence is an input feature matrix X consisting of temperature, date type, holiday factors, and historical charging load data.
[0043] In step 2, the LSTM-GNN model mainly consists of an LSTM layer, a fully connected layer 1, a graph data generation layer, a SAGEConv layer 1, an ELU activation function layer, a SAGEConv layer 2, and a fully connected layer 2. The overall framework diagram is shown in the attached figure. Figure 1 As shown in the diagram, the graph data generation layer extracts features from the input feature matrix; the ELU activation function layer solves the gradient truncation problem and specifies the graph type; finally, the final prediction result is output through two layers of linear regression in a fully connected layer 2.
[0044] The parameters of the LSTM-GNN network model are set according to the LSTM layer, fully connected layer 1, graph data generation layer, SAGEConv layer 1, ELU activation function layer, SAGEConv layer 2, and fully connected layer 2, as shown in Table 1 below.
[0045] Table 1 LSTM-GNN network model parameters
[0046]
[0047] The `in_feats` parameter refers to the input feature size, which can be one integer or two integers. When used on a one-way bipartite graph, integers can be used to represent the feature sizes of the source and destination nodes respectively. If only one integer is provided, the feature sizes of the source and destination nodes are assumed to be the same. `out_feats` refers to the output feature size.
[0048] The LSTM model in the combined model uses a multi-layer bidirectional LSTM structure with an adjustable number of layers. In the specific example experiment in this paper, the number of layers is set to 1. The LSTM formula is as follows:
[0049]
[0050] Among them, I t For input gate, O t For output gate, F t Forgotten Gate; X i W represents the input sample at the current time. xi H represents the weight matrix of the input samples in the input gate. t-1 W represents short-term memory information from the previous moment. hi b represents the weight matrix of the short-term memory information in the input gate at the previous time step. i W represents the bias vector of the input gate. xo W represents the weight matrix of the input samples in the output gate. ho b represents the weight matrix of the short-term memory information in the output gate at the previous time step. o W represents the bias vector of the output gate. xf W represents the weight matrix of the input samples in the forget gate. hf b represents the weight matrix of short-term memory information from the previous time step in the forgetting gate. f This represents the bias vector of the forget gate.
[0051] In the GraphSAGE layer structure, by Figure 1 As can be seen, the GraphSAGE layer consists of SAGEConv layer 1, the ELU activation function, and SAGEConv layer 2. SAGEConv layer 1 is mainly used to construct the convolutional layers of the GraphSAGE algorithm, using the output of the previous layer as nodes. The overall structure diagram of the GraphSAGE layer is shown below. Figure 1 As shown. The mathematical formula for SAGEConv is as follows:
[0052]
[0053]
[0054]
[0055] in, This represents the feature of the target node N at layer (l+1). Let N(dst) represent the features of the source node at layer l, and N(dst) represent the features of the target node N. This indicates the existence of a source node; W represents the weight matrix; b represents the feature of the target node at layer l; b represents the bias vector. This means concatenating the aggregated features with the target nodes of the l-th layer and the (l+1)-th layer; This represents the feature of the target node at layer l+1.
[0056] The source node features `feat_src` and the target node features `feat_dst` need to be specified according to the graph type; then, it passes through an ELU activation function layer. The ELU activation function is an improved version of the ReLU activation function, which solves the gradient cutoff problem that occurs in the negative region of ReLU. Its formula is as follows:
[0057]
[0058] Where x represents the input value; α represents a number less than zero, usually taken as 1, which is the negative slope of the ELU function when x < 0.
[0059] Step 3 includes the following steps:
[0060] S3.1. Input the sliding window dataset into the LSTM-GNN model, grouping the data into sets of 24. This group consists of historical data from the 24 hours preceding the predicted time, forming the input feature matrix X. The model's input is a vector composed of several 24×10 input feature matrices. The input feature matrix X is composed of temperature, date type, holiday factors, and historical charging load data. The output is the predicted charging load for the next hour. The format of the input feature matrix X is as follows:
[0061] X = [w (m+1)×1 T (m+1)×1 H (m+1)×1 D (m+1)×7 ]
[0062] In the formula: each training sample X is a (m+1)×10 feature matrix; w (m+1)×1 T (m+1)×1 These are column vectors representing historical charging load and historical temperature sequences, respectively; T j and w j (j=1,2,…m+1) are the decimal values of temperature and historical load, respectively, in ℃ and kW, j is the column vector value index; m is the value at that time.
[0063] As shown in the following formula:
[0064]
[0065]
[0066] H (m+1)×1 and D (m+1)×7 One-hot encoded matrices for weekend type and weekday date information, respectively:
[0067] As shown in the following formula:
[0068]
[0069]
[0070] Where: H i It is a 1-digit code, either 0 or 1, where 0 represents a weekday and 1 represents a weekend.
[0071] D j1 D j2 D j3 D j4 D j5 D j6 D j7 The 7-bit binary code is 1000000, 0100000, ..., 0000010 or 0000001. The 7-bit binary code represents Monday to Sunday of the week in sequence. If a bit in the code is 1, it means that the date type is the week type corresponding to that bit. For example, 0000100 means that the date type is Friday. j = 1, 2, ..., m+1.
[0072] S3.2. The standardized sliding window dataset is divided into training, validation, and test sets, with the entire sliding window input dataset divided into training, validation, and test sets in an 8:1:1 ratio. The divided sliding window dataset is then input into the LSTM-GNN model for training, iterating continuously until the residual (LOSS) is minimized to achieve the optimal model training effect.
[0073] S3.3 Next, the feature vectors in the sliding window dataset are input into the adjacency matrix generation layer. By learning the relationship between nodes, the adjacency matrix is output through one or more layers of the neural network.
[0074] S3.4 Input the adjacency matrix from S3.3 into the edge and weight generation layer, combine it with node features and other information to generate a weight matrix, and generate edges based on the adjacency matrix. The implementation method is to analyze the potential dependencies between variables in the construction of the adjacency matrix, that is, to obtain the relationships between the multivariate variables of power load, thereby constructing the adjacency matrix.
[0075] The static adjacency matrix primarily determines whether two points are connected, and the specific formula is as follows:
[0076]
[0077] However, static adjacency matrices require the assumption that the underlying relationships between entities are predetermined, and explicit graph structure relationships cannot reflect true dependencies. Therefore, this invention proposes dynamic adjacency matrices to capture changing dependencies.
[0078] In the combinatorial model, after inputting the feature matrix, the next step is to construct graph data. The graph data generates a layered structure diagram, such as... Figure 10 As shown. Using the results from the previous layer as nodes, and the softmax function operation on the inner product of the node feature matrices as weights, the adjacency matrix is obtained. The formula is as follows:
[0079]
[0080] A typical step involves transforming the full-map feature data into local-map data, as illustrated in Figure 9. Figure 9 As can be seen, the process mainly consists of three steps: the first step is to select node 'a' in layer B2; the second step is to sample three neighboring nodes 'cfj' in layer B1; and the third step is to sample six neighboring nodes 'dehilk' in layer B0. Ultimately, the local graph data allows for better analysis and prediction in the next stage.
[0081] S3.5. Input the adjacency matrix processed in S3.4 into SAGEConv layer 1. SAGEConv layer 1 is used to construct the convolution of the GraphSage algorithm, thus receiving seven parameters. It is mainly combined with the data processing method of the graph data layer. The received seven feature matrix input parameters are passed through the graph data layer and the ELU function activation layer, as follows: Figure 10 As shown;
[0082] S3.6. The final processed matrix is then input into the spatiotemporal convolution module to capture the space. The results of the multi-layer spatiotemporal convolution are aggregated and input into the output module, which maps the result to the required dimension. SAGEConv layer 2 uses two linear regression layers. Two linear regression layers are commonly used to build deep learning models, where the model contains two linear regression layers. Such models can be used to learn complex nonlinear relationships. In deep learning frameworks (such as TensorFlow or PyTorch), this invention mainly implements the two linear regression layers using PyTorch. First, the ReLU activation function is used to perform nonlinear processing on the output of the first layer. Then, the result is passed to the second layer, and the input dimension, the number of hidden layer neurons, and the output dimension are adjusted according to actual needs. The formula implemented in the code is as follows:
[0083] x′ i =W1x i +W2·Aggregate j∈N(i) x j ;
[0084] Further learning can be carried out on these basic patterns to generate richer and more complex nodes; the ELU activation function and two SAGEConv layers introduce nonlinearity to handle nonlinear information in the data;
[0085] S3.7. Using the GraphSAGE embedding generation (forward propagation) algorithm, the features corresponding to neighbors are aggregated, a dimensionality transformation is performed, and then the node's own dimensionality-transformed features are added to obtain the final node embedding. The flowchart is as follows: Figure 8 As shown. The main method uses Paper formulas, as shown below:
[0086] x′ i =W·concat(Aggreggate) j∈N(i) x j ,x i )
[0087] Where: point j is a neighbor of point i. After aggregating the features of the neighbors in some way, they are combined with the node's own features by concat and then subjected to a dimensional transformation. Aggregation methods include mean, pooling, LSTM, etc.
[0088] In step 4, the model data trained in step 3 is output to the fully connected layer, and the root mean square error loss function is constructed to obtain the predicted value of the electric vehicle charging load.
[0089] In step 4, specifically, the processed features are input into the fully connected layer 2 through the SAGEConv layer 2, which has a similar structure to SAGEConv layer 1, and the final result is output. The output process is as follows: Figure 11 As shown.
[0090] Step 5: To comprehensively evaluate the model's performance, the prediction effectiveness of the LSTM-GNN model is judged using four evaluation metrics: Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R-squared (R2 score). The formulas for these metrics are as follows:
[0091]
[0092]
[0093]
[0094]
[0095] Among them, w k The actual charging load data at time k; w^ k The charging load data at time k predicted by the LSTM-CNN model; q represents the average value of the actual charging load data; q represents the number of data points in the test dataset.
[0096] This invention provides a method for predicting short-term charging load of electric vehicles based on an LSTM-GNN combined model. The technical effects are as follows: 1) Based on the LSTM-GNN combined model, this invention can effectively predict the charging load of electric vehicles by inputting a feature matrix composed of processed historical load data of electric vehicle charging stations, local temperature data, and date information data, and after training the network model, it can reflect the changes in the charging load of fixed charging stations in the short term, and can also effectively analyze the data by combining meteorological information and date information.
[0097] 2) This invention improves upon the traditional LSTM model by adding the GraphSAGE graph neural network clustering architecture and the corresponding SAGEConv network layer, which better aggregates and analyzes time series features, avoiding the shortcomings of traditional models in terms of insufficient accuracy in processing nonlinear feature information, and improving prediction accuracy.
[0098] 3) This invention optimizes the feature space aggregation method through the SAGE method, adds a dimensional transformation, and adds the features of the nodes themselves after dimensional transformation, which are then projected onto different feature spaces. This greatly enhances the expressive power of the model.
[0099] 4) By comparing the method before and after the improvement with other typical algorithms, the method of the present invention can more accurately predict the charging load of electric vehicle charging stations in three different functional areas within a certain period of time, and draw conclusions with higher accuracy by statistically analyzing various error evaluation indicators. Attached Figure Description
[0100] Figure 1 This is a flowchart of the load forecasting process for the LSTM-GNN combined model.
[0101] Figure 2 This figure compares the short-term charging load prediction results of electric vehicles based on the LSTM-GNN combined model with the prediction results of several other traditional models for charging stations in a typical area.
[0102] Figure 3 This chart compares the error evaluation indices of the short-term charging load prediction results of electric vehicles based on the LSTM-GNN combined model with the error evaluation indices of several other traditional models in a typical region.
[0103] Figure 4 This is a schematic diagram of the LSTM-GNN combined model structure.
[0104] Figure 5 This is a typical region of the original dataset, showing the original charging load map.
[0105] Figure 6(a) is a visualization of GraphSAGE examples and aggregation methods. Figure 1 (Sample and neighbors);
[0106] Figure 6(b) is a visualization of the GraphSAGE example and aggregation method. Figure 2 (Acquiring aggregation feature information from neighbors); Figure 6(c) is a visualization of the GraphSAGE example and aggregation method. Figure 2 (Use aggregated information to predict context and labels).
[0107] Figure 7 This is a flowchart of the graph neural network training process.
[0108] Figure 8 This is a diagram illustrating the feature clustering relationship between nodes in the Paper formula.
[0109] Figure 9 This is a schematic diagram illustrating the transformation of full-map data into partial-map data.
[0110] Figure 10 This diagram illustrates how the seven feature matrix input parameters received by SAGEConv layer 1 pass through the graph data layer and the ELU function activation layer.
[0111] Figure 11 This is a schematic diagram of the output process for step 4. Detailed Implementation
[0112] This paper proposes a method for predicting short-term charging load of electric vehicles based on an LSTM-GNN combined model. The model leverages the strong feature aggregation capabilities of Graph Neural Networks (GNNs) to effectively analyze and predict short-term charging load of electric vehicles. The method first processes and analyzes the original load dataset of electric vehicle charging stations, reconstructing the dataset by incorporating temperature and date information. Then, it combines Long Short-Term Memory (LSTM) and GNN networks to extract and analyze features from the input feature matrix for training. Specifically, a SAGEConv layer is used to construct the convolution of the GraphSage algorithm, receiving seven parameters, and an ELU activation function layer is introduced. Two layers of linear regression are also used to allow for deeper learning based on these basic patterns, generating richer and more complex nodes to further improve the accuracy of time-series prediction. Furthermore, to accelerate the convergence of the network loss function, this invention performs one-hot encoding on date and holiday data and normalizes historical load and temperature data, significantly improving the overall training speed and stability of the model. Final experimental results show that this method can accurately predict the short-term charging load of electric vehicles.
[0113] A method for predicting short-term charging load for electric vehicles based on an LSTM-GNN combined model includes the following steps:
[0114] Step 1: Collect charging load data of electric vehicle charging stations, perform data preprocessing, and form a sliding window dataset with t=24;
[0115] Step 2: Input the standardized sliding window dataset from Step 1 into the LSTM-GNN model and train the model in the LSTM layer and fully connected layer.
[0116] Step 3: Construct graph data containing nodes, edges, and weights from the model parameters trained in Step 2, extract features, and output them to the GraphSAGE (graph neural network) aggregation framework and SAGEConv layer for training.
[0117] Step 4: Output the model data trained in Step 2 to the fully connected layer and construct the root mean square error loss function to obtain the predicted value of electric vehicle charging load.
[0118] The schematic diagram of the LSTM-GNN combined model is as follows: Figure 4 As shown.
[0119] In step one, the historical charging load of electric vehicle charging stations is collected, averaged, and distributed across 24 hours of each day, with a sampling interval of 1 hour. Simultaneously, historical temperature information and date information (whether it's a weekend or what day of the week) for the charging station's location are collected and one-hot encoded, then normalized. Outlier data points and missing values are removed from the historical data to eliminate the impact of non-standard data on model accuracy. The process of processing and standardizing data is characterized by the following steps:
[0120] S1.1 Since the proposed prediction method forecasts the charging load of a charging station within an hour, and the historical charging data exported by the charging station is mainly charging user order data, the Pandas package in Python is used to filter and clean the data, keeping only the charging load and charging start and end time information for each row. Then, the mean method is used to break down the load of each time into the charging load of 24 hours per day, i.e., 24 time periods.
[0121] S1.2 In addition, the original charging load dataset will also contain some null values. However, the charging load data of electric vehicles at charging stations has periodic characteristics. Therefore, null values can be filled based on the high consistency of similar date types. The formula is as follows:
[0122]
[0123] In the formula: y k Data to fill in missing moments; y k-1 The charging load value at the same time on the same date of the previous week; y k+1 This represents the charging load value for the same date and time of the following week. Local temperature data is processed using the same method.
[0124] S1.3 Simultaneously, to accelerate the convergence of the network loss function and improve model training speed, it is necessary to perform one-hot encoding on date and holiday data, and normalize historical load and temperature data, as shown in the following formula:
[0125]
[0126] In the formula: x represents the sample data before normalization; x one The value is the normalized value; x max and x min These are the maximum and minimum values in the sample data before normalization, respectively.
[0127] The original charging load map of a typical region in the dataset is as follows: Figure 5 As shown, by Figure 5 It can be seen that the charging load variation characteristics of university areas, one of the typical electric vehicle usage scenarios, are mainly reflected in relatively regular fluctuations. The reason for this is the influence of factors such as holidays and weather. The regular variation of this load can well represent the common phenomenon of this type of scenario. Therefore, it is of great significance to predict the charging load of electric vehicles in this typical area.
[0128] Step two includes the following steps:
[0129] Step 2.1: Input the processed sliding window dataset into the LSTM-GNN model, grouping data into sets of 24. This means using historical data from the 24 hours preceding the predicted time to construct the input feature matrix for predicting the charging load for the next hour. The model input can consist of an input vector composed of several 24×10 input feature matrices. The input feature matrix X is constructed from temperature, date type, holiday factors, and historical charging load data. The output is the predicted load for the next hour. The format of the input feature matrix X is as follows:
[0130] X = [w (m+1)×1 T (m+1)×1 H (m+1)×1 D (m+1)×7 ]
[0131] In the formula: each training sample X is a (m+1)×10 matrix; w (m+1)×1 and T (m++1)×1 These are column vectors representing historical charging load and historical temperature sequences, respectively, T j and w j (j=1,2,…m+1) are the decimal values of temperature and historical load, respectively, in ℃ and kW, as shown in the following formula:
[0132]
[0133]
[0134] H (m+1)×1 and D (m+1)×7 These are one-hot encoding matrices for weekend type and weekday date information, respectively, where: H i The code is 0 or 1, where 0 represents a weekday and 1 represents a weekend; D j1 D j2 D j3 D j4 D j5 D j6 D j7(j = 1, 2, ..., m+1) is a 7-bit binary code: 1000000, 0100000, ..., 0000010, or 0000001. These 7 bits sequentially represent Monday through Sunday of the week. A bit in the code being 1 indicates that the current day's date is the corresponding week's date. For example, 0000100 represents Friday, as shown in the following formula:
[0135]
[0136]
[0137] Step 2.2: Divide the standardized data into training, validation, and test sets. The entire input dataset is divided into training, validation, and test sets in an 8:1:1 ratio. Input the dataset into the LSTM-GNN model for training. Iterate continuously until the residual (LOSS) is minimized to achieve the optimal model training effect.
[0138] Step 2.3: Next, the data is input into the adjacency matrix generation layer. By learning the relationships between nodes, the adjacency matrix is output through one or more layers of the neural network.
[0139] Step 2.4: Input the adjacency matrix from the previous step into the edge and weight generation layer, combine it with node features and other information to generate a weight matrix, and generate edges based on the adjacency matrix;
[0140] Step 2.5: Input the processed matrix into SAGEConv layer 1. SAGEConv is used to construct the convolution of the GraphSage algorithm to receive seven parameters, and then input it into the ELU activation function layer.
[0141] Step 2.6: The final input is fed into SAGEConv layer 2, which uses two layers of linear regression. This allows for deeper learning based on these basic patterns to generate richer and more complex nodes. The ELU activation function and the two SAGEConv layers introduce non-linearity to handle non-linear information in the data.
[0142] Step 2.7: After aggregating the features corresponding to the neighbors using the GraphSAGE embedding generation (forward propagation) algorithm, perform a dimensional transformation, and add the node's own dimensional transformation features to obtain the final generated embedding of the node.
[0143] The LSTM-GNN model mentioned above, which is the LSTM model that incorporates a graph neural network, has the following characteristics:
[0144] 1) Its main feature lies in its application of the GraphSAGE inductive framework, which leverages node feature information, such as text attributes, to effectively generate node embeddings for previously unseen data. Through learning a function, it generates embeddings by sampling and aggregating features from the local neighborhood of a node, rather than training separate embeddings for each node. Its visualization is shown below. Figures 6(a) to 6(c) As shown. By Figures 6(a) to 6(c) The main operational flow of the GraphSAGE inductive framework can be summarized in three steps: ① Sampling the neighboring vertices of each vertex in the graph; ② Aggregating the information contained in the neighboring vertices using an aggregation function; ③ Obtaining the vector representation of each vertex for downstream tasks. For computational efficiency, a certain number of neighboring vertices are sampled for each vertex as the vertices to be aggregated. Let the sampling number be k. If the number of vertex neighbors is less than k, sampling with replacement is used until k vertices are sampled. If the number of vertex neighbors is greater than k, sampling without replacement is used.
[0145] 2) By fusing a GraphSAGE embedding generation (forward propagation) algorithm, assuming that the parameters of k aggregation functions that aggregate information from node neighbors have already been learned, along with a set of weight matrices used to propagate information between different layers or "search depths" of the model, parameter training is then performed. The graph neural network training process is as follows: Figure 7 As shown. Where: Forward calculates the state forward, Backward calculates the gradient backward, and the main function calls forward and backward iterations to achieve the call to minimize the loss.
[0146] 3) Selection of aggregate functions:
[0147] Since the neighbors of vertices in Figure 6(a) are naturally unordered, we hope that the constructed aggregation function is symmetric, that is, the output of the function remains unchanged when the order of the input is changed, while having high expressive power.
[0148] MEAN aggregator:
[0149] Instead of using vector representations of neighboring vertices, the mean aggregator directly generates the vector representation of the target vertex. It concatenates the (k-1)th-level vectors of the target vertex and its neighboring vertices, then averages each dimension of the vectors, performing a non-linear transformation on the result to generate the k-th-level representation vector of the target vertex.
[0150] Pooling aggregator:
[0151] The pooling aggregator first performs a nonlinear transformation on the neighboring vertex representation vectors of the target vertex, then performs a pooling operation (maxpooling or meanpooling), concatenates the result with the target vertex representation vector, and finally performs another nonlinear transformation to obtain the k-th layer representation vector of the target vertex.
[0152] LSTM aggregator:
[0153] LSTM has a stronger expressive power than a simple averaging operation. However, since the LSTM function is not symmetric about the input, a shuffling operation is required to sort the neighbors of the vertex when using it.
[0154] 4) After defining the aggregation function, unsupervised learning is used to learn the parameters. The graph-based loss function aims to ensure that neighboring vertices have similar vector representations, while making the representations of separated vertices as distinguishable as possible. The objective function is as follows:
[0155]
[0156] Where: v is a vertex that appears near u through a random walk of fixed length, P n This represents the probability distribution of negative samples, where Q is the number of negative samples. Unlike DeepWalk, the vertex representation vector here is generated by aggregating the features of the vertex's neighboring points, rather than by simply performing an embedding lookup operation.
[0157] 5) Simultaneously, the `paper` function of GraphSAGE is used for analysis and application. Nodes are sampled in the feature vector graph, and the representation of nodes is learned through neighbor aggregation to better analyze the information and characteristics of the input feature matrix. The specific implementation is as follows:
[0158] x′ i =W*concat(Aggregate) j∈N(i) x j x i )
[0159] Where: point j is a neighbor of point i. Intuitively, after aggregating the features of neighbors in some way, concatenate them with the node's own features, and then perform a dimensionality transformation. Aggregation methods include mean, pooling, and LSTM.
[0160] Furthermore, the paper's formulas were modified and optimized to allow for implementation in software using code, as shown below:
[0161] x′ i =W1xi +W2*Aggregate j∈N(i) x j
[0162] This is how PyTorch geometric is implemented. The `concat` operator has disappeared from the code; `W1` and `W2` have replaced `W`.
[0163] Figure 8 It can display the visual relationship between the two, by Figure 8 This demonstrates the logic and structure of the Paper formula, primarily including the node update rule and graph convolution operation. Node updates in GNNs typically involve aggregating information about the node's neighbors, and the graph convolution operation can be defined using the adjacency matrix W. Compared to GCN, node iii and its neighbor j jj use different adjacency matrix representations and are projected onto different feature spaces, which greatly enhances the model's expressive power.
[0164] The significance of the SAGE module is to aggregate the features corresponding to neighbors, perform a dimensionality transformation, and then add the node's own dimensionality-transformed features to generate the final node embedding. Compared to traditional GCN, node i and neighbor j use different feature dimensions and are projected into different feature spaces, which greatly enhances the model's expressive power. `mean` is the default neighbor aggregation method in the code, but it can be changed to `max`, `add`, or other methods. The Pooling-based LSTM aggregation method in the original paper is not implemented in SAGEConv. In the SAGEConv code, the neighbors are simply the neighbors you input, regardless of whether they are neighbors sampled using methods like NeighborSampler or all unsampled neighbors. It only receives the input neighbors; the sampling work is done in the next step.
[0165] For each node, samples are taken from its neighboring nodes. This is to capture the node's local neighborhood information. The features of the sampled neighboring nodes are aggregated into a fixed-size neighborhood representation. This aggregation can be achieved through operations such as averaging, concatenation, or learning via a neural network. Finally, the node's own features are combined with the aggregated neighborhood representation to update the node's final representation. In this way, the GraphSAGE module enables each node's representation to include information from its local neighborhood, thus better capturing the features in the dataset. This sampling and aggregation strategy makes GraphSAGE scalable for handling large datasets because it does not need to consider information from the entire dataset but learns by sampling subgraphs. This method has achieved good results in tasks such as node classification, graph classification, and link prediction by training the final prediction surface.
[0166] Step three includes the following steps:
[0167] Step 3.1: Use the validation set from Step 2.2 as input to the trained LSTM-GNN model to predict the charging load of electric vehicles. The final prediction result is as follows: Figure 2 As shown. By Figure 2 It can be seen that the dataset in the university area has a large sample size and low daily load fluctuation uniformity. For the load scenario where a large number of electric vehicles are charging at the same time, all models can capture the pattern of load change. However, in the time area with high load, the prediction performance of each model varies greatly. Among them, the prediction results of LTSM-CNN, CNN-LSTM and LSTM have poor fit with the actual load curve and high MAPE values. The prediction results of LSTM-GNN, GNN and SVM models fit the real power load curve better. However, the MAPE value of SVM has exceeded 4%, while the MAPE values of LSTM-GNN and GNN are both within 3%. Moreover, the R2 score of LSTM-GNN has reached 0.8, and the explanatory power of the model has reached 80%, which is the best fit.
[0168] Step 3.2: To comprehensively evaluate the model's performance, four evaluation metrics are used: Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R-squared (R2 score). The final error evaluation metric results are as follows: Figure 3 As shown. By Figure 3It can be seen that compared with the models CNN-LSTM, LSTM-CMM, LSTM, GNN, and SVM, the LSTM-GNN model's prediction results show that the MSE decreased by 7.8743, 26.0504, 21.9786, 0.0612, and 15.8403MW respectively; the RMSE decreased by 0.7107, 4.4555, 1.8053, 0.0575, and 1.3515MW respectively; the MAE decreased by 0.4238, 3.3671, 1.2764, 0.0665, and 1.035MW respectively; the MAPE decreased by 0.0576, 1.8308, 0.0386, 0.8736, and 0.6651% respectively; and the R2 score increased by 0.0584, 0.4894, 0.1629, 0.0966, and 0.1174 respectively. This demonstrates that for the prediction of charging stations in university areas, which have the largest sample size, the longest and most even date distribution, the LSTM-GNN model proposed in this patent can still achieve relatively ideal prediction results within a data span of nearly one year, even with significant temperature differences in California where the charging stations are located.
[0169] The formula for determining this is as follows:
[0170]
[0171]
[0172]
[0173]
[0174] Among them, w k The actual charging load data at time k; w^ k The charging load data at time k predicted by the LSTM-CNN model; q represents the average value of the actual charging load data; q represents the number of data points in the test dataset.
[0175] The intended effect of this invention is to reasonably process and analyze historical datasets based on temperature and temporal factors of actual regional electric vehicle charging stations, and ultimately achieve accurate prediction of short-term charging load for electric vehicles through model training output results. The advantage of this invention over other inventions and traditional models lies in its use of Graph Neural Networks (GNNs) and the GraphSAGE aggregation framework to better aggregate features from matrix-based time-series data, laying the foundation for subsequent analysis and in-depth learning. Finally, through practical examples, it predicts the short-term charging load of electric vehicle charging stations in three different functional areas within a certain period. Furthermore, comparison of the numerical results of four statistically outputted error evaluation indicators shows that the model method used in this invention has a significant improvement in prediction accuracy compared to other models.
Claims
1. A method for predicting short-term charging load of electric vehicles based on an LSTM-GNN combined model, characterized in that... Includes the following steps: Step 1: Collect charging load data, temperature data, and date data for electric vehicle charging stations, and preprocess them to construct a sliding window dataset; Step 2: Improve the LSTM model by adding the GraphSAGE and SAGEConv network layers of the graph neural network clustering architecture to obtain the LSTM-GNN model; Step 3: Input the sliding window dataset from Step 1 into the LSTM-GNN model from Step 2, train the model in the LSTM layer and the fully connected layer, and then construct graph data containing nodes, edges and weights according to the model parameters. After feature extraction, output the data to the GraphSAGE and SAGEConv network layers of the graph neural network clustering architecture for training. Step 4: Use the validation set as input to feed into the trained LSTM-GNN model to predict the charging load of electric vehicles; In step 2, the LSTM-GNN model is specifically composed of an LSTM layer, a fully connected layer 1, a graph data generation layer, a SAGEConv layer 1, an ELU activation function layer, a SAGEConv layer 2, and a fully connected layer 2. The LSTM model is constructed using a multi-layer bidirectional LSTM structure, with the number of layers adjustable. The LSTM formula is as follows: ; in, For input gate, For output gate, Forgotten Gate; This represents the input sample at the current time. This represents the weight matrix of the input samples in the input gate. This represents short-term memory information from the previous moment. This represents the weight matrix of the short-term memory information from the previous time step in the input gate. This represents the bias vector of the input gate. This represents the weight matrix of the input samples in the output gate. This represents the weight matrix of the short-term memory information from the previous time step in the output gate. This represents the bias vector of the output gate. This represents the weight matrix of the input samples in the forget gate. This represents the weight matrix of short-term memory information from the previous time step in the forgetting gate. The bias vector representing the forget gate; In the GraphSAGE layer structure, the GraphSAGE layer consists of SAGEConv layer 1, the ELU activation function, and SAGEConv layer 2. SAGEConv layer 1 is used to construct the convolutional layer of the GraphSAGE algorithm, and uses the output of the previous layer as nodes. The mathematical formula for SAGEConv is as follows: ; ; ; in, This represents the feature of the target node N at layer (l+1). This represents the characteristics of the source node at layer l. Represents the target node N, This indicates that a source node exists; Represents the weight matrix; This represents the feature of the target node at layer l; Represents the bias vector; This means concatenating the aggregated features with the target nodes of the l-th layer and the (l+1)-th layer; This represents the feature of the target node at layer l+1; The source node features `feat_src` and the target node features `feat_dst` need to be specified according to the graph type; then, it passes through the ELU activation function layer. The ELU activation function is an improved version of the ReLU activation function, and its formula is as follows: ; in, Indicates the input value; It represents a number less than zero.
2. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that: Step 1 includes the following steps: Step 1.1: Collect historical charging load data of electric vehicle charging stations, perform average processing, and then distribute the historical charging load data to 24 hours per day, with a sampling interval of 1 hour; Step 1.2: Collect historical temperature and date data for the location of electric vehicle charging stations, perform one-hot encoding, and finally normalize the representation. Simultaneously, remove outlier data points and missing values from the historical data. Normalization refers to using the Min-Max normalization method, which aims to scale the data to the range of 0-1. The formula is as follows: ; in: The sample data is before normalization; The data is the normalized sample data; and These are the maximum and minimum values in the sample data before normalization, respectively.
3. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that: In step 1, the historical charging load data exported by the charging station includes charging user order data. The Pandas package in Python is used to filter and clean the data, keeping only the charging load and charging start and end time information for each row. Then, the mean method is used to split each load into 24 hours of charging load per day.
4. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 3, characterized in that: In step 1, the original charging load dataset will still contain null values. Since the charging load data for electric vehicles at charging stations has periodic characteristics, null values can be filled based on the high consistency of similar day types, as shown in the following formula: Fill in the missing time points with data; The charging load value at the same time on the same week date of the previous week; The charging load value at the same time on the same date of the following week; ; Meanwhile, in order to accelerate the convergence of the network loss function and improve the model training speed, it is necessary to perform one-hot encoding on date and holiday data, and normalize historical charging load and temperature data.
5. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that: In step 1, the process of generating the sliding window dataset is as follows: ①. Select the window size and step size; ②. Starting from the beginning of the time series, slide the window at intervals of a certain step size; ③. For each window, extract the observations within the time window to form a subsequence; ④. Repeat the above process until you slide to the end of the time series; The window size is set to 24 hours; the step size is set to 1 hour; and the subsequence is an input feature matrix consisting of temperature, date type, holiday factors, and historical charging load data. X .
6. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that: Step 3 includes the following steps: S3.1 Input the sliding window dataset into the LSTM-GNN model, grouping the data into sets of 24, i.e., the historical data from the 24 hours prior to the time to be predicted, to form the input feature matrix. X It performs charging load prediction for the next hour; the output is the predicted charging load for the next hour, and the input is the feature matrix. X The format is as follows: ; Where: each training sample X for( m The eigenma matrix of order +1)×10; , These are column vectors representing historical charging load and historical temperature sequences, respectively. and These are the decimal values of temperature and historical load, respectively; j is the column vector value index, j=1,2,…m+1; m is the time value. As shown in the following formula: ; ; and One-hot encoded matrices for weekend type and weekday date information, respectively: As shown in the following formula: ; ; In the formula: It is a 1-digit code, either 0 or 1, where 0 represents a weekday and 1 represents a weekend. It consists of 7 binary codes: 1000000, 0100000, ..., 0000010, or 0000001. These 7 binary codes sequentially represent Monday through Sunday in the weekday calendar. If a bit in the code is 1, it means that the date is the weekday corresponding to that bit. S3.2 Divide the standardized sliding window dataset into training set, validation set and test set. The entire sliding window input dataset is divided into training set, validation set and test set in a ratio of 8:1:
1. The partitioned sliding window dataset is then input into the LSTM-GNN model for training. The training is iterated continuously until the residual is minimized, in order to achieve the optimal model training effect. S3.3 Next, the feature vectors in the sliding window dataset are input into the adjacency matrix generation layer. By learning the relationship between nodes, the adjacency matrix is output through one or more layers of the neural network. S3.4 Input the adjacency matrix from S3.3 into the edge and weight generation layer, combine it with node feature information to generate a weight matrix, and generate edges based on the adjacency matrix; S3.
5. Input the adjacency matrix processed in S3.4 into SAGEConv layer 1. SAGEConv layer 1 is used to construct the convolution of the GraphSage algorithm, so as to receive seven parameters. The seven received feature matrices are input parameters through the graph data layer and the ELU function activation layer. S3.
6. The final processed matrix is then input into the spatiotemporal convolution module to capture the space. The results of the multi-layer spatiotemporal convolution are aggregated and input into the output module, which maps the result to the required dimension. The SAGEConv layer 2 implements two linear regression layers using PyTorch. First, the ReLU activation function is used to perform non-linear processing on the output of the first layer. Then, the result is passed to the second layer, and the input dimension, the number of hidden layer neurons, and the output dimension are adjusted according to actual needs. The formula implemented in the code is as follows: ; S3.
7. Using the GraphSAGE embedding generation algorithm, the features corresponding to the neighbors are aggregated, a dimensionality transformation is performed, and then the node's own dimensionality-transformed features are added to obtain the final node embedding. The Paper formula is used, as shown below: ; Where: point j is a neighbor of point i. After aggregating the features of the neighbors in a certain way, they are combined with the node's own features by concat and then subjected to a dimensional transformation.
7. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that: In step 4, the model data trained in step 3 is output to the fully connected layer, and the root mean square error loss function is constructed to obtain the predicted value of the electric vehicle charging load.
8. The method for predicting short-term charging load of electric vehicles based on the LSTM-GNN combined model according to claim 1, characterized in that, The process also includes step 5: evaluating the prediction performance of the LSTM-GNN model using four metrics: Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R² score. The evaluation formula is as follows: ; ; ; ; in, for k Real-time charging load data; Predicted by LSTM-CNN model k Real-time charging load data; This represents the average value of the actual charging load data. q The number of data points in the test dataset.
Citation Information
Patent Citations
Electric vehicle charging load prediction method and system based on improved LSTM neural network
CN116881708A
Electric vehicle charging load prediction based on data driving
CN116992313A
