Electric vehicle charging demand prediction method, system, device and medium
By combining convolutional neural networks and long short-term memory networks with attention mechanisms, the problem of insufficient accuracy in predicting electric vehicle charging demand by traditional prediction methods is solved, achieving more accurate charging demand prediction and supporting the scientific planning and operation of charging facilities.
Patent Information
- Application Number
- CN202511834809.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-02-10
AI Technical Summary
Traditional time series forecasting methods struggle to fully capture the complex relationships among various influencing factors in electric vehicle charging demand, resulting in limited forecast accuracy.
A convolutional neural network is used to extract the spatiotemporal features of charging data, combined with a long short-term memory network for time series modeling, and an attention mechanism is introduced to dynamically adjust the feature weights to construct a predictive model for electric vehicle charging demand.
It improves the accuracy of electric vehicle charging demand forecasting, ensures high quality and consistency of input data, and optimizes the planning and operation of charging facilities.
Smart Images

Figure CN121504082A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of multi-energy power system technology, and in particular to a method, system, device and medium for predicting electric vehicle charging demand. Background Technology
[0002] Multi-energy power systems with a high proportion of renewable energy have become the future trend of power system development. With the increasing integration of renewable energy, energy storage systems, and electric vehicle charging stations, the intermittent nature of power generation and the volatility of loads are increasingly impacting the optimal operation of power systems. Electric vehicles, as representatives of clean energy transportation, exhibit significant randomness and uncertainty in their charging demand, posing new challenges to the stable operation of distribution networks. Therefore, accurately predicting electric vehicle charging demand and rationally scheduling renewable energy, energy storage systems, and conventional power sources in the distribution network to achieve coordinated development between electric vehicles and the power grid has become a hot topic in power system optimization and scheduling. Traditional time series forecasting methods struggle to fully capture the complex relationships between various influencing factors when dealing with complex nonlinear time series data such as electric vehicle charging demand, resulting in limited prediction accuracy. In recent years, deep learning technologies, especially CNN and LSTM, have demonstrated significant advantages in processing complex nonlinear time series data. CNN can effectively extract local features from data and capture patterns at different time scales, while LSTM excels at handling long-term dependencies in time series data. Combining these two network structures can complement each other's strengths and improve prediction performance. However, simply combining CNN and LSTM is insufficient. Electric vehicle charging demand prediction is influenced by various factors, such as different vehicle models and driver habits, each with varying degrees of impact. Traditional CNN-LSTM models treat all input features equally, ignoring the differentiated impact of different features on the prediction results, leading to limited performance improvements. Attention mechanisms, which simulate human attention, assign different weights to different features, highlighting the influence of important features and suppressing the interference of noisy features, thereby improving the model's prediction accuracy. Introducing attention mechanisms into CNN-LSTM models allows for dynamic adjustment of weights based on the contribution of different features to the prediction results, constructing a more accurate prediction model. Summary of the Invention
[0003] In view of the aforementioned existing problems, the present invention is proposed.
[0004] Therefore, this invention provides a method, system, device, and medium for predicting electric vehicle charging demand to address the problem that traditional time series forecasting methods struggle to fully capture the complex relationships between various influencing factors when processing complex nonlinear time series data such as electric vehicle charging demand, resulting in limited prediction accuracy.
[0005] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for predicting electric vehicle charging demand, comprising the following steps: collecting raw charging data from charging stations; processing the raw charging data to obtain preprocessed charging data; inputting the preprocessed charging data into a convolutional neural network for spatiotemporal feature extraction to obtain spatiotemporal feature data; inputting the spatiotemporal feature data into a long short-term memory network for time series modeling to obtain time series feature data; inputting the time series feature data into an attention mechanism module to calculate the attention score of each time node in the time series feature data to obtain a context vector; concatenating the context vector with the hidden state output by the long short-term memory network, inputting it into a fully connected layer for calculation, and outputting the electric vehicle charging demand prediction result.
[0006] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the step of processing the original charging data includes: repairing missing data in the original charging data to obtain repaired charging data; removing abnormal data in the repaired charging data to obtain cleaned charging data; and normalizing the cleaned charging data to scale it to a preset range to obtain the preprocessed charging data.
[0007] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the following steps are performed: imputing missing data in the original charging data to obtain imputed charging data includes: identifying missing data points in the original charging data; initially filling in the missing data points by constructing an interpolation polynomial until the function value of the interpolation polynomial at a known data point is equal to the actual value of the known data point, thus obtaining preliminary interpolated charging data; inputting the preliminary interpolated charging data into a multivariate autoregressive embedding model, mapping the preliminary interpolated charging data to a latent space through an embedding matrix to obtain latent state data; establishing an autoregressive model in the latent space to iteratively predict the latent state data; and reconstructing the predicted latent state data into time series data through a reconstruction matrix to obtain the imputed charging data.
[0008] The beneficial effects of this preferred technical solution are as follows: the two-stage repair method, which combines initial filling using Lagrange interpolation with optimization using a multivariate autoregressive embedding model, not only preserves the overall structure of the original charging data, but also further improves the repair accuracy of missing data through latent space modeling, thus ensuring the integrity and accuracy of the charging data.
[0009] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the step of removing abnormal data from the repaired charging data to obtain cleaned charging data includes: constructing multiple isolated trees using the repaired charging data, and recursively splitting the data in each isolated tree by randomly selecting features and randomly selecting split values; for each data point in the repaired charging data, calculating the path length of the data point in each isolated tree, wherein the path length is the number of splits required to reach the leaf node where the data point is located from the root node; calculating the average path length of each data point in all isolated trees; calculating the anomaly score of each data point based on the average path length; and identifying and removing data points whose anomaly scores are greater than a preset threshold as abnormal data points to obtain the cleaned charging data.
[0010] The beneficial effects of this preferred technical solution are as follows: It uses the isolated forest algorithm to remove outlier data, isolates outliers by randomly splitting the data, can quickly process large-scale charging datasets, is insensitive to the distribution of data, does not require prior assumptions about the data distribution, has strong adaptability to high-dimensional data and noise, and effectively improves the quality of charging data.
[0011] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the step of obtaining the spatiotemporal feature data includes: inputting the preprocessed charging data into the input layer of a convolutional neural network; in the convolutional layer, using multiple convolutional kernels to perform convolution operations on the preprocessed charging data, extracting local features at different levels, and obtaining the output feature map of the convolutional layer after processing by the ReLU activation function; inputting the output feature map of the convolutional layer into a pooling layer, reducing the spatial dimension of the output feature map of the convolutional layer through pooling operations, and obtaining a pooled feature map; flattening the pooled feature map into a one-dimensional vector, inputting it into a fully connected layer for feature combination, and obtaining the spatiotemporal feature data.
[0012] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the step of obtaining the time series feature data includes: The spatiotemporal feature data are input into the Long Short-Term Memory network in chronological order. At each time t, the Long Short-Term Memory network performs the following calculations: Calculate the output of the forget gate using the forget gate. : ; Calculate the input gate output using the input gate. : ; Calculate candidate cell state : ; Update cell state : ; Calculate the output of the output gate by the output gate. : ; Calculate the hidden state at the current time. : ; in, For the current input, This is the hidden state from the previous moment. This represents the cell state at the previous moment. is the sigmoid activation function, and tanh is the hyperbolic tangent activation function. , , , These are the connection coefficients for the forget gate, input gate, candidate cell state, and output gate, respectively. , , , These are the corresponding biases; Hidden states at each time point The time series feature data is output as the output.
[0013] As a preferred embodiment of the electric vehicle charging demand prediction method of the present invention, the step of calculating the attention score of each time node in the time series feature data to obtain the context vector includes: Calculate the hidden state at the current time. Source state at each time step Similarity score between them: ; Among them, W a U a b a These are learnable parameters; The similarity scores are then subjected to softmax normalization to obtain the attention scores. : ; The context vector is obtained by weighted summation of the source states at each time step based on the attention scores. : ; The context vector Hidden state at the current moment After being concatenated, the data is input into a fully connected layer to calculate the predicted charging demand. : ; in, The connection coefficients of the fully connected layer. For biasing the fully connected layer; The model is trained using the mean squared error loss function: Where N is the sample size. For the true value, These are predicted values.
[0014] In a second aspect, the present invention provides an electric vehicle charging demand prediction system, comprising: The data processing module is used to collect the raw charging data of the charging station, perform missing data repair, abnormal data removal and normalization on the raw charging data, and output the preprocessed charging data. The spatiotemporal feature extraction module is used to receive the preprocessed charging data, perform convolution and pooling operations on the preprocessed charging data through a convolutional neural network, and output spatiotemporal feature data. The time series modeling module is used to receive the spatiotemporal feature data, perform time series modeling on the spatiotemporal feature data through a long short-term memory network, and output the time series feature data and hidden states. The attention calculation module is used to receive the time series feature data, calculate the attention score at each time node and perform a weighted summation, and output the context vector; The prediction output module is used to concatenate the context vector with the hidden state, calculate and output the electric vehicle charging demand prediction result through a fully connected layer.
[0015] Thirdly, the present invention provides an electronic device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the electric vehicle charging demand prediction method.
[0016] Fourthly, the present invention provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the electric vehicle charging demand prediction method.
[0017] Compared with existing technologies, the beneficial effects of this invention are as follows: By integrating convolutional neural networks, long short-term memory networks, and attention mechanisms, an electric vehicle charging demand prediction model is constructed. Specifically, the convolutional neural network can effectively extract spatiotemporal features from charging data and capture the charging distribution patterns within different time periods; the long short-term memory network models time-series data through a gating mechanism, capturing the long- and short-term dependencies in charging demand, thus overcoming the shortcomings of traditional prediction models in handling long-term dependencies; and the attention mechanism enables the model to focus on key nodes in the time series, improving the accuracy of charging demand prediction.
[0018] This invention employs a missing data repair method combining Lagrange interpolation and a multivariate autoregressive embedding model, as well as an outlier removal method based on isolated forests, in the data processing stage. This ensures the high quality and consistency of the input data and provides a solid foundation for the stable operation of the deep learning model. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the overall process of the electric vehicle charging demand prediction method according to an embodiment of the present invention.
[0021] Figure 2 This is an isolated forest structure diagram of the electric vehicle charging demand prediction method according to an embodiment of the present invention.
[0022] Figure 3 This is a diagram illustrating the overall structure of an electric vehicle charging demand prediction method according to an embodiment of the present invention. Detailed Implementation
[0023] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0024] Example 1, referring to Figure 1 As an embodiment of the present invention, a method for predicting electric vehicle charging demand is provided, comprising the following steps: S1. Collect the raw charging data of the charging station, process the raw charging data to obtain preprocessed charging data.
[0025] S2. Input the preprocessed charging data into a convolutional neural network to extract spatiotemporal features and obtain spatiotemporal feature data.
[0026] S3. Input the spatiotemporal feature data into a long short-term memory network to perform time series modeling and obtain time series feature data.
[0027] S4. Input the time series feature data into the attention mechanism module, calculate the attention score of each time node in the time series feature data, and obtain the context vector.
[0028] S5. Concatenate the context vector with the hidden state output by the long short-term memory network, input it into the fully connected layer for calculation, and output the electric vehicle charging demand prediction result.
[0029] It should be noted that with the rapid popularization of electric vehicles, the demand for electric vehicle charging exhibits significant randomness and uncertainty, posing new challenges to the stable operation of the power distribution network. Electric vehicle charging behavior is influenced by various factors, including vehicle type, user travel habits, weather conditions, and holidays, resulting in a complex temporal and spatial distribution of charging load. Traditional time series forecasting methods struggle to fully capture the intricate relationships between various influencing factors when dealing with complex nonlinear data such as electric vehicle charging demand, leading to limited prediction accuracy. Furthermore, the raw charging data collected by charging stations often contains missing or abnormal data. Equipment failures and other factors in the data transmission between charging facilities and backend storage devices cause data omissions or deviations, directly affecting the accuracy of the prediction results. Therefore, how to accurately predict electric vehicle charging demand and provide a scientific basis for the planning and operation of charging facilities has become a hot issue in power system optimization and dispatching.
[0030] Therefore, to address the aforementioned issues of data quality and prediction accuracy, steps S1-S5 are employed. First, missing data is repaired and outlier data is removed from the original charging data of charging stations to ensure high quality and consistency of the input data. Then, a convolutional neural network is used to extract spatiotemporal features from the charging data, capturing the charging distribution patterns within different time periods. Furthermore, a long short-term memory network is used to model the time series data, capturing the long- and short-term dependencies in charging demand. Finally, an attention mechanism is introduced to enable the model to focus on key nodes in the time series, achieving accurate prediction of electric vehicle charging demand. This provides data support for charging facility operators, optimizes the layout of charging pile resources, and improves the utilization rate of charging facilities.
[0031] Example 2, refer to Figures 1-3As an embodiment of the present invention, a method for predicting electric vehicle charging demand is provided based on the above embodiment.
[0032] In this embodiment of the application, S1, the raw charging data of the charging station is collected, and the raw charging data is processed to obtain preprocessed charging data.
[0033] Step S1, the data processing steps for the raw charging data include A1~A3: A1. Perform missing data repair on the original charging data to obtain repaired charging data, specifically including the following steps A1.1 to A1.5: A1.1 Identify missing data points in the original charging data.
[0034] Specifically, data loss usually occurs during the data transmission process between the charging facility and the charging station's backend storage equipment, due to factors such as equipment malfunction. By traversing the time series of the original charging data, the time points where null or invalid values exist in the data records are detected, and these time points are marked as missing data points, forming a missing data point index list.
[0035] A1.2. Initially fill in the missing data points by constructing an interpolation polynomial until the function value of the interpolation polynomial at the known data points is equal to the actual value of the known data points, thus obtaining the initial interpolated charging data.
[0036] In this embodiment, the Lagrange interpolation method is used to initially fill in the missing data points. An interpolation polynomial P(x) is constructed such that, given the known data points... The above satisfies The form of the Lagrange interpolation polynomial is: ,in, It is the Lagrange basis function. An interpolation polynomial is constructed using the known data points adjacent to the missing data points. The function values at the missing data points are then calculated as initial filler values to obtain the initial interpolated charging data.
[0037] A1.3 Input the preliminary interpolated charging data into the multivariate autoregressive embedding model, and map the preliminary interpolated charging data to the latent space through the embedding matrix to obtain the latent state data.
[0038] Specifically, assuming the initial interpolated charging data is a time series... ,in, Indicates a point in time. It is a p×1 vector. Through the embedding matrix... The initial interpolated charging data is mapped to the latent space; the data embedding process is represented as follows: In this context, E is a d×p embedding matrix, where d is the dimension of the latent space. Typically, d is less than p, thereby achieving data dimensionality reduction and extracting key features to obtain the latent state data Z(t).
[0039] A1.4. Establish an autoregressive model in the potential space and perform iterative prediction on the potential state data.
[0040] An autoregressive model is established in the latent space Z(t), assuming the autoregressive model of the latent state Z(t) is as follows. ,in, This is the autoregressive coefficient matrix. This represents the white noise error term. The autoregressive model iteratively predicts the potential state data, using historical potential state data to predict the current potential state, thereby providing a deeper analysis of the temporal characteristics of the charging data. A1.5. The predicted potential state data is reconstructed into time series data by reconstructing the matrix to obtain the repaired charging data.
[0041] Specifically, the predicted latent state Z(t) is reconstructed into the predicted value of the original time series data by using the reconstruction matrix D. The reconstruction process is represented as Where D is a p×d reconstruction matrix. The reconstructed predicted values are filled into the corresponding missing data point positions to obtain the repaired charging data. This not only preserves the overall structure of the original charging data but also improves the accuracy of missing data repair.
[0042] A2. Remove abnormal data from the repaired charging data to obtain cleaned charging data, specifically including the following steps A2.1~A2.5: A2.1. Multiple isolated trees are constructed using the repaired charging data. Each isolated tree recursively splits the data by randomly selecting features and randomly selecting split values.
[0043] In this embodiment, the Isolation Forest algorithm is used for outlier removal. Isolation Forest isolates outliers by randomly splitting the data, enabling rapid processing of large-scale datasets and is insensitive to the data distribution, requiring no assumptions about the data distribution. Specifically, subsamples are randomly selected from the repaired charging data, and an isolation tree is constructed for each subsample. When constructing each isolation tree, a feature dimension is randomly selected, and a splitting value is randomly selected within the range of that feature's values to divide the data point into left and right child nodes. This splitting process is repeated until each leaf node contains only one data point or a preset tree height limit is reached.
[0044] A2.2 For each data point in the repaired charging data, calculate the path length of the data point in each isolated tree, where the path length is the number of splits required to reach the leaf node where the data point is located from the root node.
[0045] For each isolated tree, starting from the root node, traverse downwards according to the splitting conditions of each node until a leaf node is reached. Record the number of edges traversed from the root node to the leaf node containing the data point; this is the path length of the data point in the isolated tree. Outliers, due to their significant differences from normal data points, are more likely to be isolated during random splitting, and therefore their path length is usually shorter.
[0046] A2.3 Calculate the average path length of each data point across all isolated trees.
[0047] For each data point Calculate the path length for each of the n isolated trees. Then calculate the average path length. The anomaly level of data points is assessed by using the average path length across multiple trees, reducing the bias caused by the randomness of a single tree and improving the stability of anomaly detection.
[0048] A2.4 Calculate the anomaly score for each data point based on the average path length.
[0049] Anomaly score calculated based on average path length. ,in, It is a normalization constant used to adjust the scale of path length, and its calculation formula is: N is the total number of samples in the dataset. Anomaly score The value ranges from 0 to 1, when When the value is close to 1, it indicates that the average path length of the data point is short, and it is more likely to be identified as an outlier; when... When the value is close to 0, it indicates that the data point is a normal point.
[0050] A2.5. Data points with abnormal scores greater than a preset threshold are identified as abnormal data points and removed to obtain the cleaned charging data.
[0051] In this embodiment, an anomaly score threshold of 0.6 is set, and data points with an anomaly score greater than this threshold are identified as anomalous data points. These anomalous data points are usually due to significant deviations between the data recorded in the system and the normal data caused by uncontrollable factors during the recording and uploading of charging data by charging piles. The identified anomalous data points are removed from the repaired charging data to obtain the cleaned charging data, thereby improving data quality and the accuracy of subsequent predictions.
[0052] A3. Normalize the post-cleaning charging data and scale it to a preset range to obtain the pre-processed post-charging data.
[0053] Normalization scales data to a fixed range to ensure consistent dimensions of different features and prevent certain features from having an excessive impact on model training. In this embodiment, the Min-Max normalization method is used to scale the cleaned and charged data to the range [0,1]. The normalization formula is as follows: Where x is the original data value, and These are the minimum and maximum values of the data, respectively. These are the normalized data values. After normalization, the preprocessed charging data is obtained, providing high-quality input data for the stable training of subsequent convolutional neural networks and long short-term memory networks.
[0054] In one optional implementation, the preliminary filling of the missing data points in step A1.2 can also be performed using cubic spline interpolation. Cubic spline interpolation constructs a cubic polynomial between adjacent data points, ensuring the interpolation curve has continuous first and second derivatives at each data point, thus obtaining a smoother interpolation result. This method is particularly suitable for scenarios where charging data changes relatively smoothly, effectively avoiding the Runge phenomenon that may occur with Lagrange interpolation when there are many data points.
[0055] In another optional implementation, the normalization of the post-cleaning charging data in step A3 can also be performed using the Z-score normalization method. Z-score normalization converts the data into a standard normal distribution with a mean of 0 and a standard deviation of 1. The calculation formula is as follows: Where μ is the data mean and σ is the data standard deviation. This method is suitable for scenarios where the data distribution approximates a normal distribution, can preserve the distribution characteristics of the data, and has better robustness for charging data with many outliers.
[0056] In this embodiment of the application, S2, the preprocessed charging data is input into a convolutional neural network for spatiotemporal feature extraction to obtain spatiotemporal feature data.
[0057] Specifically, the steps for obtaining the spatiotemporal feature data include B1 to B4: B1. Input the preprocessed charging data into the input layer of the convolutional neural network.
[0058] Specifically, a convolutional neural network (CNN) is a deep learning model particularly well-suited for processing data with a grid structure, such as images and time-series data. The preprocessed charging data obtained in step S1 is organized according to the time and feature dimensions to form input data in the form of a two-dimensional matrix. The input layer receives this two-dimensional matrix data and passes it to subsequent convolutional layers for feature extraction. The dimensions of the input data are determined based on the length of the charging data's time window and the number of features, providing a standardized data format for subsequent convolutional operations.
[0059] B2. In the convolutional layer, multiple convolutional kernels are used to perform convolution operations on the preprocessed charging data to extract local features at different levels, and the output feature map of the convolutional layer is obtained after processing by the ReLU activation function.
[0060] In this embodiment, the convolutional layer extracts the spatial features of the input data through convolution operations. Assuming the input feature map is X and the convolutional kernel is W, the convolution operation is represented as follows: ,in, These are the input data, and M and N are the sizes of the convolution kernels. It is an activation function. Specifically, multiple convolutional kernels of different sizes are set, and sliding convolution operations are performed on the preprocessed charging data. Each convolutional kernel is responsible for extracting local features of a specific pattern. After the convolution operation is completed, a nonlinear transformation is performed through the ReLU activation function. The ReLU function sets all negative values to zero and keeps positive values unchanged, thereby enhancing the nonlinear expressive ability of the network and obtaining the output feature map of the convolutional layer.
[0061] B3. Input the output feature map of the convolutional layer into the pooling layer, and reduce the spatial dimension of the output feature map of the convolutional layer through the pooling operation to obtain the pooled feature map.
[0062] Pooling layers are used to reduce the spatial dimensionality of feature maps, thereby reducing computational cost and preventing overfitting. In this embodiment, max pooling is used, which is expressed as follows: ,in, The pooling stride is denoted by m and n, where m and n range from 0 to the pooling window size minus 1. Max pooling selects the maximum value within each pooling window as the output, preserving the most significant feature information while reducing the spatial dimensionality of the feature map. The convolutional layer output feature map is divided into multiple non-overlapping local regions, and max pooling is performed on each local region to obtain the pooled feature map.
[0063] B4. Flatten the pooled feature map into a one-dimensional vector and input it into a fully connected layer for feature combination to obtain the spatiotemporal feature data.
[0064] In this embodiment, the fully connected layer flattens the outputs of the convolutional and pooling layers into a one-dimensional vector, and then combines the features through multiple fully connected layers. The pooled feature maps are arranged row-wise or column-wise and flattened into a one-dimensional vector; this one-dimensional vector is input into the fully connected layer, and the output of the fully connected layer is represented as... In this matrix, Weights is the connection coefficient matrix, and Bias is the bias vector. Each neuron in the fully connected layer is connected to all elements of the input vector. The learned connection coefficients are used to linearly combine the input features, which are then processed by the ReLU activation function to map the extracted local features onto a high-level semantic space, resulting in the spatiotemporal feature data. This spatiotemporal feature data contains the distribution patterns and spatial correlation information of the charging data across different time periods.
[0065] In an optional implementation, step B3 reduces the spatial dimension of the convolutional layer's output feature map through pooling operations; alternatively, average pooling can be used. Average pooling calculates the average value of all elements within each pooling window as the output, represented as... Average pooling can retain more background information and is effective in extracting the overall trend of charging data. It is suitable for scenarios where the charging load changes relatively steadily.
[0066] In another alternative implementation, a batch normalization layer can be added after the convolutional layer in step B2. The batch normalization layer normalizes each mini-batch of data to have a mean of zero and a variance of one, and then performs a linear transformation using learnable scaling and offset parameters. Batch normalization can accelerate network training convergence, alleviate the vanishing gradient problem, and has a certain regularization effect, improving the model's generalization ability.
[0067] In this embodiment of the application, S3, the spatiotemporal feature data is input into a long short-term memory network for time series modeling to obtain time series feature data.
[0068] Specifically, the steps for obtaining the time series feature data include C1 to C3: C1. Input the spatiotemporal feature data into the Long Short-Term Memory network in chronological order.
[0069] Specifically, Long Short-Term Memory (LSTM) networks are a type of temporal recurrent neural network that can retain some information during information transmission as input for the next neuron, effectively solving the gradient vanishing and gradient exploding problems in traditional recurrent neural networks. The spatiotemporal feature data obtained in step S2 is segmented according to the time dimension to form a time series input sequence. , of which each This represents the feature vector at time t. The time series is then input into the Long Short-Term Memory (LSTM) network in chronological order, enabling the network to learn the evolution of the charging data over time.
[0070] C2. At each time t, the Long Short-Term Memory network performs the following calculations: Calculate the output of the forget gate using the forget gate. : ; Calculate the input gate output using the input gate. : ; Calculate candidate cell state : ; Update cell state : ; Calculate the output of the output gate by the output gate. : ; Calculate the hidden state at the current time. : ; in, For the current input, This is the hidden state from the previous moment. This represents the cell state at the previous moment. is the sigmoid activation function, and tanh is the hyperbolic tangent activation function. , , , These are the connection coefficients for the forget gate, input gate, candidate cell state, and output gate, respectively. , , , These are the corresponding biases.
[0071] In this embodiment, the Long Short-Term Memory (LSTM) network updates the unit state through a three-gate structure. The forget gate updates the state based on the input at the current time step. and the hidden state of the previous moment The decision is based on the cell state at the previous moment. What invalid information is forgotten in the process, and what is the output of the forget gate? The value of is between 0 and 1, with values close to 0 indicating complete forgetting and values close to 1 indicating complete retention. The input gate determines which new input information is saved to the cell state, and the input gate output... With candidate cell state Multiplying these results in the new information that needs to be added to the cell state. Cell state The cell state is updated by multiplying the output of the forget gate by the product of the cell state at the previous time step and the output of the input gate by the product of the candidate cell state, thus achieving selective memorization and forgetting of information. The output gate determines which information in the cell state needs to be output, and the output gate outputs... Multiplying the result of the cell state after tanh activation yields the hidden state at the current time step. .
[0072] C3. Hide the state at each time step. The time series feature data is output as the output.
[0073] Specifically, after the spatiotemporal feature data is modeled using a Long Short-Term Memory (LSTM) network, a hidden state is generated at each time step t. This hidden state contains all historical information from the start of the sequence to the current time. The hidden states at each time step... The collected and organized data forms the time-series feature data. This time-series feature data captures the long-term and short-term dependencies in charging demand, reflects the pattern of charging load changes over time, compensates for the shortcomings of traditional models in dealing with long-term dependencies, and provides feature input with temporal correlation information for the subsequent attention mechanism module.
[0074] In one optional implementation, step C1 involves inputting the spatiotemporal feature data into a Long Short-Term Memory (LSTM) network. Alternatively, a bidirectional LSTM network structure can be employed. The bidirectional LSTM network comprises two LSTM networks: a forward network and a reverse network. The forward network processes the input sequence in chronological order, while the reverse network processes the input sequence in reverse chronological order. Finally, the hidden states from both directions are concatenated. This structure can simultaneously capture both historical and future information from charging data, making it suitable for scenarios requiring more comprehensive modeling of charging demand.
[0075] In another optional implementation, the Long Short-Term Memory (LSTM) network in step C2 can also employ a multi-layer stacked structure. Multiple LSM network layers are stacked sequentially, with the hidden state output of the previous layer serving as the input to the next layer, forming a deep LSM network. This multi-layer stacked structure can extract higher-level temporal features, enhancing the model's ability to express complex charging patterns and making it suitable for scenarios with complex temporal relationships in charging data.
[0076] In this embodiment of the application, S4, the time series feature data is input into the attention mechanism module, the attention score of each time node in the time series feature data is calculated, and the context vector is obtained.
[0077] The steps to obtain the context vector include D1~D5: D1. Calculate the hidden state at the current time. Source state at each time step Similarity score between them: ; Among them, W a U a b a These are learnable parameters.
[0078] In this embodiment, the attention mechanism is used to focus on important parts of the Long Short-Term Memory (LSTM) network output, enabling the model to focus on key nodes in the time series that have a significant impact on the prediction results. Current hidden state. The hidden states output by the Long Short-Term Memory network in step S3, and the source states at each time step. This represents the output state of the Long Short-Term Memory network at various historical moments. This is achieved through a learnable parameter matrix. and Perform linear transformations on the current hidden state and the source states at each time step, sum the transformation results, and then add a bias. The hidden state is then processed using the tanh activation function to obtain the similarity score between the current hidden state and the source states at each time step. This similarity score reflects the importance of information from each historical time step to the prediction at the current time step.
[0079] D2. Perform softmax normalization on the similarity scores to obtain the attention scores. : ; Specifically, the softmax function converts the similarity scores into attention scores in the form of a probability distribution. For the current time t, its similarity scores with all historical times t' are input into the softmax function, which is calculated using the following formula: The denominator is the sum of the exponents of the similarity scores at all historical moments. After softmax normalization, all attention scores... The value of the attention score ranges from 0 to 1, and the sum of all attention scores is 1. The larger the attention score, the greater the contribution of information from the corresponding historical moment to the prediction at the current moment.
[0080] D3. Calculate the weighted sum of the source states at each time step based on the attention scores to obtain the context vector. : ; In this embodiment, the attention score obtained in step D2 is used as the combination coefficient of the source states at each time step, and a weighted sum is performed on the source states at all historical time steps. Historical time steps with higher attention scores have a larger weight in the weighted sum, while historical time steps with lower attention scores have a smaller weight. Through this weighted summation operation, the information from each historical time step is aggregated according to its importance to obtain the context vector. This context vector contains historical information most relevant to the current moment's prediction, effectively capturing key patterns in the charging demand time series.
[0081] D4. Transfer the context vector Hidden state at the current moment After being concatenated, the data is input into a fully connected layer to calculate the predicted charging demand. : ; in, The connection coefficients of the fully connected layer. This is the bias for the fully connected layer.
[0082] Specifically, the context vector Hidden state at the current moment The features are concatenated along the feature dimension to form a joint feature vector that contains information about the current moment and key historical information. The joint feature vector is input into a fully connected layer. The fully connected layer performs a linear transformation on the joint feature vector through the connection coefficient matrix Wfc, and after adding the bias vector bfc, it outputs the predicted charging demand value. This forecast value represents the predicted electric vehicle charging demand at the current moment.
[0083] D5. Train the model using the mean squared error loss function: Where N is the sample size. For the true value, These are predicted values.
[0084] In this embodiment, the mean squared error loss function is used to measure the difference between the model's predicted value and the true value. For N samples in the training dataset, the predicted value for each sample is calculated separately. Compared with the true value The difference between the samples is squared, summed, and then divided by the sample size N to obtain the average loss value. During model training, the gradient of the loss function with respect to the parameters of each layer is calculated using the backpropagation algorithm, and the network parameters are updated using an optimization algorithm. The parameter update formula is as follows: Where η is the learning rate. Through multiple rounds of iterative training, the loss function value gradually decreases, and the model's prediction accuracy gradually improves.
[0085] In an optional implementation, the similarity score calculation in step D1 can also employ a dot product attention mechanism. The dot product attention mechanism directly calculates the dot product between the current hidden state and the source states at each time step as the similarity score, using the following formula: ,in, The dimension of the hidden state, divided by This is used to scale the dot product result to prevent the value from becoming too large. The dot product attention mechanism is computationally efficient and suitable for charging data prediction scenarios with long sequence lengths.
[0086] In another alternative implementation, the model training in step D5 can also employ the mean absolute error loss function. The formula for calculating the mean absolute error loss function is as follows: This loss function is less sensitive to outliers. When there are a few extreme values in the charging data, the mean absolute error loss function can achieve more stable training results.
[0087] In this embodiment of the application, S5, the context vector is concatenated with the hidden state output by the long short-term memory network, and input into the fully connected layer for calculation, and the electric vehicle charging demand prediction result is output.
[0088] Specifically, step S5 is the model's prediction output stage, where the context vector obtained in step S4 is... The hidden state at the current time of the output of the Long Short-Term Memory network in step S3 Feature concatenation is performed to form a joint feature representation that integrates temporal modeling information and attention-focusing information. This joint feature representation is then input into a fully connected layer, which performs a nonlinear mapping on the joint features, transforming the high-dimensional feature space into a charging demand prediction space, and outputting the final electric vehicle charging demand prediction result.
[0089] In this embodiment, the trained model can be used to predict the charging demand of electric vehicles in future periods. After processing the charging data for the period to be predicted through steps S1 (data processing), S2 (spatiotemporal feature extraction via convolutional neural network), S3 (time series modeling via long short-term memory network), and S4 (attention mechanism calculation), the predicted charging demand for that period is output through a fully connected layer. This prediction result can provide data support for charging facility operators, optimize the layout of charging pile resources, improve the utilization rate of charging facilities, and reduce construction and operation costs.
[0090] In summary, an electric vehicle charging demand prediction model was constructed by integrating convolutional neural networks, long short-term memory networks, and attention mechanisms. Convolutional neural networks effectively extract spatiotemporal features from charging data, capturing charging distribution patterns across different time periods. Long short-term memory networks model time-series data through gating mechanisms, capturing the short- and long-term dependencies in charging demand, thus overcoming the shortcomings of traditional prediction models in handling long-term dependencies. The attention mechanism enables the model to focus on key nodes in the time series, improving the accuracy of charging demand prediction. In the data processing stage, this invention employs a missing data imputation method combining Lagrange interpolation and a multivariate autoregressive embedding model, as well as an outlier removal method based on isolated forests, ensuring high-quality and consistent input data and providing a solid foundation for the stable operation of the deep learning model.
[0091] Example 3 illustrates an illustrative scheme for an electric vehicle charging demand forecasting method. It should be noted that the technical solution of this electric vehicle charging demand forecasting system belongs to the same concept as the technical solution of the electric vehicle charging demand forecasting method described above. Details not described in detail in this embodiment can be found in the description of the technical solution of the electric vehicle charging demand forecasting method described above.
[0092] This embodiment also provides an electric vehicle charging demand prediction system, including: The data processing module is used to collect the raw charging data of the charging station, perform missing data repair, abnormal data removal and normalization on the raw charging data, and output the preprocessed charging data. The spatiotemporal feature extraction module is used to receive the preprocessed charging data, perform convolution and pooling operations on the preprocessed charging data through a convolutional neural network, and output spatiotemporal feature data. The time series modeling module is used to receive the spatiotemporal feature data, perform time series modeling on the spatiotemporal feature data through a long short-term memory network, and output the time series feature data and hidden states. The attention calculation module is used to receive the time series feature data, calculate the attention score at each time node and perform a weighted summation, and output the context vector; The prediction output module is used to concatenate the context vector with the hidden state, calculate and output the electric vehicle charging demand prediction result through a fully connected layer.
[0093] This embodiment also provides an electronic device suitable for electric vehicle charging demand forecasting, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the electric vehicle charging demand forecasting method proposed in the above embodiment.
[0094] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements the electric vehicle charging demand prediction method proposed in the above embodiments.
[0095] The storage medium proposed in this embodiment belongs to the same inventive concept as the method for predicting electric vehicle charging demand proposed in the above embodiments. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0096] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0097] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for predicting electric vehicle charging demand, characterized in that, Includes the following steps: Collect raw charging data from the charging station, process the raw charging data, and obtain preprocessed charging data. The preprocessed charging data is input into a convolutional neural network for spatiotemporal feature extraction to obtain spatiotemporal feature data. The spatiotemporal feature data is input into a long short-term memory network for time series modeling to obtain time series feature data; The time series feature data is input into the attention mechanism module to calculate the attention score for each time node in the time series feature data, and the context vector is obtained. The context vector is concatenated with the hidden state output by the long short-term memory network, and then input into a fully connected layer for calculation, outputting the electric vehicle charging demand prediction result.
2. The electric vehicle charging demand forecasting method as described in claim 1, characterized in that, The steps for processing the raw charging data include: The original charging data is repaired by filling in missing data to obtain the repaired charging data; The repaired charging data is subjected to abnormal data removal to obtain cleaned charging data; The post-cleaning charging data is normalized and scaled to a preset range to obtain the pre-processed post-charging data.
3. The electric vehicle charging demand forecasting method as described in claim 2, characterized in that, The original charging data is repaired by removing missing data to obtain repaired charging data, including: Identify missing data points in the original charging data; The missing data points are initially filled by constructing an interpolation polynomial until the function value of the interpolation polynomial at the known data points is equal to the actual value of the known data points, thus obtaining the initial interpolated charging data. The preliminary interpolated charging data is input into a multivariate autoregressive embedding model, and the preliminary interpolated charging data is mapped to the latent space through the embedding matrix to obtain the latent state data. An autoregressive model is established in the potential space to iteratively predict the potential state data; The predicted potential state data is reconstructed into time series data by reconstructing the matrix, thus obtaining the repaired charging data.
4. The electric vehicle charging demand forecasting method as described in claim 3, characterized in that, The steps for removing abnormal data from the repaired charging data to obtain cleaned charging data include: Multiple isolated trees are constructed using the repaired charging data. Each isolated tree recursively splits the data by randomly selecting features and randomly selecting split values. For each data point in the repaired charging data, the path length of the data point is calculated in each isolated tree, where the path length is the number of splits required to reach the leaf node where the data point is located from the root node. Calculate the average path length of each data point across all isolated trees; Calculate the anomaly score for each data point based on the average path length; Data points with abnormal scores greater than a preset threshold are identified as abnormal data points and removed to obtain the cleaned charging data.
5. The electric vehicle charging demand forecasting method as described in claim 4, characterized in that, The steps for obtaining the spatiotemporal feature data include: The preprocessed charging data is then input into the input layer of the convolutional neural network. In the convolutional layer, multiple convolutional kernels are used to perform convolution operations on the preprocessed charging data to extract local features at different levels, and the output feature map of the convolutional layer is obtained after processing by the ReLU activation function. The convolutional layer output feature map is input into the pooling layer. The spatial dimension of the convolutional layer output feature map is reduced by the pooling operation to obtain the pooled feature map. The pooled feature map is flattened into a one-dimensional vector and input into a fully connected layer for feature combination to obtain the spatiotemporal feature data.
6. The electric vehicle charging demand forecasting method as described in claim 5, characterized in that, The steps for obtaining the time series feature data include: The spatiotemporal feature data are input into the Long Short-Term Memory network in chronological order. At each time t, the Long Short-Term Memory network performs the following calculations: Calculate the output of the forget gate using the forget gate. : ; Calculate the input gate output using the input gate. : ; Calculate candidate cell state : ; Update cell state : ; Calculate the output of the output gate by the output gate. : ; Calculate the hidden state at the current time. : ; in, For the current input, This is the hidden state from the previous moment. This represents the cell state at the previous moment. is the sigmoid activation function, and tanh is the hyperbolic tangent activation function. , , , These are the connection coefficients for the forget gate, input gate, candidate cell state, and output gate, respectively. , , , These are the corresponding biases; Hidden states at each time point The time series feature data is output as the output.
7. The electric vehicle charging demand forecasting method as described in claim 6, characterized in that, The steps for calculating the attention score at each time point in the time series feature data to obtain the context vector include: Calculate the hidden state at the current time. Source state at each time step Similarity score between them: ; Among them, W a U a b a These are learnable parameters; The similarity scores are then subjected to softmax normalization to obtain the attention scores. : ; The context vector is obtained by weighted summation of the source states at each time step based on the attention scores. : ; The context vector Hidden state at the current moment After being concatenated, the data is input into a fully connected layer to calculate the predicted charging demand. : ; in, The connection coefficients of the fully connected layer. For biasing the fully connected layer; The model is trained using the mean squared error loss function: Where N is the number of samples, For the true value, These are predicted values.
8. An electric vehicle charging demand forecasting system, employing the method described in any one of claims 1-7, characterized in that, include: The data processing module is used to collect the raw charging data of the charging station, perform missing data repair, abnormal data removal and normalization on the raw charging data, and output the preprocessed charging data. The spatiotemporal feature extraction module is used to receive the preprocessed charging data, perform convolution and pooling operations on the preprocessed charging data through a convolutional neural network, and output spatiotemporal feature data. The time series modeling module is used to receive the spatiotemporal feature data, perform time series modeling on the spatiotemporal feature data through a long short-term memory network, and output the time series feature data and hidden states. The attention calculation module is used to receive the time series feature data, calculate the attention score at each time node and perform a weighted summation, and output the context vector; The prediction output module is used to concatenate the context vector with the hidden state, calculate and output the electric vehicle charging demand prediction result through a fully connected layer.
9. An electronic device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the electric vehicle charging demand prediction method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the electric vehicle charging demand prediction method according to any one of claims 1 to 7.