Traffic flow completion method and traffic flow prediction method
Through the combination of hybrid expert models and graph attention networks, the analysis and prediction challenges caused by the sparseness of traffic flow data are solved, achieving more accurate traffic flow completion and prediction, supporting real-time traffic management and future prediction.
Patent Information
- Application Number
- CN202510527023.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-07-18
AI Technical Summary
The sparseness of traffic flow data leads to challenges in traffic system analysis and prediction, and it is difficult for existing technologies to accurately complete and predict traffic flow in sparse scenarios.
A hybrid expert model is introduced for multi-dimensional analysis, including a gated network, multiple expert models and output layers, and the data to be supplemented is generated through sparse traffic data and the traffic flow is completed. A dynamic graph is constructed in combination with the graph attention network for prediction.
It achieves more accurate traffic flow completion and prediction in sparse scenarios, improves the integrity and accuracy of traffic data, and supports real-time traffic management and future traffic forecasts.
Smart Images

Figure CN120340253A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent transportation technology, and in particular, to a traffic flow completion method and a traffic flow prediction method. Background Art
[0002] In traffic management, the accuracy and integrity of traffic flow data are crucial for effective traffic planning and real-time management. However, due to the sparsity of data collection, traffic flow data is often incomplete, which poses significant challenges to the analysis and prediction of traffic systems. The sparsity of traffic flow data mainly stems from the limited coverage of sensors, data transmission problems, data storage problems, and the complexity of the dynamic traffic environment. Urban traffic flow data usually relies on sensors installed on roads and / or mobile devices on vehicles for collection. However, due to cost, technical limitations, or geographical conditions, the coverage of sensors is limited, resulting in insufficient data collection in some areas. During data transmission, data loss may occur due to network interruptions or device failures, and storage limitations may also cause some historical data to not be saved for a long time. In addition, the urban traffic system is a dynamically changing environment, and affected by factors such as weather and events (such as accidents and construction), traffic flow will change significantly. This dynamic nature makes it difficult to maintain continuous and complete data collection at certain times and locations.
[0003] Therefore, it is particularly necessary to complete the traffic flow. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide a traffic flow completion method and a traffic flow prediction method to introduce a mixture of experts model for multi-dimensional analysis of traffic data, so as to more accurately complete the traffic flow and achieve traffic flow completion in sparse traffic data scenarios.
[0005] In a first aspect, a traffic flow completion method is provided, and the method includes:
[0006] Obtain sparse traffic data;
[0007] Input the sparse traffic data into a mixture of experts model to determine the corresponding traffic data to be supplemented;
[0008] Complete the traffic flow according to the traffic data to be supplemented;
[0009] Wherein, the mixture of experts model includes a gating network, multiple expert models, and an output layer.
[0010] In a second aspect, a traffic flow prediction method is provided, and the method includes:
[0011] Generate a static graph corresponding to the traffic network;
[0012] Use a graph attention network to determine the correlation relationships among the elements in the static graph;
[0013] Construct a dynamic graph base map according to the correlation relationships;
[0014] Add the completed traffic flow to the dynamic graph base map to generate a corresponding dynamic graph, where the completed traffic flow includes sparse traffic data and traffic data to be supplemented, and the traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data;
[0015] Predict future traffic flow according to the dynamic graph.
[0016] In a third aspect, a traffic flow completion device is provided, and the device includes:
[0017] An acquisition module, configured to acquire sparse traffic data;
[0018] A determination module, configured to input the sparse traffic data into a mixture of experts model to determine corresponding traffic data to be supplemented;
[0019] A completion module, configured to complete the traffic flow according to the traffic data to be supplemented;
[0020] Wherein, the mixture of experts model includes a gating network, multiple expert models and an output layer.
[0021] In a fourth aspect, a traffic flow prediction device is provided, and the device includes:
[0022] A first generation module, configured to generate a static graph corresponding to a traffic network;
[0023] A determination module, configured to use a graph attention network to determine the correlation relationships among the elements in the static graph;
[0024] A construction module, configured to construct a dynamic graph base map according to the correlation relationships;
[0025] A second generation module, configured to add the completed traffic flow to the dynamic graph base map to generate a corresponding dynamic graph, where the completed traffic flow includes sparse traffic data and traffic data to be supplemented, and the traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data;
[0026] A prediction module, configured to predict future traffic flow according to the dynamic graph.
[0027] In a fifth aspect, an electronic device is provided, including a memory and a processor, where the memory is used to store one or more computer program instructions, and wherein the one or more computer program instructions are executed by the processor to implement the method as described in the first aspect or the second aspect above.
[0028] In a sixth aspect, a computer-readable storage medium is provided. A computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the method described in the first aspect or the second aspect above is implemented.
[0029] In a seventh aspect, a computer program product is provided, including a computer program / instructions. When the computer program / instructions are executed by a processor, the method described in the first aspect or the second aspect above is implemented.
[0030] The technical solution of the embodiment of the present invention is to obtain sparse traffic data, input the sparse traffic data into a mixture of experts model, determine the corresponding traffic data to be supplemented, and complete the traffic flow according to the traffic data to be supplemented. The mixture of experts model includes a gating network, multiple expert models, and an output layer. The above technical solution introduces a mixture of experts model to perform multi-dimensional analysis on traffic data, thereby more accurately completing the traffic flow and realizing traffic flow completion in the scenario of sparse traffic data. Description of the Drawings
[0031] Through the following description of the embodiments of the present invention with reference to the drawings, the above and other objects, features, and advantages of the present invention will become clearer. In the drawings:
[0032] Figure 1 It is a flowchart of the traffic flow completion method according to the embodiment of the present invention;
[0033] Figure 2 It is a flowchart of the sparse traffic data acquisition method according to the embodiment of the present invention;
[0034] Figure 3 It is a flowchart of the gating network processing method according to the embodiment of the present invention;
[0035] Figure 4 It is a data flow diagram within the mixture of experts model according to the embodiment of the present invention;
[0036] Figure 5 It is a flowchart of the traffic flow prediction method according to the embodiment of the present invention;
[0037] Figure 6 It is a schematic diagram of the traffic flow completion device according to the embodiment of the present invention;
[0038] Figure 7 It is a schematic diagram of the traffic flow prediction device according to the embodiment of the present invention;
[0039] Figure 8 It is a schematic diagram of the electronic device according to the embodiment of the present invention. Detailed Embodiments
[0040] The present application will be described based on embodiments, but the present application is not limited to these embodiments. In the following detailed description of the present application, some specific details are described in detail. Those skilled in the art can fully understand the present application without the description of these details. In order to avoid obscuring the essence of the present application, well-known methods, processes, flows, components, and circuits are not described in detail.
[0041] In addition, those of ordinary skill in the art should understand that the drawings provided herein are for illustrative purposes only, and the drawings are not necessarily drawn to scale.
[0042] Unless the context clearly requires otherwise, the words such as "including", "comprising", etc. throughout the application documents shall be construed in an inclusive sense rather than an exclusive or exhaustive sense; that is, it is the meaning of "including but not limited to".
[0043] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be construed as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise specified, the meaning of "a plurality" is two or more.
[0044] For the solutions described in this specification and the embodiments, if they involve personal information processing, they will all be processed on the premise of having a legal basis (such as obtaining the consent of the personal information subject, or being necessary for performing a contract, etc.), and will only be processed within the specified or agreed scope. If the user refuses to process personal information other than the necessary information required for the basic functions, it will not affect the user's use of the basic functions.
[0045] Figure 1 It is a flowchart of the traffic flow completion method according to an embodiment of the present invention. As Figure 1 shown, the traffic flow completion method includes the following steps:
[0046] Step S101, obtaining sparse traffic data.
[0047] Among them, sparse traffic data refers to spatio-temporally consistent data constructed based on the traffic data to be processed in a data sparse scenario. The traffic data to be processed refers to the initial road surface data collected by sensors, which usually depends on sensors installed on the road and / or mobile devices on vehicles for collection. The data collected by sensors may include road surface condition information, vehicle driving information, environmental information, etc., and the traffic data collected by different sensors may be different.
[0048] Figure 2 It is a flowchart of the sparse traffic data obtaining method according to an embodiment of the present invention. As Figure 2 shown, the sparse traffic data obtaining method includes the following steps:
[0049] Step S201, obtain the traffic data to be processed, where the traffic data to be processed includes time information and spatial information.
[0050] Step S202, according to the time information and the spatial information, match the corresponding traffic data to be processed with the road to construct sparse traffic data with consistent time and space.
[0051] The accuracy and diversity of traffic data are crucial for downstream tasks such as traffic prediction and traffic control. In order to better complete downstream tasks, it is first necessary to collect a large amount of traffic data to be processed. The traffic data to be processed usually comes with timestamp information, which is used to characterize the distribution of data in time to assist in analyzing the changing trends of traffic flow in different time periods. At the same time, the collected traffic data to be processed will also be spatially matched with the roads or road segments in the traffic road network. By combining the time information and spatial information of the traffic data to be processed, the traffic data to be processed is processed to construct sparse traffic data with consistent time and space, thus laying a data foundation for traffic flow completion.
[0052] In a possible implementation manner, before inputting the sparse traffic data into the mixture of experts model, it can also be preprocessed to convert the sparse traffic data into a data format that meets the input requirements of the mixture of experts model.
[0053] Optionally, the preprocessing operation can include discrete wavelet transform (DWT), which can perform multi-resolution analysis on the sparse traffic data. Specifically, the sparse traffic data is subjected to discrete wavelet transform to obtain components with multiple different resolutions.
[0054] Among them, DWT is a powerful mathematical tool that can decompose a signal into components of different scales and frequencies, thereby revealing the internal characteristics and patterns of the sparse traffic data. The basic principle of discrete wavelet transform is to process the data through a series of filters, decomposing the original signal into approximation coefficients and detail coefficients. The approximation coefficients represent the low-frequency or slow-changing part of the data, while the detail coefficients contain high-frequency or fast-changing information. This process can be represented by the following formula:
[0055] X dwt = DWT(X original )
[0056] where, X original is the original sparse traffic data, X dwtIs the data processed by DWT, which contains components of different resolutions. DWT allows the model to capture traffic patterns at different time scales. The low-frequency components are related to the changing trends of traffic flow (such as morning and evening rush hours), while the high-frequency components may be related to the flow changes caused by emergencies (such as traffic accidents). Applying a low-pass filter to the original signal and then performing downsampling to obtain the low-frequency approximation coefficient C J 。
[0057] C J =LPF(X original )↓
[0058] where LPF represents the low-pass filter and ↓ represents the downsampling operation. In this way, DWT helps to extract the key features of sparse traffic data, providing more abundant information for subsequent analysis and prediction.
[0059] Optionally, the preprocessing operation may further include embedding processing. The embedding processing aims to convert the sparse traffic data into a format suitable for processing by the mixture of experts model and enhance the ability of the mixture of experts model to capture the time information in the time series data. Specifically, the components corresponding to the sparse traffic data are subjected to embedding processing to obtain corresponding data vectors.
[0060] The embedding processing converts the multi-scale features obtained by DWT analysis into a five-dimensional vector, which can capture the key information of the sparse traffic data. The embedding layer learns to map the output of DWT to a low-dimensional space while retaining as many original data features as possible. The mathematical expression of this step is as follows:
[0061] E=f embed (X dwt )
[0062] where E represents the five-dimensional embedding vector, X dwt is the data processed by DWT, and f embed is the embedding function, which is usually implemented by a fully connected layer and can be expressed as:
[0063] E=W embed ·X dwt +b embed
[0064] Here, W embed is the weight matrix of the embedding layer, and b embed is the bias term.
[0065] Optionally, the preprocessing operation may further include position encoding. Specifically, the data vector is subjected to position encoding according to the spatial information of the sparse traffic data.
[0066] The positional encoding adds spatial information to the embedding vectors, which is crucial for understanding the spatio-temporal dependence of traffic flow. The positional encoding can be achieved through the following formula:
[0067] PE = pos enc (t)
[0068] where PE represents the positional encoding, t represents the time step, and pos enc is the positional encoding function. In the present invention, the positional encoding adopts a combination of sine and cosine functions to capture the periodic characteristics of the time series:
[0069]
[0070] For i = 0, 1, 2, 3, 4, they respectively correspond to the five dimensions of the embedding vector. The embedding vector and the positional encoding are fused to form the final feature representation, which will be input into the mixture of experts model. The feature fusion can be achieved through the following formula:
[0071] F = E + PE
[0072] where F represents the fused feature representation. Through the data feature engineering steps, this embodiment can provide high-quality input data for traffic flow completion and prediction, providing a solid foundation for achieving precise traffic management. The introduction of the embedding process and the positional encoding enables the model to more effectively capture the spatio-temporal characteristics of sparse traffic data, thereby improving the accuracy and real-time performance of downstream tasks based on traffic data.
[0073] Step S102, input the sparse traffic data into the mixture of experts model to determine the corresponding traffic data to be supplemented.
[0074] where the mixture of experts model includes a gating network, multiple expert models, and an output layer.
[0075] The mixture of experts model is an ensemble learning strategy that enhances the performance of the overall model by integrating the prediction results of multiple expert models. Each expert model is responsible for processing different parts or features of the data in the model system, while the gating network is responsible for dynamically allocating tasks to the corresponding expert models according to the characteristics of the input data. This structure not only enables the model to adapt to various complex data patterns but also improves the model's response ability to new situations. The core advantages of the mixture of experts model lie in its flexibility and adaptability. The expert models can be different types of machine learning models, such as decision trees, neural networks, or linear models, each of which is good at dealing with specific features or patterns in the data. The training of the mixture of experts model usually adopts the expectation-maximization algorithm or other optimization techniques, which enables the model to continuously adjust and improve to adapt to the distribution changes of the data. The scalability of this model allows adding or removing expert models according to requirements, or adjusting the complexity of the gating network to adapt to different sparse traffic data and the Journey to the West tasks completed based on sparse traffic data.
[0076] In this embodiment, the mixture of experts model can handle complex spatio-temporal dependencies and adapt to the dynamic changes of sparse traffic data. By combining the processing of multiple expert models and the intelligent routing of the gating network, efficient management and optimization of traffic flow can be achieved, providing a more accurate and real-time traffic flow completion scheme.
[0077] In a possible implementation, the gating network is used to select a suitable expert model for processing the sparse traffic data.
[0078] Figure 3 It is a flowchart of the gating network processing method according to an embodiment of the present invention. As Figure 3 shown, the gating network processing method includes the following steps:
[0079] Step S301, extract the feature vector of the sparse traffic data.
[0080] Step S302, respectively determine the selection probabilities of each expert model according to the extracted feature vector.
[0081] Step S303, determine the target expert models as the expert models with probabilities higher than a preset probability threshold.
[0082] Step S304, allocate corresponding weights to each of the target expert models according to the feature vector.
[0083] The Gate Network, as a key component of the mixture-of-experts model, is responsible for dynamically routing the input data (i.e., sparse traffic data) to the most suitable expert model. The introduction of the Gate Network is to improve the flexibility and adaptability of the model, ensuring that when dealing with sparse traffic data, the optimal processing path can be selected according to the characteristics of the data.
[0084] When implementing traffic flow prediction and traffic control in scenarios based on sparse traffic data, different time periods (such as peak hours and off-peak hours) and different traffic patterns (such as holidays and weekdays) may require different processing strategies. The Gate Network dynamically selects the most suitable expert model for processing by learning the characteristics of sparse traffic data.
[0085] The gating mechanism of the Gate Network can be expressed by the following formula:
[0086] G(X) = σ(W g X + b g )
[0087] where G(X) represents the output of the Gate Network, X is the sparse traffic data, W g is the learnable weight matrix, b g is the bias vector of the weight matrix, and σ is the activation function, usually the sigmoid function to ensure that the output is between 0 and 1, representing the probability of selecting a certain expert model.
[0088] The Gate Network assigns a weight to each expert model according to the characteristics of the input data, and these weights reflect the suitability of each expert to process the current input data. The selection of the expert model can be achieved by the following formula:
[0089]
[0090] where E is the final output, K is the number of expert models in the mixture-of-experts model, G k (X) is the gating weight of the k-th expert model, and E k (X) is the output of the k-th expert model.
[0091] The output of each expert model is weighted and summed through the weights of the Gate Network to obtain the final prediction result. This process can be expressed as:
[0092]
[0093] where O is the final output, α k is the normalized weight, and O k is the output of the k-th expert model.
[0094] The training objective of the gating network is to minimize the prediction error, which can be achieved through the following loss function:
[0095]
[0096] where Y i is the true value, O i is the model's predicted value, and N is the number of samples.
[0097] In a possible implementation, the expert model includes a temporal expert model, which is used to capture the temporal dependencies between the sparse traffic data.
[0098] Among them, the temporal expert model can be a temporal Transformer, which is specifically responsible for processing the time series features in the traffic flow data. The input data of the temporal Transformer are the features extracted by DWT (Discrete Wavelet Transform) and the feature vectors after embedding processing. Its input data contains the time series information of the traffic flow and the fixed-dimensional feature representations obtained through the embedding layer conversion.
[0099] Optionally, positional encoding is also added to the input to provide the order information of the time steps.
[0100] The output data of the temporal Transformer are a series of processed time step features, which not only contain the original time series information but also enhance the representation of key time points through the self-attention mechanism. These output features will be passed to the gating network for further expert selection and feature fusion.
[0101] Through its self-attention mechanism, the temporal Transformer can capture the dependencies between any two time points in the time series, regardless of their distance in the sequence. This ability is crucial for understanding the dynamic changes in traffic flow because it can identify the seasonality, periodicity of traffic patterns, and the mutations caused by special events. The self-attention layer of the temporal Transformer can be expressed as:
[0102]
[0103] where Q is the query matrix, K is the key matrix, V is the value matrix, and d k is the dimension of the key vector. This mechanism allows the model to consider all other time steps in the entire time series when processing the data of each time step, thereby capturing long-term dependencies.
[0104] In a possible implementation, the expert model includes a spatial expert model, which is used to capture the dynamic spatial correlation relationships between the sparse traffic data.
[0105] The spatial expert model adopts the Low-rank guided Sampling Graph Attention (LrSGAT), which is specifically used to capture the dynamic spatial correlation relationships in the traffic network. This expert model can not only identify the interactions of local neighborhood nodes, but also efficiently capture the global dependencies across regions through low-rank decomposition and hybrid sampling strategies, thus significantly improving the modeling ability of spatial features in complex traffic scenarios.
[0106] The input data of the spatial expert model includes data such as temporal features, frequency domain features, and / or spatio-temporal embeddings.
[0107] Among them, the temporal features come from the intermediate output of the Time Experts (T-Experts), including the low-frequency trend features and high-frequency event features extracted by the Multi-Head Self-Attention (MSAT). The frequency domain features are the low-frequency components (X l ) and high-frequency components (X h ) obtained by decomposing the original traffic data through discrete wavelet transform, which are used to enhance the perception of traffic flow fluctuation patterns. The spatio-temporal embedding is a data vector obtained by fusing time information, space information and through embedding processing, and its dimension is expanded through a Multi-Layer Perceptron (MLP) to form a high-dimensional spatio-temporal joint representation.
[0108] The output data of the spatial expert network is the updated node feature representation, which captures the dynamic spatial correlation relationships between nodes in the traffic network. These features are then used for dynamic graph generation, where the connection strength between nodes is weighted by attention coefficients, thus forming a dynamic graph reflecting the real-time traffic conditions. In the spatial GAT network, the update of node i can be expressed as:
[0109]
[0110] where α ij is the attention coefficient of node j to node i, W is the weight matrix, V j is the feature vector of node j, and σ is the non-linear activation function.
[0111] In a possible implementation, the output layer is a Multi-Layer Perceptron (MLP), which is used to integrate the output results of the target expert models according to the weights corresponding to the target expert models to obtain the traffic data to be supplemented.
[0112] The MLP is responsible for integrating the outputs from the gating network and generating the final traffic data to be supplemented. The design of the MLP output layer aims to enhance the model's prediction ability through non-linear transformation, ensuring the accuracy and reliability of the output results. The MLP output layer consists of multiple fully connected layers, each of which contains a weight matrix and a bias vector, and introduces non-linearity through non-linear activation functions. This enables the MLP to learn and simulate the complex relationships in traffic flow data. The calculation of the MLP output layer can be represented by the following formula:
[0113] H (l) =σ(W (l) H (l-1) +b (l) )
[0114] Where H (l) represents the output of the l-th layer, W (l) and b (l) are the weight matrix and bias vector of the l-th layer respectively, and σ is the sigmoid activation function.
[0115] The output of the gating network is input into the MLP output layer, and the MLP integrates these outputs by learning the weights and biases to generate the final prediction. This process can be expressed as:
[0116] O=MLP(G(X))
[0117] Where G(X) is the output of the gating network and O is the final output of the mixture of experts model.
[0118] The training objective of the MLP output layer is to minimize the prediction error. This is achieved by minimizing the loss function:
[0119]
[0120] Where (Y i is the true value, O i is the model prediction value, and N is the number of samples.
[0121] Optionally, the MLP can also be responsible for integrating the outputs from the gating network and generating information such as traffic flow prediction data, thereby implementing downstream tasks based on sparse traffic data.
[0122] Figure 4 This is the data flow diagram within the mixture of experts model of the embodiment of the present invention. As Figure 4 shown, the data flow within the mixture of experts model includes:
[0123] Step S401, performing discrete wavelet transform on the sparse traffic data to obtain components with multiple different resolutions.
[0124] Step S402: Embed the sparse traffic data to obtain corresponding data vectors.
[0125] Step S403: Embed components of multiple different resolutions to obtain corresponding data vectors.
[0126] Step S404: Input the data vectors into a gated network.
[0127] Step S405: Determine the input data for the time expert model.
[0128] Specifically, the gated network selects the time expert model from multiple expert models in the mixture of experts model as the target expert model and determines the input data for the time expert model.
[0129] Exemplarily, the input data for the time expert model is the data vector after position encoding, where the data vector here is the vector obtained after embedding based on the sparse traffic data and components of multiple different resolutions.
[0130] Step S406: Determine the input data for the space expert model.
[0131] Specifically, the gated network selects the space expert model from multiple expert models in the mixture of experts model as the target expert model and determines the input data for the space expert model.
[0132] Exemplarily, the input data for the space expert model is the data vector and the output data of the time expert model, where the data vector here is the vector obtained after embedding based on the sparse traffic data and components of multiple different resolutions.
[0133] Step S407: Input the output result of the time expert model into the space expert model.
[0134] Step S408: Input the output result of the space expert model into the output layer.
[0135] Step S409: Input the output result of the time expert model into the output layer.
[0136] Step S410: Output the weight input values corresponding to each target expert network determined by the gated network to the output layer.
[0137] Step S411: The output layer integrates the output results of each target expert model according to the weights corresponding to each target expert model, and obtains and outputs the traffic data to be supplemented.
[0138] Among them, the methods involved in the above data flow steps are detailed in the above embodiments and will not be elaborated here.
[0139] Step S103: Complete the traffic flow according to the traffic data to be supplemented.
[0140] The method of the embodiment of the present invention is to obtain sparse traffic data, input the sparse traffic data into a mixture of experts model, determine the corresponding traffic data to be supplemented, and complete the traffic flow according to the traffic data to be supplemented. Among them, the mixture of experts model includes a gating network, multiple expert models, and an output layer. The above method introduces a mixture of experts model to perform multi-dimensional analysis on traffic data, so as to more accurately complete the traffic flow and realize the traffic flow completion in the sparse traffic data scenario.
[0141] Figure 5 It is a flowchart of the traffic flow prediction method of the embodiment of the present invention. As Figure 5 shown, the traffic flow prediction method includes the following steps:
[0142] Step S501: Generate a static graph corresponding to the traffic network.
[0143] Among them, the static graph provides a structural framework for the subsequent generation of the dynamic graph. The static graph is usually composed of nodes and edges in the traffic network. Among them, the nodes represent various traffic entities in the city, such as roads, intersections, etc. The edges represent the connection relationships between the nodes, that is, the actual connections between the roads. These nodes and edges constitute the topological structure of the traffic network. The generation of the static graph not only depends on the existing traffic network structure, but also involves the predefined potential associations between the nodes.
[0144] The generation of the static graph includes element definition and weight assignment.
[0145] Element definition refers to the definition of various elements in the static graph. The elements include at least nodes and edges. The node definition is to determine all the nodes in the traffic network. Each node is assigned a unique identifier and stores its geographical location information. The edge definition is predefined based on map data or obtained by identifying frequent patterns in traffic flow data.
[0146] Weight assignment means that in the static graph, each edge can be assigned an initial weight, which can represent the road capacity, historical average flow, or other related attributes. These weights provide a benchmark for subsequent dynamic adjustment. The weight assignment can be implemented based on the following formula:
[0147] W ij =f(C ij ,T ij )
[0148] where, W ij is the weight of the edge between node i and node j, C ij is the road capacity, T ijis the historical average flow, and f is a function used to calculate the initial weight based on the road capacity and historical flow.
[0149] The static graph can be represented by the adjacency matrix A, where A ij indicates whether there is an edge between node i and node j, and the weight of the edge. If there is an edge between nodes i and j, then A ij = W ij ; if there is no edge, then A ij = 0.
[0150] Step S502, use the graph attention network to determine the association relationship between the elements in the static graph.
[0151] Among them, the graph attention network (Graph Attention Networks) is a graph neural network based on the attention mechanism. It captures the complex dependencies between nodes by dynamically assigning weights to each node in the static graph. This weight assignment is learned, enabling the model to adaptively focus on the most relevant information in the graph, thereby improving the prediction accuracy. The core advantage of the GAT network lies in its ability to adaptively aggregate the features of nodes. In traditional graph convolutional networks, the feature aggregation of nodes is based on fixed weights, while the GAT network allows the model to learn the relationship strength between nodes through the attention mechanism. This means that the model can handle structural changes in the graph more flexibly, such as sudden events or road construction in traffic flow, which may cause traditional fixed-weight methods to fail. In addition, the GAT network supports the multi-head attention mechanism, which enables the model to capture different relationship types between nodes from multiple perspectives. This multi-angle feature aggregation provides the model with richer information, enabling it to more accurately simulate the dynamic changes in the traffic network.
[0152] In the application of traffic flow completion, the GAT network can handle the complex interaction relationships between various nodes in the traffic network, such as roads and intersections. By aggregating the information of neighbor nodes, the GAT network forms a global representation of each node, which is crucial for understanding and predicting traffic flow changes. The introduction of the GAT network enables this patent to not only consider the characteristics of the nodes themselves but also the context information of the entire traffic network when processing traffic data, thereby assisting in achieving more accurate traffic flow completion and prediction.
[0153] Attention sampling is a key technology used to extract important spatial features from sparse and dynamic traffic data to generate an accurate graph structure.
[0154] In a possible implementation, Top-k Pooling and Random Group can be combined to dynamically adjust the attention weights between nodes, achieve low-rank and accurate graph construction, and optimize the generation of static and dynamic graphs. The main goal of attention sampling is to capture key nodes and their global influence in the traffic network while ensuring computational efficiency through a hybrid sampling strategy. The specific implementation steps are as follows:
[0155] Local attention calculation: Based on the static topology graph, calculate the local attention weights between nodes:
[0156]
[0157] Among them, represent the query vector and the key vector respectively, and d k is the scaling factor, represents the local attention feedback of the node at time t.
[0158] Significance scoring and hybrid sampling: Generate the node significance scoring matrix through the trainable scoring vector
[0159]
[0160] Based on the significance scoring, adopt a hybrid sampling strategy to select nodes. Among them, significance sampling refers to selecting the top S = [log N] nodes with the highest significance scores which represent the key hub nodes in the traffic network, and probability sampling refers to randomly selecting SS nodes from the remaining nodes according to the probability distribution to ensure that potential associated nodes are not ignored. The final sampled node set is
[0161] Then, generate the projection vector. Specifically, map the query vector Q t and the key vector K t of the sampled nodes to the projection vector and calculate the projection message M t through the self-attention mechanism
[0162]
[0163] where, V t is the value vector. The projection vector significantly reduces the computational complexity while retaining the global influence of the key nodes.
[0164] The low-rank guided re-attention mechanism further compresses and restores high-dimensional space features through low-rank decomposition technology, enhancing the model's ability to model global spatial dependencies. The implementation steps are as follows:
[0165] Low-rank decomposition and re-attention calculation: Project the vector and the projection message M t into the re-attention layer to generate a low-rank guided global attention representation:
[0166]
[0167] Among them, encapsulates the key state information of the current traffic network, which is used to restore the compressed global features.
[0168] Low-rank approximation and feature reconstruction. Specifically, through low-rank decomposition, the original high-dimensional space matrix is approximated as a low-rank representation:
[0169] X = uV T
[0170] where u and V are low-rank matrices. This design significantly reduces the computational complexity while retaining the global structural information of the traffic network.
[0171] Step S503, construct a dynamic graph base map according to the association relationship.
[0172] Step S504, add the completed traffic flow to the dynamic graph base map to generate a corresponding dynamic graph. The completed traffic flow includes sparse traffic data and traffic data to be supplemented. The traffic data to be supplemented is generated by the mixture of experts model according to the sparse traffic data.
[0173] Among them, the method for completing the traffic flow is detailed in the above embodiments and will not be elaborated here.
[0174] The dynamic graph is used to dynamically capture the spatio-temporal change characteristics of the traffic network. By dynamically adjusting the connection relationship between nodes and edges, a dynamic graph that can reflect the traffic flow in real time is generated. Its input mainly includes a static adjacency matrix (Static Adj) and a full attention mechanism (Full Attention). After embedding the input features, a dynamic graph is generated, and high-dimensional embedded features finally used for traffic flow prediction are output. The dynamic graph generation module constructs a dynamic graph structure reflecting the real-time traffic state through sampling attention vectors and low-rank decomposition technology. The implementation steps are as follows:
[0175] Based on the sampling attention vector and the adaptive matrix E adp , generate a semi-adaptive dynamic adjacency matrix The calculation formula is as follows:
[0176]
[0177] Among them, is the sampling attention matrix, E adp is dynamically generated by referring to the reference matrix E ref .
[0178] E adp The generation formula of is as follows:
[0179] E adp = toph(M t (E ref )) T ).
[0180] Among them, the toph() function zeros out the elements below the median value to ensure the sparsity and computational efficiency of the dynamic graph.
[0181] The generated dynamic graph can reflect the spatio-temporal state changes of the traffic network in real time and be directly used for downstream tasks (such as traffic flow prediction). Compared with the traditional static graph, the dynamic graph can better capture the non-stationarity in the traffic network and the impact of emergencies (such as congestion, accidents).
[0182] Step S505, predict the future traffic flow according to the dynamic graph.
[0183] It should be noted that the above traffic flow prediction method can be implemented by a model. Optionally, the expert model in the mixture of experts model further includes a traffic flow prediction expert model, and the prediction expert model is used to output the predicted future traffic flow based on the completed traffic flow and the above method.
[0184] In the traditional graph structure, the relationship between nodes and edges is static and it is difficult to adapt to the real-time changes of traffic flow. In this embodiment, by introducing the attention mechanism, the connection strength between nodes in the graph is dynamically adjusted to generate a dynamic graph that can reflect the real-time traffic conditions. This dynamic graph can not only capture the immediate interactions between nodes in the traffic network, but also predict future traffic flow changes, providing forward-looking decision support for traffic management. The spatial attention sampling mechanism plays a crucial role in the generation of the dynamic graph. By sampling the low-rank characteristics of spatial correlation, this traffic flow prediction expert model can identify the most critical nodes and edges in the traffic network, which are crucial for understanding the traffic flow distribution of the entire network. In this way, this traffic flow prediction expert model can accurately complete the missing traffic data while maintaining computational efficiency and generate a dynamic graph that reflects the actual traffic conditions.
[0185] In addition, the spatial attention sampling mechanism of this embodiment also serves the final output representation. By applying the sampled attention to dynamic graph generation, the traffic prediction expert model can provide a comprehensive context representation for each node, which not only contains the features of the node itself but also the information of its neighboring nodes. This context-aware representation is crucial for improving the accuracy of traffic flow prediction.
[0186] The method of the embodiment of the present invention is to generate a static graph corresponding to a traffic network, generate a corresponding static adjacency matrix according to the static graph, construct a corresponding dynamic graph base map according to the static adjacency matrix, add the complemented traffic flow to the dynamic graph base map to generate a corresponding dynamic graph. The traffic flow includes sparse traffic data and traffic data to be supplemented. The traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data, and the future traffic flow is predicted according to the dynamic graph. The above method can improve the accuracy of traffic flow complementation and the efficiency of dynamic graph generation in sparse scenarios. By using the mixture of experts model to complement the sparse traffic data, the accuracy of traffic flow prediction can be improved. At the same time, by dynamically generating and adjusting the dynamic graph of the traffic network according to the complemented traffic flow, the real-time traffic conditions can be intuitively reflected, which is crucial for real-time traffic management, emergency response, and future traffic flow prediction.
[0187] Figure 6 It is a schematic diagram of the traffic flow complementation device according to the embodiment of the present invention. As Figure 6 shown, the traffic flow complementation device includes:
[0188] An acquisition module 601, configured to acquire sparse traffic data.
[0189] A determination module 602, configured to input the sparse traffic data into a mixture of experts model to determine the corresponding traffic data to be supplemented.
[0190] A complementation module 603, configured to complement the traffic flow according to the traffic data to be supplemented.
[0191] Wherein, the mixture of experts model includes a gating network, multiple expert models, and an output layer.
[0192] The device of the embodiment of the present invention is used to acquire sparse traffic data, input the sparse traffic data into a mixture of experts model to determine the corresponding traffic data to be supplemented, and complement the traffic flow according to the traffic data to be supplemented. Wherein, the mixture of experts model includes a gating network, multiple expert models, and an output layer. The above device can more accurately complement the traffic flow by introducing a mixture of experts model to perform multi-dimensional analysis on traffic data, and realize traffic flow complementation in sparse traffic data scenarios.
[0193] Figure 7 It is a schematic diagram of the traffic flow prediction device according to the embodiment of the present invention. AsFigure 7 As shown, the traffic flow prediction device includes:
[0194] A first generation module 701 for generating a static graph corresponding to a traffic network.
[0195] A determination module 702 for using a graph attention network to determine the correlation relationships between various elements in the static graph.
[0196] A construction module 703 for constructing a dynamic graph base map according to the correlation relationships.
[0197] A second generation module 704 for adding the complemented traffic flow to the dynamic graph base map to generate a corresponding dynamic graph, where the complemented traffic flow includes sparse traffic data and traffic data to be supplemented, and the traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data.
[0198] A prediction module 705 for predicting future traffic flow according to the dynamic graph.
[0199] The device according to an embodiment of the present invention is used to generate a static graph corresponding to a traffic network, generate a corresponding static adjacency matrix according to the static graph, construct a corresponding dynamic graph base map according to the static adjacency matrix, add the complemented traffic flow to the dynamic graph base map to generate a corresponding dynamic graph, where the traffic flow includes sparse traffic data and traffic data to be supplemented, the traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data, and predict future traffic flow according to the dynamic graph. The above device is used to improve the accuracy of traffic flow complementation and the efficiency of dynamic graph generation in sparse scenarios. By using a mixture of experts model to complement sparse traffic data, the accuracy of traffic flow prediction can be improved. At the same time, generating and adjusting the dynamic graph of the traffic network dynamically according to the complemented traffic flow can intuitively reflect the real-time traffic conditions, which is crucial for real-time traffic management, emergency response, and future traffic flow prediction.
[0200] Figure 8 It is a schematic diagram of an electronic device according to an embodiment of the present invention. As Figure 8 shown, Figure 8The electronic device shown is a traffic flow completion device and / or a traffic flow prediction device, which includes a general computer hardware structure, and at least includes a processor 801 and a memory 802. The processor 801 and the memory 802 are connected through a bus 803. The memory 802 is adapted to store instructions or programs executable by the processor 801. The processor 801 can be an independent microprocessor or a set of one or more microprocessors. Thus, by executing the instructions stored in the memory 802, the processor 801 implements the method flow of the embodiment of the present invention as above to process data and control other devices. The bus 803 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to a display controller 804, a display device, and an input / output (I / O) device 805. The input / output (I / O) device 805 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a body sense input device, a printer, and other devices well-known in the art. Typically, the input / output device 805 is connected to the system through an input / output (I / O) controller 806.
[0201] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a device, an apparatus, a computer-readable storage medium, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be implemented as a computer program product on one or more computer-readable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.
[0202] The present application is described with reference to the flowcharts of methods, devices (apparatuses), and computer program products according to the embodiments of the present application. It should be understood that each process in the flowchart can be implemented by computer program instructions.
[0203] These computer program instructions can be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, and the instruction device implements the process Figure 1 specified functions in one process or multiple processes.
[0204] These computer program instructions can also be provided to the processor of a general computer, a special computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices produce a device for implementing the Figure 1 specified functions in one process or multiple processes.
[0205] The technical solution of the embodiment of the present invention is to obtain sparse traffic data, input the sparse traffic data into a mixture of experts model, determine the corresponding traffic data to be supplemented, and complete the traffic flow according to the traffic data to be supplemented. The mixture of experts model includes a gating network, multiple expert models, and an output layer. The above technical solution introduces a mixture of experts model to perform multi-dimensional analysis on traffic data, so as to more accurately complete the traffic flow and realize the traffic flow completion in the sparse traffic data scenario.
[0206] Another embodiment of the present invention relates to a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it implements the above-mentioned partial or all method embodiments.
[0207] Another embodiment of the present invention relates to a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, they implement the above-mentioned partial or all method embodiments.
[0208] That is, those skilled in the art can understand that all or part of the steps in implementing the above-mentioned embodiment methods can be completed by specifying relevant hardware through a program. The program is stored in a storage medium, including several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the method embodiments of the present application. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical disks and other various media that can store program codes.
[0209] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A traffic flow completion method, characterized in that, The method includes: Obtaining sparse traffic data; Inputting the sparse traffic data into a mixture of experts model to determine corresponding traffic data to be supplemented; Completing the traffic flow according to the traffic data to be supplemented; Wherein, the mixture of experts model includes a gating network, multiple expert models, and an output layer.
2. The method according to claim 1, wherein The obtaining of the sparse traffic data includes: Obtaining traffic data to be processed, where the traffic data to be processed includes time information and spatial information; According to the time information and the spatial information, matching the corresponding traffic data to be processed with the traffic road network to construct spatio-temporally consistent sparse traffic data.
3. The method according to claim 1, wherein Before inputting the sparse traffic data into the mixture of experts model, the method further includes: Performing discrete wavelet transform on the sparse traffic data to obtain components with various different resolutions; Performing embedding processing on the components corresponding to the sparse traffic data to obtain corresponding data vectors.
4. The method according to claim 3, characterized in that The method further includes: Performing position encoding on the data vectors according to the spatial information of the sparse traffic data.
5. The method according to claim 1, wherein The gating network is used to select a suitable expert model for processing the sparse traffic data; The processing process of the gating network includes the following steps: Extracting the feature vector of the sparse traffic data; According to the extracted feature vector, respectively determining the probabilities of being selected for each expert model; Determining the expert models with probabilities higher than a preset probability threshold as target expert models; According to the feature vector, assigning corresponding weights to each of the target expert models.
6. The method according to claim 1, characterized in that, The expert model includes a time expert model, and the time expert model is used to capture the time dependence relationship between the sparse traffic data.
7. The method according to claim 1, wherein The expert model includes a spatial expert model, and the spatial expert model is used to capture the dynamic spatial correlation relationship between the sparse traffic data.
8. The method according to claim 5, characterized in that The output layer is a multi-layer perceptron, and the output layer is used to integrate the output results of each target expert model according to the weights corresponding to each target expert model to obtain the traffic data to be supplemented.
9. A traffic flow prediction method, characterized in that, The method includes: Generating a static graph corresponding to the traffic network; Using a graph attention network to determine the correlation relationship between the elements in the static graph; Constructing a dynamic graph base map according to the correlation relationship; Adding the completed traffic flow to the dynamic graph base map to generate a corresponding dynamic graph, where the completed traffic flow includes sparse traffic data and traffic data to be supplemented, and the traffic data to be supplemented is generated by the mixture of experts model according to the sparse traffic data; Predicting future traffic flow according to the dynamic graph.
10. A traffic flow completion device, characterized in that, The device includes: An obtaining module, configured to obtain sparse traffic data; A determining module, configured to input the sparse traffic data into a mixture of experts model to determine corresponding traffic data to be supplemented; A completing module, configured to complete the traffic flow according to the traffic data to be supplemented; Wherein, the mixture of experts model includes a gating network, multiple expert models, and an output layer.
11. A traffic flow prediction device, characterized in that The device includes: A first generating module, configured to generate a static graph corresponding to the traffic network; A determining module, configured to use a graph attention network to determine the correlation relationship between the elements in the static graph; A constructing module, configured to construct a dynamic graph base map according to the correlation relationship; A second generation module, configured to add the completed traffic flow to the dynamic map background to generate a corresponding dynamic map, wherein the completed traffic flow includes sparse traffic data and traffic data to be supplemented, and the traffic data to be supplemented is generated by a mixture of experts model according to the sparse traffic data; A prediction module, configured to predict future traffic flow according to the dynamic map.
12. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1-9.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1-9 is implemented.
14. A computer program product, comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the method according to any one of claims 1-9 is implemented.