GCN-Transform model-based space-time load prediction method for electric vehicle battery replacement station under different couplings
Through the spatial and temporal load prediction method of electric vehicle battery replacement station under different couplings based on the GCN-Transformer model, the problem of difficulty in capturing complex spatial and temporal dependencies in the prior art is solved, and a more accurate load prediction effect is achieved.
Patent Information
- Application Number
- CN202411576179.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art is difficult to accurately predict the spatiotemporal load of electric vehicle battery replacement stations under different couplings, especially when the load is affected by multiple unpredictable factors, there are challenges in capturing complex spatiotemporal dependencies and differentiated coupling relationships.
The space-time load prediction method of electric vehicle battery replacement station under different couplings based on the GCN-Transformer model is adopted. By integrating spatial and temporal characteristics, the complex space-time dependence relationship between the power exchange stations is extracted to enhance the accuracy of load prediction. Specific steps include obtaining load data, building a GCN-Transformer model, performing training and prediction.
The spatial features and the Transformer model are extracted through multi-layer GCN and the temporal features are extracted and fusion is carried out, which improves the accuracy of load prediction, can effectively capture the complex space-time dependence relationship between battery swap stations, and enhances the generalization ability of the model.
Smart Images

Figure CN119476605A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of load prediction methods for electric vehicle battery replacement stations, and relates to a spatiotemporal load prediction method for electric vehicle battery replacement stations under different couplings based on a GCN-Transformer model. Background Art
[0002] Electric vehicles (EVs) have been successful in urban transportation and logistics due to their reduced carbon emissions and lower operating costs. Governments around the world are encouraging the transformation of urban freight transportation from traditional diesel vehicles to electric vehicles. However, the disorderly integration of large-scale EVs has led to high volatility and randomness in regional power grid loads, which has brought potential risks to the power grid system and created new challenges for load forecasting tasks. Accurately predicting the load of EV stations is not only the basis for studying the task of grid load planning, but also a prerequisite for guiding EV charging, which is crucial to promote the planning of charging facilities.
[0003] At present, the methods for EV station load forecasting can be mainly divided into two categories: statistical learning-based and machine learning (ML)-based methods. Statistical learning methods usually involve modeling and analyzing the historical data of EV station charging using statistical analysis techniques to predict future charging loads. For example, a EV charging load forecasting model was established based on factors such as vehicle type, charging duration, daily mileage, start charging time, charging mode, and initial charging state, achieving high accuracy. A scalable EV station demand model was established using the Monte Carlo simulation method by analyzing user driving patterns. A probabilistic travel model of a typical user was constructed based on statistics such as user charging preferences, charging power, and charging location. Although these methods are easy to understand and implement, they are usually limited by data quality and sample size, which makes it challenging to ensure the accuracy of load forecasting. Traditional statistical methods rely heavily on the quality and completeness of historical data. If historical data is missing, erroneous, or the sample size is insufficient, the prediction accuracy of these methods will drop significantly. In addition, these methods usually assume that the data follows certain statistical laws, which makes it difficult to capture nonlinear patterns and complex interactions in the load data of electric vehicle (EV) battery swap stations, especially when the load is affected by multiple unpredictable factors. As new data continue to emerge, these methods need to be regularly remodeled and recalibrated, a process that is often time-consuming and labor-intensive.
[0004] With the rapid development of artificial intelligence (AI) technology, ML methods are increasingly applied to charging load prediction tasks, especially in various fields related to electric vehicles. For example: a charging load spatiotemporal prediction method based on an extended causal convolutional 2D neural network effectively captures the spatiotemporal distribution of charging loads by inputting the load of each battery swap station in the form of a heat map, mainly exploring the spatiotemporal coupling relationship between the loads of multiple battery swap stations with geographical proximity, and achieving good prediction results for multiple battery swap stations. However, in real-world scenarios, multiple public battery swap stations may have differentiated coupling relationships, which may include battery swap stations with similar charging modes but no geographical proximity. Although the spatiotemporal coupling relationship between charging loads is considered, due to the limitation of sequentially inputting Euclidean space data, the model fails to learn the differentiated spatiotemporal coupling relationship between the current charging load and specific multiple charging loads, resulting in inaccurate prediction of the spatiotemporal distribution of charging loads; another example: a load spatiotemporal prediction method based on GCN (graph convolutional neural network), in which all nodes share a set of GCN parameters, effectively improving the accuracy of load spatiotemporal prediction. However, the charging load of public battery swap stations is significantly affected by the user's electricity consumption behavior. The power consumption pattern of each node is different. If the same GCN model parameters are used for each node, there will be a problem of being unable to characterize the differentiated power consumption pattern of each node, which affects the effect of load spatiotemporal prediction. Summary of the invention
[0005] The purpose of the present invention is to provide a spatiotemporal load forecasting method for electric vehicle battery swap stations under different couplings based on the GCN-Transformer model. By integrating spatial and temporal features, the complex spatiotemporal dependencies between battery swap stations can be captured, thereby enhancing the accuracy of load forecasting.
[0006] The technical solution adopted by the present invention is a method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model, which is specifically implemented in the following steps:
[0007] Step 1, obtain the load data of n battery swap stations within k hours, the load data includes the battery swap load data at different time points, the meteorological data of the day at the time point, and the regional location data of the corresponding battery swap station, pre-process the battery swap load data, and divide the pre-processed data into a training set and a validation set;
[0008] Step 2, obtaining the adjacency matrix A between n battery swap stations;
[0009] Step 3: Build a GCN-Transformer model with multi-head attention mechanism and sparse attention mechanism;
[0010] Step 4, using the data in the training set to train the model constructed in step 4;
[0011] Step 5: Use the trained model to predict the spatiotemporal load of the electric vehicle battery swap station under different couplings.
[0012] The present invention is also characterized in that
[0013] The specific preprocessing of load data in step 1 is as follows:
[0014] Step 1.1, clean the battery swap load data, specifically: process missing data and abnormal data, use the average value of the previous day at that time point to fill the missing data, and remove abnormal fluctuation data;
[0015] Step 1.2: Normalize the cleaned data.
[0016]
[0017] Among them, x is the corresponding battery replacement load data after cleaning, x * is the corresponding battery swap load data after normalization, x min is the minimum value of the corresponding battery replacement load data after cleaning, x max It is the maximum value of the corresponding battery replacement load data after cleaning;
[0018] Step 1.3, using a low-pass filter to filter the normalized battery swap load data for noise;
[0019] Step 1.4, the load data processed in step 1.3 is matched with the meteorological data of the day according to the 24-hour period, specifically:
[0020] Meteorological data consists of cloud coverage, rainfall, humidity, air pressure, and temperature data. The battery swap load data processed in step 1.3 is classified according to the type of meteorological data, and then the battery swap load data corresponding to the same type of meteorological data are arranged in descending order according to the rank correlation coefficient value. The Spearman rank correlation coefficient calculation formula is as follows:
[0021]
[0022] Where l is the number of load data values for each time period, d i represents the difference between the position of the ith load data value and the selected meteorological data, d iThe calculation method of is as follows: first, collect the battery swap load data and corresponding meteorological data of each time period; second, sort the i-th value of the battery swap load data and meteorological data of each time period respectively, assign a rank to each data point, and finally, for each time period, calculate the difference between the rank of the battery swap load data and the rank of the meteorological data to obtain d i ; The Spearman rank correlation coefficient of the calculated related factors was used to screen and retain the top four factors. For each time period, a meteorological data segment with a dimension of 3 was obtained. The meteorological data dimension obtained by sampling at all stations was (n, k, 3), where k was the total number of time steps for all sampled data;
[0023] Step 1.5, the data segment exchange load data processed in step 1.4 is segmented by sliding window, and a 1h sliding window is set to segment the EEG signals in the data. The standby channel selects the total load of the exchange station, and samples at 1 sample point per hour for n exchange stations to obtain a data segment with a dimension of (n, k, 1);
[0024] Step 1.6, merging the meteorological data obtained in step 1.4 into the data segment obtained in step 1.5 to obtain a data segment with a dimension of (n, k, 4), where k is the total time steps of all sampled data;
[0025] Step 1.7, divide the formed data segments into training set and validation set according to the proportion.
[0026] Step 2 is as follows:
[0027] Step 2.1, according to the regional location data of the corresponding battery swap station, the geographical location of the battery swap station is mapped to the map, and the element values of the neighbor matrix are judged based on the shortest driving routes between different battery swap stations in the map to form an L matrix with a dimension of (n, n), where each element in the L matrix is denoted as l ij , l ij represents the shortest driving route from the i-th battery swap station to the j-th battery swap station, i = 1, 2, 3, ..., n, j = 1, 2, 3, ..., n;
[0028] Step 2.2, take the matrix A, element a in A ij Determined by the size of the elements in the L matrix, when l ij If it is greater than or equal to 15, take a ij is 0, otherwise it is 1, and we get the A matrix:
[0029]
[0030] That is, the adjacency matrix A between each battery swap station.
[0031] The GCN-Transformer model with multi-head attention mechanism and sparse attention mechanism in step 3 includes a graph convolutional network module and a Transformer module connected in sequence. The outputs of the graph convolutional network module and the Transformer module are jointly connected to the spatiotemporal feature fusion layer, and the output of the spatiotemporal feature fusion layer is connected to the fully connected layer.
[0032] The graph convolution network module includes three layers of graph convolution networks connected in sequence. The adjacency matrix A obtained in step 2 and the training data in the training set obtained in step 1 are input into the graph convolution network module together, wherein 0 in the matrix A represents that power station i and battery swap station j do not have a graph structure connection relationship, and 1 represents that power station i and battery swap station j have a graph structure connection relationship;
[0033] The first layer of graph convolutional network extracts the direct adjacency of each station, that is, the first-order neighbor matrix features, and the output dimension is (x, n, 64), where 64 is the output feature dimension of the first layer, n is the number of battery swap stations, and x is the batch size;
[0034] The second-layer graph convolutional network further extracts the second-order adjacency matrix of the site, and the output dimension is (x, n, 32), where 32 is the output feature dimension of the second-layer graph convolutional network;
[0035] The third layer of graph convolutional network continues to extract site features and outputs features with a dimension of (x,n,16).
[0036] The output of the graph convolutional network module is transformed into a shape transformation operation, and the output shape of the graph convolutional network module is converted into (n, x, 16); that is, the batch size of the input of the Transformer module is converted from the batch size x of the graph convolutional network module to n, that is, the total number of battery swap stations, that is, the input data dimension of the Transformer module is (n, x, 16);
[0037] The Transformer module consists of a self-attention mechanism layer, a multi-head attention mechanism layer, a linear transformation layer, a residual connection, and a layer normalization.
[0038] The input of the self-attention mechanism layer is the output of the graph convolutional network module. The self-attention mechanism layer maps the input features into three matrices: Q, K, and V;
[0039] Among them, the Q matrix is generated as follows:
[0040] Through the weight matrix W Q , W Q The size of is 16×16, and the input matrix is mapped to the query matrix. The calculation formula is as follows:
[0041] Q=X·WQ (4)
[0042] X represents the input data feature. The dimension of the input data is (n, x, 16). After matrix multiplication, the dimension of the generated Q matrix is (n, x, 16), which means that each battery swap station generates a 16-dimensional query feature. Next, the Q matrix is split into 4 heads. The dimension of each head is (n, x, 4), that is, each head is responsible for processing 4-dimensional features.
[0043] The K matrix is generated as follows:
[0044] Using the weight matrix W K , W K The size is 16×16, and the input features are mapped to a key matrix. The calculation formula is as follows:
[0045] K=X·W K (5)
[0046] X represents the input data feature. The dimension of the input data is also (n, x, 16). The dimension of the generated K matrix is (n, x, 16). The K matrix is also split into 4 heads, and the dimension of each head is (n, x, 4).
[0047] The V matrix is generated as follows:
[0048] Using the weight matrix W V , W V The size is (16×16) and the input features are mapped to a value matrix. The calculation formula is as follows:
[0049] V=X·W V (6)
[0050] The generated Value matrix has a dimension of (n,x,16) and is split into 4 sub-matrices, each with a head dimension of (n,x,4);
[0051] The number of heads in the multi-head attention mechanism layer is h = 4, and the query vector dimension of each head is d k =16 / 4=4;
[0052] For each attention head in the multi-head attention mechanism layer, the dot product between the Q and K matrices is calculated, and then the result is scaled and the Softmax function is applied to get the attention weight, which is calculated as follows:
[0053]
[0054] After calculation, the attention weight matrix is multiplied by the V matrix to obtain the output of each attention head. The output dimension of each head is (n,x,16);
[0055] Then the outputs of all attention heads are connected to form a complete output matrix. After concatenating the output dimensions of the four heads, each with a dimension of (n, x, 4), the output of the final multi-head attention mechanism layer is obtained with a dimension of (n, x, 16).
[0056] The output of the multi-head attention mechanism layer is then linearly transformed to restore the dimension of the original input, and then processed by residual connection and layer normalization to obtain the final output of the Transformer module. The dimension of the output feature is (n, x, 16).
[0057] The spatiotemporal feature fusion layer organically integrates the spatial features extracted from the graph convolutional network module with the temporal features extracted from the Transformer module. The spatiotemporal feature fusion layer includes a spatiotemporal feature connection layer and a multi-layer perceptron.
[0058] The spatiotemporal feature connection layer inputs the feature matrix output by the graph convolutional network module into the Transformer module. After modeling dependencies of different degrees, the output feature dimension is (n, x, 16). The multilayer perceptron projects the concatenated feature matrix into a feature space of dimension 16 through a fully connected layer, and then passes through the ReLU activation function and normalization layer to finally obtain the spatiotemporal fusion feature matrix with a dimension of (n, x, 16).
[0059] The input of the fully connected layer comes from the output feature matrix of the spatiotemporal feature fusion layer. The fully connected layer includes three fully connected neurons. Each neuron is connected to all elements of the input feature vector and linearly transformed through weighted and biased terms, and then nonlinearly processed through activation functions. Specifically:
[0060] In the first fully connected layer, the input features are first linearly transformed, that is, multiplied by the weight matrix and the input matrix, and the bias term is added. Assuming that the dimension of the weight matrix W of the fully connected layer is (16,8), the input 16-dimensional features are compressed into 8-dimensional features. The calculation formula of the linear transformation is as follows:
[0061] Z=X′W+b(8)
[0062] Where: X′ is the output feature matrix of the input spatiotemporal feature fusion layer, with a dimension of (n, x, 16); W is the weight matrix of the fully connected layer, with a dimension of (16, 8), indicating that the 16-dimensional feature is mapped to the 8-dimensional space; b is the bias term of the fully connected layer, with a dimension of 8, indicating that each output dimension has a bias; Z is the output matrix after the fully connected layer, with a dimension of (n, x, 8), indicating that the features of each battery swap station are represented in 8 dimensions after the fully connected layer;
[0063] After the linear transformation, nonlinearity is introduced by introducing the ReLU activation function. The formula is as follows:
[0064] ReLU(x)=max(0,x)(9)
[0065] The output dimension after the ReLU activation function remains unchanged, which is (n,x,8);
[0066] By analogy, in the second fully connected layer: input dimension (n,x,8), output dimension (n,x,4), the third fully connected layer: input dimension (n,x,4), output dimension (n,x,1);
[0067] That is, after passing the fully connected layer, the final output matrix dimension is (n, x, 1), where n is the batch size, i.e., the samples of 46 stations, x is the time step, i.e., x battery swap load data are used as input, and 1 is the load prediction value, which indicates the load prediction result of each battery swap station at the current time step.
[0068] Step 3 The training process is as follows:
[0069] The data in the training set is input into the graph convolutional network module to extract spatial features, and then the temporal features are extracted through the Transformer module. The spatial and temporal features are fused through the spatiotemporal feature fusion layer, and the predicted value of the battery swap load of each battery swap station is output through the fully connected layer.
[0070] During training, the difference between the predicted value and the true value is calculated through the loss function mean square error MSE, the error is back-propagated and the model parameters are updated. The formula of MSE is as follows:
[0071]
[0072] Where: y i is the actual load value, is the load value predicted by the model, and N is the number of samples;
[0073] The Adam optimizer is used to update the parameters. The initial learning rate is set to 0.001, the batch size x is 128, and the maximum number of iterations is 1500. To prevent the model from overfitting, the training is stopped early when the loss on the validation set no longer decreases.
[0074] According to the performance of the model on the validation set, the model's hyperparameters are dynamically adjusted, including the learning rate, batch size, the number of graph convolutional network layers in the graph convolutional network module, and the number of Transformer heads.
[0075] The beneficial effects of the present invention are as follows: the present invention extracts spatial features between nodes through multi-layer GCN, and gradually deepens the expression of spatial dependencies. The spatial features extracted by each layer of GCN are used to represent the mutual influence between battery swap stations. After the spatial features are extracted, these features are input into the Transformer model, and the multi-head self-attention mechanism is used to process the long-distance dependencies in the time series. Each attention head works in parallel to process the load changes at different time steps to capture richer time features. In the spatiotemporal feature fusion layer, the spatial features from GCN and the temporal features of the Transformer model are organically fused to form a high-dimensional spatiotemporal feature representation. This fusion representation integrates the geographic spatial relationship between battery swap stations and the load change trend over time, enhances the accuracy of load prediction, reduces the dimensionality of the spatiotemporal features through a multi-layer fully connected network, and finally outputs the load prediction results of each battery swap station in the future time period. During the training process, the mean square error (MSE) is used as the loss function, combined with the Adam optimization algorithm, the learning rate is dynamically adjusted, and an early stopping mechanism is introduced to avoid overfitting, ensuring that the model performs optimally on the validation set. Therefore, the present invention can effectively improve the accuracy (precision) of load prediction of electric vehicle battery swap stations by comprehensively considering the spatial location of the battery swap station and the changes in load over time. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 is a meteorological factor and load correlation analysis diagram obtained by calculating the Spearman rank correlation coefficient in Example 6 of the present invention;
[0077] Figure 2 is a schematic diagram of the site location on a map in Example 6 of the present invention;
[0078] Figure 3 It is a polymerization pattern diagram of the multi-layer GCN layer used in the present invention;
[0079] Figure 4 It is the overall framework diagram of the Transformer model with multi-head sparse attention mechanism in the present invention;
[0080] Figure 5 is a flow chart of a method for calculating attention weight in the present invention;
[0081] Figure 6 It is a schematic diagram of the multi-head attention mechanism added to the Transformer module in the model structure of the present invention;
[0082] Figure 7 It is a curve chart of the predicted data and the actual data in Example 6. DETAILED DESCRIPTION
[0083] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0084] Example 1
[0085] The spatiotemporal load forecasting method of the electric vehicle battery replacement station under different couplings based on the GCN-Transformer model of the present invention is specifically implemented according to the following steps:
[0086] Step 1, obtain the load data of n battery swap stations within k hours, the load data includes the battery swap load data at different time points, the meteorological data of the day at the time point, and the regional location data of the corresponding battery swap station, pre-process the battery swap load data, and divide the pre-processed data into a training set and a validation set;
[0087] Step 2, obtaining the adjacency matrix A between n battery swap stations;
[0088] Step 3: Build a GCN-Transformer model with multi-head attention mechanism and sparse attention mechanism;
[0089] Step 4, using the data in the training set to train the model constructed in step 4;
[0090] Step 5: Use the trained model to predict the spatiotemporal load of the electric vehicle battery swap station under different couplings.
[0091] Example 2
[0092] Based on Example 1,
[0093] The specific preprocessing of load data in step 1 is as follows:
[0094] Step 1.1, clean the battery swap load data, specifically: process missing data and abnormal data, use the average value of the previous day at that time point to fill the missing data, and remove abnormal fluctuation data;
[0095] Step 1.2: Normalize the cleaned data.
[0096]
[0097] Among them, x is the corresponding battery replacement load data after cleaning, x * is the corresponding battery swap load data after normalization, x min is the minimum value of the corresponding battery replacement load data after cleaning, x max It is the maximum value of the corresponding battery replacement load data after cleaning;
[0098] Step 1.3, using a low-pass filter to filter the normalized battery swap load data for noise;
[0099] Step 1.4, the load data processed in step 1.3 is matched with the meteorological data of the day according to the 24-hour period, specifically:
[0100] Meteorological data consists of cloud coverage, rainfall, humidity, air pressure, and temperature data. The battery swap load data processed in step 1.3 is classified according to the type of meteorological data, and then the battery swap load data corresponding to the same type of meteorological data are arranged in descending order according to the rank correlation coefficient value. The Spearman rank correlation coefficient calculation formula is as follows:
[0101]
[0102] Where l is the number of load data values for each time period, d i represents the difference between the position of the ith load data value and the selected meteorological data, d i The calculation method of is as follows: First, collect the battery swap load data and corresponding meteorological data for each time period. Secondly, sort the i-th value of the battery swap load data and meteorological data for each time period, assign a rank to each data point, and finally, for each time period, calculate the difference between the rank of the battery swap load data and the rank of the meteorological data to obtain d i ; The Spearman rank correlation coefficient of the calculated related factors was used to screen and retain the top four factors. For each time period, a meteorological data segment with a dimension of 3 was obtained. The meteorological data dimension obtained by sampling at all stations was (n, k, 3), where k was the total number of time steps for all sampled data;
[0103] Step 1.5, the data segment exchange load data processed in step 1.4 is segmented by sliding window, and a 1h sliding window is set to segment the EEG signals in the data. The standby channel selects the total load of the exchange station, and samples at 1 sample point per hour for n exchange stations to obtain a data segment with a dimension of (n, k, 1);
[0104] Step 1.6, merging the meteorological data obtained in step 1.4 into the data segment obtained in step 1.5 to obtain a data segment with a dimension of (n, k, 4), where k is the total time steps of all sampled data;
[0105] Step 1.7, divide the formed data segments into training set and validation set according to the proportion.
[0106] The present invention collects historical load data, environmental data (such as temperature, air pressure, humidity and rainfall) and geographical location information of electric vehicle battery swap stations, performs data cleaning, normalization and noise filtering, and then divides the data into fixed time windows to ensure that the model can capture spatiotemporal dependencies.
[0107] Example 3
[0108] Based on Example 2, step 2 is specifically as follows:
[0109] Step 2.1, according to the regional location data of the corresponding battery swap station, the geographical location of the battery swap station is mapped to the map, and the element values of the neighbor matrix are judged based on the shortest driving routes between different battery swap stations in the map to form an L matrix with a dimension of (n, n), where each element in the L matrix is denoted as l ij , l ij represents the shortest driving route from the i-th battery swap station to the j-th battery swap station, i = 1, 2, 3, ..., n, j = 1, 2, 3, ..., n;
[0110] Step 2.2, take the matrix A, element a in A ij Determined by the size of the elements in the L matrix, when l ij If it is greater than or equal to 15, take a ij is 0, otherwise it is 1, and we get the A matrix:
[0111]
[0112] That is, the adjacency matrix A between each battery swap station.
[0113] Example 4
[0114] Based on Example 3, the GCN-Transformer model containing multi-head attention mechanism and sparse attention mechanism in step 3 includes a graph convolutional network module and a Transformer module connected in sequence, the outputs of the graph convolutional network module and the Transformer module are jointly connected to the spatiotemporal feature fusion layer, and the output of the spatiotemporal feature fusion layer is connected to the fully connected layer.
[0115] The graph convolution network module includes three layers of graph convolution networks connected in sequence. The adjacency matrix A obtained in step 2 and the training data in the training set obtained in step 1 are input into the graph convolution network module together, wherein 0 in the matrix A represents that power station i and battery swap station j do not have a graph structure connection relationship, and 1 represents that power station i and battery swap station j have a graph structure connection relationship;
[0116] The first layer of graph convolutional network extracts the direct adjacency of each station, that is, the first-order neighbor matrix features, and the output dimension is (x, n, 64), where 64 is the output feature dimension of the first layer, n is the number of battery swap stations, and x is the batch size (also the number of historical steps that need to be reviewed during prediction);
[0117] The second-layer graph convolutional network further extracts the second-order adjacency matrix of the site, and the output dimension is (x, n, 32), where 32 is the output feature dimension of the second-layer graph convolutional network;
[0118] The third layer of graph convolutional network continues to extract site features and outputs features with a dimension of (x,n,16).
[0119] The output of the graph convolutional network module is transformed into a shape transformation operation, and the output shape of the graph convolutional network module is converted into (n, x, 16); that is, the batch size of the input of the Transformer module is converted from the batch size x of the graph convolutional network module to n, that is, the total number of battery swap stations, that is, the input data dimension of the Transformer module is (n, x, 16);
[0120] The Transformer module consists of a self-attention mechanism layer, a multi-head attention mechanism layer, a linear transformation layer, a residual connection, and a layer normalization.
[0121] The input of the self-attention mechanism layer is the output of the graph convolutional network module. The self-attention mechanism layer maps the input features into three matrices: Q, K, and V;
[0122] Among them, the Q matrix is generated as follows:
[0123] Through the weight matrix W Q , W Q The size of is 16×16, and the input matrix is mapped to the query matrix. The calculation formula is as follows:
[0124] Q=X·W Q (4)
[0125] X represents the input data feature. The dimension of the input data is (n, x, 16). After matrix multiplication, the dimension of the generated Q matrix is (n, x, 16), which means that each battery swap station generates a 16-dimensional query feature. Next, the Q matrix is split into 4 heads. The dimension of each head is (n, x, 4), that is, each head is responsible for processing 4-dimensional features.
[0126] The K matrix is generated as follows:
[0127] Using the weight matrix W K , W K The size is 16×16, and the input features are mapped to a key matrix. The calculation formula is as follows:
[0128] K=X·W K (5)
[0129] X represents the input data feature. The dimension of the input data is also (n, x, 16). The dimension of the generated K matrix is (n, x, 16). The K matrix is also split into 4 heads, and the dimension of each head is (n, x4).
[0130] The V matrix is generated as follows:
[0131] Using the weight matrix W V , W V The size is (16×16) and the input features are mapped to a value matrix. The calculation formula is as follows:
[0132] V=X·W V (6)
[0133] The generated Value matrix has a dimension of (n,x,16) and is split into 4 sub-matrices, each with a head dimension of (n,x,4);
[0134] The number of heads in the multi-head attention mechanism layer is h = 4, and the query vector dimension of each head is d k =16 / 4=4;
[0135] For each attention head in the multi-head attention mechanism layer, the dot product between the Q and K matrices is calculated, and then the result is scaled and the Softmax function is applied to get the attention weight, which is calculated as follows:
[0136]
[0137] After calculation, the attention weight matrix is multiplied by the V matrix to obtain the output of each attention head. The output dimension of each head is (n,x,4);
[0138] Then the outputs of all attention heads are connected to form a complete output matrix. After concatenating the output dimensions of the four heads, each with a dimension of (n, x, 4), the output of the final multi-head attention mechanism layer is obtained with a dimension of (n, x, 16).
[0139] The output of the multi-head attention mechanism layer is then linearly transformed to restore the dimension of the original input, and then processed by residual connection and layer normalization to obtain the final output of the Transformer module. The dimension of the output feature is (n, x, 16).
[0140] The spatiotemporal feature fusion layer organically integrates the spatial features extracted from the graph convolutional network module with the temporal features extracted from the Transformer module. The spatiotemporal feature fusion layer includes a spatiotemporal feature connection layer and a multi-layer perceptron.
[0141] The spatiotemporal feature connection layer inputs the feature matrix output by the graph convolutional network module into the Transformer module. After modeling dependencies of different degrees, the output feature dimension is (n, x, 16). The multilayer perceptron projects the concatenated feature matrix into a feature space of dimension 16 through a fully connected layer, and then passes through the ReLU activation function and normalization layer to finally obtain the spatiotemporal fusion feature matrix with a dimension of (n, x, 16).
[0142] The input of the fully connected layer comes from the output feature matrix of the spatiotemporal feature fusion layer. The fully connected layer includes three fully connected neurons. Each neuron is connected to all elements of the input feature vector and linearly transformed through weighted and biased terms, and then nonlinearly processed through activation functions. Specifically:
[0143] In the first fully connected layer, the input features are first linearly transformed, that is, multiplied by the weight matrix and the input matrix, and the bias term is added. Assuming that the dimension of the weight matrix W of the fully connected layer is (16,8), the input 16-dimensional features are compressed into 8-dimensional features. The calculation formula of the linear transformation is as follows:
[0144] Z=X′W+b(8)
[0145] Where: X′ is the output feature matrix of the input spatiotemporal feature fusion layer, with a dimension of (n, x, 16); W is the weight matrix of the fully connected layer, with a dimension of (16, 8), indicating that the 16-dimensional feature is mapped to the 8-dimensional space; b is the bias term of the fully connected layer, with a dimension of 8, indicating that each output dimension has a bias; Z is the output matrix after the fully connected layer, with a dimension of (n, x, 8), indicating that the features of each battery swap station are represented in 8 dimensions after the fully connected layer;
[0146] After the linear transformation, nonlinearity is introduced by introducing the ReLU activation function. The formula is as follows:
[0147] ReLU(x)=max(0,x)(9)
[0148] The output dimension after the ReLU activation function remains unchanged, which is (n,x,8);
[0149] By analogy, in the second fully connected layer: input dimension (n,x,8), output dimension (n,x,4), the third fully connected layer: input dimension (n,x,4), output dimension (n,x,1);
[0150] That is, after passing the fully connected layer, the final output matrix dimension is (n, x, 1), where n is the batch size, i.e., the samples of 46 stations, x is the time step, i.e., x battery swap load data are used as input, and 1 is the load prediction value, which indicates the load prediction result of each battery swap station at the current time step.
[0151] Example 5
[0152] Based on Example 4, the training process of step 3 is as follows:
[0153] The data in the training set is input into the graph convolutional network module to extract spatial features, and then the temporal features are extracted through the Transformer module. The spatial and temporal features are fused through the spatiotemporal feature fusion layer, and the predicted value of the battery swap load of each battery swap station is output through the fully connected layer.
[0154] During training, the difference between the predicted value and the true value is calculated through the loss function mean square error MSE, the error is back-propagated and the model parameters are updated. The formula of MSE is as follows:
[0155]
[0156] Where: y i is the actual load value, is the load value predicted by the model, and N is the number of samples;
[0157] The Adam optimizer is used to update the parameters. The initial learning rate is set to 0.001, the batch size x is 128, and the maximum number of iterations is 1500. To prevent the model from overfitting, the training is stopped early when the loss on the validation set no longer decreases.
[0158] According to the performance of the model on the validation set, the model's hyperparameters are dynamically adjusted, including the learning rate, batch size, the number of graph convolutional network layers in the graph convolutional network module, and the number of Transformer heads.
[0159] Example 6
[0160] In actual application, the model input data: For the GCN-Transformer model, its input is the synchronized data of n sites at all time steps. The sorted data is constructed into a tensor with a shape of (k,n,4), where: k represents the number of time steps, n represents the number of sites, and 4 represents the data dimension of each site (for example, 4 features of each site). In the verification stage, the input data shape of each time step is (n,4). By sorting the data of all time steps into (k val ,n,4) tensor, which is convenient for model processing and calculation of verification results. Here k val Refers to the size of the historical time step during validation.
[0161] Example 7
[0162] Based on Example 5, this example obtains the load data of 46 electric vehicle swap stations in Changchun City within one year (from March 1, 2022 to February 29, 2023); the specific process is as follows:
[0163] Step 1: Obtain historical electric vehicle load data from a designated database or sensor system. The data includes battery swap load data at different time points, weather data (cloud coverage, rainfall, humidity, air pressure, temperature, wind speed) at that time point, and regional location (latitude and longitude) of the battery swap station. There are 46 longitudes and latitudes of battery swap stations, 365 groups of weather data of battery swap stations (6 in each group), and 854,689 historical load data of battery swap stations (854,689 battery swaps at all 46 battery swap stations in one year).
[0164] Step 1.1, data cleaning: clean the historical battery swap load data, process missing values and outliers, use the average value of the previous day at that time point to fill in the missing data, remove abnormal fluctuation data, and ensure the accuracy of the input data;
[0165] Step 1.2, normalize the cleaned battery swap load data to eliminate dimensional differences in order to improve the efficiency and stability of model training;
[0166] Step 1.3, apply a low-pass filter to filter the normalized data to remove high-frequency noise components to ensure that the input data is smoother and more reliable;
[0167] Step 1.4, the load data processed in step 1.3 is matched with the meteorological data of the day according to the 24-hour period, specifically:
[0168] Meteorological data consists of cloud cover, rainfall, humidity, air pressure, and temperature data. The battery load data processed in step 1.3 is classified according to the type of meteorological data, and then the battery load data corresponding to the same type of meteorological data is arranged in descending order according to the rank correlation coefficient value. The final calculated result is as follows: Figure 1 As shown, the weather factors finally retained are air pressure, humidity, rainfall, and temperature, and the final data segment with dimension (46, 365, 3) is obtained; the total time step number of all sampled data is 365 days;
[0169] Step 1.5, perform sliding window segmentation on the data segment exchange load data processed in step 1.4, set a 1h sliding window to sample the EEG signals in the data in segments, select the total load of the exchange station for the standby channel, sample at 1 sample point per hour for 46 exchange stations, and sample at 1 sample point per hour for 46 exchange stations to obtain a data segment with a dimension of (46,365*24,1);
[0170] Step 1.6, merge the meteorological data obtained in step 1.4 into the data segment obtained in step 1.5 to obtain a data segment with a dimension of (46,365*24,4), where k is the total time steps of all sampled data;
[0171] In step 1.7, the obtained data segments are divided into training set, validation set and test set in a ratio of 8:1:1 to ensure that the model can be fully learned through the training set, adjust the hyperparameters through the validation set, and evaluate the generalization ability of the model through the test set.
[0172] Step 2: Map the location of the corresponding battery swap station to the map. Figure 2 As shown, according to the coordinates on the map, find the shortest driving distance between the battery swap station i and the battery swap station j, denoted as l ij , we get a matrix L with a dimension of (46, 46), according to the element l in L ij Generate a ij , when l ij When it is greater than or equal to 15, take a ij is 0, otherwise it is 1, generating an A matrix with dimension (46, 46) containing only 0 or 1. In the A matrix, 0 represents that power station i and battery swap station j do not have a graph structure connection relationship, and 1 represents that power station i and battery swap station j have a graph structure connection relationship.
[0173] Step 3: In order to better extract the complex spatial relationship between sites, the present invention uses a three-layer graph convolutional network (GCN) layer for feature extraction, such as Figure 3 As shown in the figure. Each layer of GCN gradually propagates information from adjacent nodes to obtain a richer spatial feature representation. In the GCN layer, a graph structure containing multiple nodes is constructed. The nodes represent battery swap stations, and the edges represent the physical or functional connections between the stations. The graph structure is represented by the adjacency matrix A.
[0174] The first layer of GCN extracts the direct adjacency (i.e., first-order neighbor matrix) features of each site, and the output dimension is (128, 46, 64), where 64 is the output feature dimension of the first layer.
[0175] The second layer of GCN further extracts the second-order adjacency matrix of the site, and the output dimension is (128, 46, 32), where 32 is the output feature dimension of the second layer;
[0176] The third layer of GCN extracts the features of the site and captures deeper spatial dependencies, with an output dimension of (128, 46, 16);
[0177] The spatial features obtained from the GCN module are input into the Transformer module, and the multi-head coefficient self-attention mechanism is used to extract the long-distance dependencies in the time series. When implementing the self-attention mechanism based on the multi-head attention mechanism (Self-Attention with Multi-Head Attention Mechanism), the model processes different parts of the input sequence in parallel in different representation subspaces through multiple attention heads (AttentionHeads), thereby capturing the long-distance dependencies in the input data. The following is a detailed description of the mechanism, the generation and setting of related parameters, and the implementation steps:
[0178] The multi-head sparse self-attention mechanism layer calculates the correlation in the input data and processes different time steps in parallel through the multi-head attention mechanism. The output of the graph convolutional network module is transformed to convert the output shape of the graph convolutional network module (128, 46, 16) to (46, 128, 16); that is, the batch size of the input to the Transformer module is converted from the batch size of 128 of the graph convolutional network module to 46, that is, the total number of battery swap stations, that is, the input data dimension of the Transformer module is (46, 128, 16), and the number of heads h = 4 (in the scenario, the feature dimension of each battery swap station is 4 (one compliance data, three weather factors). If the multi-head attention mechanism is selected, the feature dimension d is usually required. k Divisible by the number of heads h, the query vector dimension of each head is d k =16 / 4=4.
[0179] The input of the self-attention mechanism layer is the output of the graph convolutional network module. The self-attention mechanism layer maps the input features into three matrices: Query (Q), Key (K) and Value (V), as shown in Figure 4 As shown;
[0180] Among them, the Q matrix is generated as follows:
[0181] Through the weight matrix W Q , W Q The size of is 16×16, and the input matrix is mapped to the query matrix. The calculation formula is as follows:
[0182] Q=X·W Q (4)
[0183] X represents the input data feature. The dimension of the input data is (46, 128, 16). After matrix multiplication, the dimension of the generated Q matrix is (46, 128, 16), indicating that each battery swap station generates a 16-dimensional query feature. Next, the Q matrix is split into 4 heads. The dimension of each head is (46, 128, 4), that is, each head is responsible for processing 4-dimensional features.
[0184] The K matrix is generated as follows:
[0185] Using the weight matrix W K , W K The size is 16×16, and the input features are mapped to a key matrix. The calculation formula is as follows:
[0186] K=X·W K (5)
[0187] X represents the input data feature. The dimension of the input data is also (46, 128, 16). The dimension of the generated K matrix is (46, 128, 16). The K matrix is also split into 4 heads, and the dimension of each head is (46, 128, 4).
[0188] The V matrix is generated as follows:
[0189] Using the weight matrix W V , W V The size is (16×16) and the input features are mapped to a value matrix. The calculation formula is as follows:
[0190] V=X·W V (6)
[0191] The generated Value matrix has a dimension of (46, 128, 16) and is split into 4 sub-matrices, with each head having a dimension of (46, 128, 4).
[0192] For each attention head in the multi-head attention mechanism layer, the dot product between the Q and K matrices is calculated, and then the result is scaled and the Softmax function is applied to get the attention weight, which is calculated as follows:
[0193]
[0194] After calculation, the attention weight matrix is multiplied by the V matrix to obtain the output of each attention head. The output dimension of each head is (46, 128, 16);
[0195] Then the outputs of all attention heads are connected to form a complete output matrix. After concatenating the output dimensions of the four heads, each with a dimension of (46, 128, 4), the output of the final multi-head attention mechanism layer is obtained with a dimension of (46, 128, 16).
[0196] The output of the multi-head attention mechanism layer is then linearly transformed to restore the dimension of the original input, and then processed by residual connection and layer normalization to obtain the final output of the Transformer module. The dimension of the output feature is (46, 128, 16).
[0197] The spatiotemporal feature fusion layer organically integrates the spatial features extracted from the graph convolutional network module with the temporal features extracted from the Transformer module. The spatiotemporal feature fusion layer includes a spatiotemporal feature connection layer and a multi-layer perceptron.
[0198] The spatiotemporal feature connection layer inputs the output feature matrix of the graph convolutional network module into the Transformer module. After modeling different degrees of dependency, the output feature dimension is (46, 128, 16). The multi-layer perceptron projects the concatenated feature matrix through a fully connected layer to a feature space with a dimension of 16. After passing through the ReLU activation function and the normalization layer, the spatiotemporal fusion feature matrix is finally obtained with a dimension of (46, 128, 16). The fusion feature matrix will be used as the input of subsequent layers (such as fully connected layers or output layers) for the final load forecasting task. Through the effective fusion of spatiotemporal features, the model can capture and utilize spatial and temporal dependencies at the same time, thereby improving the accuracy of prediction and the generalization ability of the model.
[0199] The fully connected layer (FC) is a key part used to further compress and map the high-dimensional spatiotemporal features output by the previous layer (i.e., the spatiotemporal feature fusion layer). Through the fully connected layer, the model can convert high-dimensional features into low-dimensional representations suitable for prediction. The fully connected layer is usually connected to the output layer to complete the final task of load forecasting.
[0200] The input of the fully connected layer comes from the output feature matrix of the spatiotemporal feature fusion layer. The fully connected layer includes three fully connected neurons. Each neuron is connected to all elements of the input feature vector and linearly transformed through weighted and biased terms, and then nonlinearly processed through activation functions. Specifically:
[0201] In the first fully connected layer, the input features are first linearly transformed, that is, multiplied by the weight matrix and the input matrix, and the bias term is added. Assuming that the dimension of the weight matrix W of the fully connected layer is (16,8), the input 16-dimensional features are compressed into 8-dimensional features. The calculation formula of the linear transformation is as follows:
[0202] Z=X′W+b(8)
[0203] Among them: X′ is the output feature matrix of the input spatiotemporal feature fusion layer, with a dimension of (46, 128, 16); W is the weight matrix of the fully connected layer, with a dimension of (16, 8), indicating that the 16-dimensional feature is mapped to the 8-dimensional space; b is the bias term of the fully connected layer, with a dimension of 8, indicating that each output dimension has a bias; Z is the output matrix after the fully connected layer, with a dimension of (46, 128, 8), indicating that the features of each battery swap station are represented by 8-dimensional features after the fully connected layer;
[0204] After the linear transformation, nonlinearity is introduced by introducing the ReLU activation function. The ReLU function can effectively handle positive values. The formula is as follows:
[0205] ReLU(x)=max(0,x)(9)
[0206] The output dimension after the ReLU activation function remains unchanged, which is (46,128,8);
[0207] In order to enhance the expressiveness of the model, the fully connected layer can usually be designed as a three-layer structure;
[0208] By analogy, in the second fully connected layer: input dimension (46,128,8), output dimension (46,128,4), the third fully connected layer: input dimension (46,128,4), output dimension (46,128,1);
[0209] That is, after passing through the fully connected layer, the final output matrix dimension is (46, 128, 1), 46 is the batch size, that is, the samples of 46 stations, 128 is the time step, that is, 128 battery swap load data are used as input, and 1 is the load prediction value, which represents the load prediction result of each battery swap station at the current time step. That is, through layer-by-layer compression, the load prediction result of each node is finally obtained.
[0210] Step 3: Model training and optimization
[0211] The data in the training set is input into the GCN-Transformer model. The specific training process includes forward propagation, back propagation, loss calculation and parameter update. The model extracts spatial features through the GCN layer in turn, and then extracts temporal features through the Transformer layer. The spatiotemporal feature fusion layer fuses the spatial and temporal features, and outputs the load forecast value of each battery swap station through the fully connected layer. The difference between the predicted value and the true value is calculated through the loss function mean square error (MSE), the error is back propagated and the model parameters are updated. The formula of MSE is as follows:
[0212]
[0213] Where: y i is the actual load value, is the load value predicted by the model, and N is the number of samples.
[0214] The model uses the Adam optimizer to update parameters. The initial learning rate is set to 0.001, the batch size is 128, and the maximum number of iterations is 1500. The learning rate and other hyperparameters are adjusted through the validation set. The Adam optimizer combines the first-order and second-order momentum to accelerate the convergence of the model during training.
[0215] To prevent the model from overfitting, the training is stopped early when the loss on the validation set no longer decreases significantly. The specific early stopping mechanism is set to terminate the training process when the loss on the validation set does not decrease for several consecutive rounds.
[0216] According to the performance on the validation set, the model's hyperparameters are dynamically adjusted, including learning rate, batch size, number of GCN layers, and number of Transformer heads.
[0217] After the training is completed in this embodiment, it will be evaluated on the test set. Common evaluation indicators include mean square error (MSE) and mean absolute error (MAE) to ensure that the model can accurately predict load on unseen data.
[0218] The load prediction value and the actual value of a certain switching point in 46 switching stations according to this embodiment are as follows: Figure 7 As shown in Table 1, the prediction error values of three battery swap stations are randomly selected from all battery swap stations:
[0219] Table 1
[0220]
[0221] The average error is shown in Table 2:
[0222] Table 2
[0223]
[0224] To illustrate the advantages of the method provided by the present invention, the performance indicators of the latest and most relevant prediction methods in recent years are compared as shown in Table 3:
[0225] Table 3
[0226]
[0227] It can be seen from the table that the y prediction method of the GCN-Transformer mechanism proposed in this invention MAPE and FABoth indicators are better than the existing RNN (recurrent neural network), TCN-LSTM (temporal convolutional network-long short-term memory network), and CNN-LSTM (convolutional neural network-long short-term memory network).
Claims
1. A spatiotemporal load forecasting method for electric vehicle battery swap stations under different couplings based on the GCN-Transformer model, characterized in that: The specific steps are as follows: Step 1, obtaining load data of n battery swap stations within k hours, wherein the load data includes battery swap load data at different time points, meteorological data of the day at the time point, and regional location data of the corresponding battery swap station, preprocessing the battery swap load data, and dividing the preprocessed data into a training set and a validation set; Step 2, obtaining the adjacency matrix A between n battery swap stations; Step 3: Build a GCN-Transformer model with multi-head attention mechanism and sparse attention mechanism; Step 4, using the data in the training set to train the model constructed in step 4; Step 5: Use the trained model to predict the spatiotemporal load of the electric vehicle battery swap station under different couplings.
2. The spatiotemporal load forecasting method of electric vehicle battery swap station based on GCN-Transformer model under different couplings according to claim 1 is characterized in that: The load data is preprocessed in step 1 as follows: Step 1.1, clean the battery swap load data, specifically: process missing data and abnormal data, use the average value of the previous day at that time point to fill the missing data, and remove abnormal fluctuation data; Step 1.2: Normalize the cleaned data. Among them, x is the corresponding battery replacement load data after cleaning, x * is the corresponding battery swap load data after normalization, x min is the minimum value of the corresponding battery replacement load data after cleaning, x max It is the maximum value of the corresponding battery replacement load data after cleaning; Step 1.3, using a low-pass filter to filter the normalized battery swap load data for noise; Step 1.4, the load data processed in step 1.3 is matched with the meteorological data of the day according to the 24-hour period, specifically: Meteorological data consists of cloud coverage, rainfall, humidity, air pressure, and temperature data. The battery swap load data processed in step 1.3 is classified according to the type of meteorological data, and then the battery swap load data corresponding to the same type of meteorological data are arranged in descending order according to the rank correlation coefficient value. The Spearman rank correlation coefficient calculation formula is as follows: Where l is the number of load data values for each time period, d i represents the difference between the position of the ith load data value and the selected meteorological data, d i The calculation method of is as follows: first, collect the battery swap load data and corresponding meteorological data of each time period; second, sort the i-th value of the battery swap load data and meteorological data of each time period respectively, and assign a rank to each data point; finally, for each time period, calculate the difference between the rank of the battery swap load data and the rank of the meteorological data, and get d i ; The Spearman rank correlation coefficient of the calculated related factors was used to screen and retain the top four factors. For each time period, a meteorological data segment with a dimension of 3 was obtained. The meteorological data dimension obtained by sampling at all stations was (n, k, 3), where k was the total number of time steps for all sampled data; Step 1.5, the data segment exchange load data processed in step 1.4 is segmented by sliding window, and a 1h sliding window is set to segment the EEG signals in the data. The standby channel selects the total load of the exchange station, and samples at 1 sample point per hour for n exchange stations to obtain a data segment with a dimension of (n, k, 1); Step 1.6, merging the meteorological data obtained in step 1.4 into the data segment obtained in step 1.5 to obtain a data segment with a dimension of (n, k, 4), where k is the total time steps of all sampled data; Step 1.7, divide the formed data segments into training set and validation set according to the proportion.
3. The spatiotemporal load forecasting method of electric vehicle battery swap station based on GCN-Transformer model under different couplings according to claim 2 is characterized in that: The step 2 is specifically as follows: Step 2.1, according to the regional location data of the corresponding battery swap station, the geographical location of the battery swap station is mapped to the map, and the element values of the neighbor matrix are judged based on the shortest driving routes between different battery swap stations in the map to form an L matrix with a dimension of (n, n), where each element in the L matrix is denoted as l ij , l ij represents the shortest driving route from the i-th battery swap station to the j-th battery swap station, i = 1, 2, 3, ..., n, j = 1, 2, 3, ..., n; Step 2.2, take the matrix A, element a in A ij Determined by the size of the elements in the L matrix, when l ij If it is greater than or equal to 15, take a ij is 0, otherwise it is 1, and we get the A matrix: That is, the adjacency matrix A between each battery swap station.
4. The spatiotemporal load forecasting method for electric vehicle battery swap stations based on the GCN-Transformer model under different couplings according to claim 3 is characterized in that: The GCN-Transformer model containing the multi-head attention mechanism and the sparse attention mechanism in step 3 includes a graph convolutional network module and a Transformer module connected in sequence, the outputs of the graph convolutional network module and the Transformer module are jointly connected to a spatiotemporal feature fusion layer, and the output of the spatiotemporal feature fusion layer is connected to a fully connected layer.
5. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 4 is characterized in that: The graph convolution network module includes three layers of graph convolution networks connected in sequence. The adjacency matrix A obtained in step 2 and the training data in the training set obtained in step 1 are input into the graph convolution network module together, wherein 0 in the A matrix represents that the power station i and the battery swap station j do not have a graph structure connection relationship, and 1 represents that the power station i and the battery swap station j have a graph structure connection relationship; The first layer of graph convolutional network extracts the direct adjacency of each station, that is, the first-order neighbor matrix features, and the output dimension is (x, n, 64), where 64 is the output feature dimension of the first layer, n is the number of battery swap stations, and x is the batch size; The second-layer graph convolutional network further extracts the second-order adjacency matrix of the site, and the output dimension is (x, n, 32), where 32 is the output feature dimension of the second-layer graph convolutional network; The third layer of graph convolutional network continues to extract site features and outputs features with a dimension of (x,n,16).
6. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 5 is characterized in that: The output of the graph convolutional network module is transformed into a shape transformation operation, and the output shape of the graph convolutional network module is converted into (n, x, 16); that is, the batch size of the input of the Transformer module is converted from the batch size x of the graph convolutional network module to n, that is, the total number of battery swap stations, that is, the input data dimension of the Transformer module is (n, x, 16); The Transformer module includes a self-attention mechanism layer, a multi-head attention mechanism layer, a linear transformation layer, a residual connection and a layer normalization, which are connected in sequence.
7. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 6 is characterized in that: The input of the self-attention mechanism layer is the output of the graph convolutional network module. The self-attention mechanism layer maps the input features into three matrices: Q, K and V; Among them, the Q matrix is generated specifically as follows: Through the weight matrix W Q , W Q The size of is 16×16, and the input matrix is mapped to the query matrix. The calculation formula is as follows: Q=X·W Q (4) X represents the input data feature. The dimension of the input data is (n, x, 16). After matrix multiplication, the dimension of the generated Q matrix is (n, x, 16), which means that each battery swap station generates a 16-dimensional query feature. Next, the Q matrix is split into 4 heads. The dimension of each head is (n, x, 4), that is, each head is responsible for processing 4-dimensional features. The K matrix is generated as follows: Using the weight matrix W K , W K The size is 16×16, and the input features are mapped to a key matrix. The calculation formula is as follows: K=X·W K (5) X represents the input data feature. The dimension of the input data is also (n, x, 16). The dimension of the generated K matrix is (n, x, 16). The K matrix is also split into 4 heads, and the dimension of each head is (n, x, 4). The V matrix is generated as follows: Using the weight matrix W V , W V The size is (16×16) and the input features are mapped to a value matrix. The calculation formula is as follows: V=X·W V (6) The generated Value matrix has a dimension of (n,x,16) and is split into 4 sub-matrices, each with a head dimension of (n,x,4); The number of heads in the multi-head attention mechanism layer is h=4, and the query vector dimension of each head is d k =16 / 4=4; For each attention head in the multi-head attention mechanism layer, the dot product between the Q and K matrices is calculated, and then the result is scaled and the Softmax function is applied to get the attention weight, which is calculated as follows: After calculation, the attention weight matrix is multiplied by the V matrix to obtain the output of each attention head. The output dimension of each head is (n,x,4); Then the outputs of all attention heads are connected to form a complete output matrix. After concatenating the output dimensions of the four heads, each with a dimension of (n, x, 4), the output of the final multi-head attention mechanism layer is obtained with a dimension of (n, x, 16). The output of the multi-head attention mechanism layer is then linearly transformed to restore the dimension of the original input, and then processed by residual connection and layer normalization to obtain the final output of the Transformer module. The dimension of the output feature is (n, x, 16).
8. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 7 is characterized in that: The spatiotemporal feature fusion layer organically fuses the spatial features extracted from the graph convolutional network module with the temporal features extracted from the Transformer module, and the spatiotemporal feature fusion layer includes a spatiotemporal feature connection layer and a multi-layer perceptron; The spatiotemporal feature connection layer inputs the feature matrix output by the graph convolutional network module into the Transformer module. After modeling dependencies of different degrees, the output feature dimension is (n, x, 16). The multilayer perceptron projects the concatenated feature matrix into a feature space of dimension 16 through a fully connected layer, and then passes through the ReLU activation function and the normalization layer to finally obtain a spatiotemporal fusion feature matrix with a dimension of (n, x, 16).
9. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 8 is characterized in that: The input of the fully connected layer comes from the output feature matrix of the spatiotemporal feature fusion layer. The fully connected layer includes three fully connected neurons, each of which is connected to all elements of the input feature vector and linearly transformed through weighted and biased terms, and then nonlinearly processed through activation functions. Specifically: In the first fully connected layer, the input features are first linearly transformed, that is, multiplied by the weight matrix and the input matrix, and the bias term is added. Assuming that the dimension of the weight matrix W of the fully connected layer is (16,8), the input 16-dimensional features are compressed into 8-dimensional features. The calculation formula of the linear transformation is as follows: Z=X′W+b(8) Where: X′ is the output feature matrix of the input spatiotemporal feature fusion layer, with a dimension of (n, x, 16); W is the weight matrix of the fully connected layer, with a dimension of (16, 8), indicating that the 16-dimensional feature is mapped to the 8-dimensional space; b is the bias term of the fully connected layer, with a dimension of 8, indicating that each output dimension has a bias; Z is the output matrix after the fully connected layer, with a dimension of (n, x, 8), indicating that the features of each battery swap station are represented in 8 dimensions after the fully connected layer; After the linear transformation, nonlinearity is introduced by introducing the ReLU activation function. The formula is as follows: ReLU(x)=max(0,x)(9) The output dimension after the ReLU activation function remains unchanged, which is (n,x,8); By analogy, in the second fully connected layer: input dimension (n,x,8), output dimension (n,x,4), the third fully connected layer: input dimension (n,x,4), output dimension (n,x,1); That is, after passing the fully connected layer, the final output matrix dimension is (n, x, 1), where n is the batch size, i.e., the samples of 46 stations, x is the time step, i.e., x battery swap load data are used as input, and 1 is the load prediction value, which indicates the load prediction result of each battery swap station at the current time step.
10. The method for predicting the spatiotemporal load of an electric vehicle battery swap station under different couplings based on the GCN-Transformer model according to claim 9 is characterized in that: The training process of step 3 is as follows: The data in the training set is input into the graph convolutional network module to extract spatial features, and then the temporal features are extracted through the Transformer module. The spatial and temporal features are fused through the spatiotemporal feature fusion layer, and the predicted value of the battery swap load of each battery swap station is output through the fully connected layer. During training, the difference between the predicted value and the true value is calculated through the loss function mean square error MSE, the error is back-propagated and the model parameters are updated. The formula of MSE is as follows: Where: y i is the actual load value, is the load value predicted by the model, and N is the number of samples; The Adam optimizer is used to update the parameters. The initial learning rate is set to 0.001, the batch size x is 128, and the maximum number of iterations is 1500. To prevent the model from overfitting, the training is stopped early when the loss on the validation set no longer decreases. According to the performance of the model on the validation set, the model's hyperparameters are dynamically adjusted, including the learning rate, batch size, the number of graph convolutional network layers in the graph convolutional network module, and the number of Transformer heads.
Citation Information
Cited By
Method and system for complementing traffic flow data based on priori knowledge and Transform
CN120216932A
Battery swap station battery swap demand prediction method and device, server and readable storage medium
CN121638897A
Method and system for predicting net load of high-proportion new energy access power distribution network
CN122118681A