Traffic flow generation method based on structural causal model
Through the traffic flow generation method based on structural causal model, the variable autoencoder and graph neural network are used for causal reasoning and prediction, the problem of insufficient causal distribution and insufficient prediction accuracy in the existing technology is solved, and more accurate causal modeling and higher prediction accuracy are achieved.
Patent Information
- Application Number
- CN202510207138.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-06-13
AI Technical Summary
The prior art is difficult to capture complex causal relationships and the influence of multiple factors in the prediction of people flow, resulting in insufficient causal distribution and insufficient prediction accuracy.
The traffic flow generation method based on structural causal model is adopted to collect and preprocess urban traffic operation data, and a causal reasoning generation model is established, including observation, intervention and counterfactual fitting processing, and a variational autoencoder and graph neural network are used for causal reasoning and prediction.
Effectively capture and fit complex constraints in the causal graph, improve the accuracy of causal relationship modeling, improve the accuracy and reliability of counterfactual reasoning, and enhance the interpretability of the model.
Smart Images

Figure CN120146270A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of causal reasoning and causal learning, and particularly relates to a traffic flow generation method based on a structural causal model. Background Art
[0002] In modern urban management and planning, pedestrian flow prediction is a key issue. Accurate pedestrian flow prediction can help merchants optimize resource allocation, improve service efficiency, and also provide decision-making support for urban planning and traffic management. Traditional pedestrian flow prediction methods mainly rely on statistical methods such as time series analysis and regression analysis. Although they can reflect the changing trend of pedestrian flow to a certain extent, it is often difficult to capture complex causal relationships and the influence of multiple factors.
[0003] As an emerging modeling method, the structural causal model has gradually attracted the attention of researchers. By clarifying the causal relationships between variables, the structural causal model can better understand and predict dynamic changes in complex systems. In pedestrian flow prediction, the structural causal model can consider the interaction of multiple factors, thus providing more accurate and reliable prediction results.
[0004] However, due to the complex causal relationships involved in causal reasoning and the high data dimension, applying causal theory to actual data reasoning still faces many challenges: (1) The fitting difficulty of causal graph constraints is large. In causal reasoning, intervention operations will change the causal paths in the causal graph, and existing models face great challenges in fitting the constraints of these causal graphs. Especially in complex systems, the model needs to accurately simulate the impact of intervention operations on causal relationships to generate an accurate intervention distribution. (2) It is difficult to decouple exogenous variables in counterfactual scenarios. Counterfactual reasoning requires decoupling exogenous variables in a specific context to generate a counterfactual distribution. However, the diversity and complexity of exogenous factors in different contexts make it difficult to effectively decouple these variables. When existing methods handle counterfactual reasoning, it is often difficult to accurately decouple exogenous factors, thus affecting the generation effect of the counterfactual distribution. Summary of the Invention
[0005] In view of the above problems, the present invention provides a traffic flow generation method based on a structural causal model, which solves the technical problems of inaccurate causal distribution and low prediction accuracy in pedestrian flow prediction in the prior art.
[0006] The present invention provides a traffic flow generation method based on a structural causal model, including the following steps: Step S1, collect urban traffic operation data, preprocess the urban traffic operation data, and establish a standard data set; Step S2: Establish a causal inference generation model based on the structural causal model, and the causal inference generation model performs observational, interventional, and counterfactual fitting processing on the structural causal model of the urban traffic operation data; Step S3: Use the standard data set to train the causal inference generation model; Step S4: Input the historical urban traffic operation data to be generated into the trained causal inference generation model to obtain the generated pedestrian flow.
[0007] Preferably, step S1 specifically includes: Step S1-1: Collect urban traffic operation data, where the urban traffic operation data includes the number of people getting on and off bicycles, the number of people getting on and off taxis, the number of people getting on and off buses, time, the corresponding weather, and the overall traffic speed; Step S1-2: Standardize the number of people getting on and off bicycles, the number of people getting on and off taxis, and the number of people getting on and off buses in each time period respectively to obtain the standardized pedestrian flow in each time period; Step S1-3: Use the standardized pedestrian flow in each time period, the corresponding weather information, and the overall traffic speed information as the standard data set.
[0008] Preferably, in step S1-2, the standardization process specifically includes: normalizing the number of people getting on and off bicycles, the number of people getting on and off taxis, and the number of people getting on and off buses respectively.
[0009] Preferably, in step S2, the causal inference generation model is established by an observational distribution fitting module, an interventional distribution fitting module, and a counterfactual distribution fitting module, and specifically includes: Step S2-1: Establish an observational distribution fitting module, and the observational distribution fitting module fits the data distribution of the standard data set to obtain an observational distribution; Step S2-2: Establish an interventional distribution fitting module, and the interventional distribution fitting module intervenes in the constraints generated by the causal graph corresponding to the data in the standard data set based on the observational distribution to obtain an interventional distribution; Step S2-3: Establish a counterfactual distribution fitting module, and the counterfactual distribution fitting module performs exogenous variable decoupling and instance intervention based on the interventional distribution to obtain the generated pedestrian flow.
[0010] Preferably, the process of establishing the causal graph by the structural causal model specifically includes: Use the standardized pedestrian flow in each time period in the standard data set, the corresponding weather information, and the overall traffic speed information as endogenous variables; use the city and landform where the data in the standard data set is located as exogenous variables; Taking the endogenous variables as nodes and connecting them to form a preset directed edge, the causal graph is finally obtained.
[0011] Preferably, in step S2-1, the calculation expression of the observation distribution fitting module is:
[0012] where is the observation distribution, p(Z) is the latent variable distribution of the data in the standard dataset, Z is the set of latent variables, A is the causal graph corresponding to the data in the standard dataset, is a graph neural network with
[0013] Preferably, in step S2-2, the causal graph A corresponding to the data in the standard dataset and the set of endogenous variables of the observation distribution are intervened to obtain the intervened causal graph and the intervened set of endogenous variables ; The calculation expression of the intervention distribution fitting module is:
[0014] where is the intervention distribution, represents the set of intervened latent variables, is a graph neural network with
[0015] Preferably, in step S2-3, the calculation expression of the counterfactual distribution fitting module is:
[0016] where represents the generated counterfactual data, i.e., the generated pedestrian flow, represents the set of endogenous variables of a given instance.
[0017] Preferably, step S3 specifically includes: Taking the minimization of the loss function as the optimization direction, the model parameters are updated by using the gradient descent method to complete the training of the causal inference generation model.
[0018] Compared with the prior art, the present invention has at least the following beneficial effects: (1) Based on the variational autoencoder and the graph neural network, the present invention adjusts the graph neural network to realize causal inference and prediction for different data and causal graphs, and can effectively capture and fit the complex constraints in the causal graph, making the causal relationship modeling more accurate.
[0019] (2) Through counterfactual distribution generation and fitting, the present invention uses a neural network to simulate intervention operations and combines exogenous variable decoupling technology, enabling the separation of the influence of exogenous variables from specific instances and improving the accuracy and reliability of counterfactual reasoning.
[0020] (3) Through the structural causal model and the graph neural network, the present invention can clearly model the causal relationships between variables, making the reasoning process of the model more transparent and understandable, thereby improving the interpretability of the model. Description of the Drawings
[0021] The drawings are only for the purpose of showing specific embodiments and are not considered to be a limitation of the present invention.
[0022] Figure 1 It is a flowchart of the traffic flow generation method based on the structural causal model provided by the present invention; Figure 2 It is a schematic diagram of the causal graph in the structural causal model provided by the present invention.
[0023] Figures 3(a), 3(b), 3(c) and 3(d) are schematic diagrams of different causal graphs and their corresponding network architectures provided by the present invention.
[0024] Figure 4 It is a schematic diagram of the observation distribution fitting model architecture provided by the present invention.
[0025] Figure 5 It is a schematic diagram of the intervention fitting model architecture provided by the present invention.
[0026] Figure 6 It is a schematic diagram of the counterfactual distribution fitting model architecture provided by the present invention.
[0027] Reference Signs: 401 - Graph neural network with parameters of, 402 - Set of latent variables Z, 403 - Causal graph A corresponding to the data in the standard dataset, 404 - Observation distribution, 501 - Graph neural network with as parameters, 503 - Set of endogenous variables after intervention , 504 - Causal graph after intervention , 505 - Set of latent variables after intervention , 507 - Intervention distribution , 604 - Set of endogenous variables of a given instance , 606 - Set of latent variables of a given instance , 610 - Generated counterfactual data. Detailed Embodiments
[0028] To better understand the above objects, features, and advantages of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. Additionally, the present invention can also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited by the specific embodiments disclosed below.
[0029] To illustrate the effectiveness of the method proposed by the present invention, the above technical solution of the present invention will be described in detail through a specific embodiment. A specific embodiment of the present invention, as Figure 1 shown, discloses a traffic flow generation method based on a structural causal model, and the specific implementation steps are as follows: Step S1: Collect urban traffic operation data, preprocess the urban traffic operation data, and establish a standard data set.
[0030] In this step, the present invention collects traffic travel information such as shared bicycle, taxi, and bus order information to statistically analyze the pedestrian flow data, standardizes the pedestrian flow data, statistically analyzes the pedestrian flow within each time period, and obtains the corresponding weather information and overall traffic speed, which are used as the standard data set.
[0031] The data format in the standard data set is a three-dimensional array of B*T*N, where B is the batch number, T is the time dimension, and N is the number of street nodes. It can include the following 5 endogenous variables: time and corresponding weather, the number of people getting on and off bicycles, the number of people getting on and off taxis, the number of people getting on and off buses, and the overall traffic speed. It can include the following exogenous variables: the city where the data is located, temperature, terrain, etc.
[0032] By establishing a standard data set, it is possible to collect pedestrian flow data and corresponding weather and overall traffic speed information, etc., providing historical data for subsequent model training.
[0033] Step S2: Establish a causal inference generation model based on a structural causal model, and the causal inference generation model performs observation, intervention, and counterfactual fitting processing on the structural causal model of the urban traffic operation data.
[0034] The present invention establishes a causal inference generation model based on a structural causal model, including an observation distribution fitting module, an intervention distribution fitting module, and a counterfactual distribution fitting module. Each distribution fitting module includes 1 to 2 encoders and a decoder. Inputting the data in the standard data set into the causal inference generation model can finally obtain the generated pedestrian flow information for predicting the pedestrian flow. The following separately introduces these three modules: (1) Observation distribution fitting module The observation distribution fitting module enables the inference generation model to learn the data distribution in the standard dataset through training.
[0035] A Structural Causal Model (SCM) is a mathematical model that describes causal relationships and can include endogenous variables, exogenous variables, and a causal graph. The endogenous variables are variables that are affected by other variables, and the exogenous variables are variables determined by external factors that are not affected by the endogenous variables. Using the endogenous variables and exogenous variables as nodes and connecting them with directed edges, the directed edges are used to represent the causal relationships between the endogenous variables and exogenous variables, and finally the causal graph is obtained.
[0036] In the present invention, the data in the standard dataset can be selected as the endogenous variables and exogenous variables. Specifically, time and corresponding weather, the number of people getting on and off bicycles, the number of people getting on and off taxis, the number of people getting on and off buses, and the overall traffic speed, etc. can be used as the endogenous variables; system inherent factors such as the city where it is located and the terrain, etc., which are not affected by the endogenous variables, can be used as the exogenous variables.
[0037] In the present invention, based on the causal information of existing domain knowledge and experience, the connection mode of the directed edges can be preset, and finally the causal graph in the structural causal model is obtained.
[0038] Figure 2 Shows the relationships between the nodes in the causal graph of the structural causal model. The set of endogenous variables is represented as , , represents the th endogenous variable. The set of exogenous variables is represented as , represents the i-th exogenous variable. As shown in the figure, when and j is not the parent node of i, and are independent of each other. Figure 2 In are the second exogenous variable and the third exogenous variable respectively, are the first endogenous variable, the second endogenous variable, and the third endogenous variable respectively.
[0039] In order to enable the model to better fit the causal relationships in the causal graph, the observation distribution p(X) generated by the observation distribution fitting module also needs to satisfy causal decomposition. Since in the neural network, the set of latent variables Z is approximately the same as the set of exogenous variables in the causal graph , the decoder is similar in function to the structural causal equation F. However, since each endogenous variable corresponding latent variable does not exactly correspond to the corresponding exogenous variable in the causal graph , but only captures all the information that cannot be explained by its parent variables . Therefore, the decoder does not need to approximate the structural causal equation. Since is determined by the parent variables and exogenous variables , the role of the decoder can be regarded as capturing the information in the exogenous variables and the parent variables that can affect . Since the space-based graph neural network can be regarded as a combination of message passing layers, the number of hidden network layers of the graph neural network is closely related to the message passing process. That is, in the space-based graph neural network, each layer is a message passing, which is also a causal path. Therefore, as shown in Figure 3(a), the causal graph connects causal nodes through directed edges to accurately express the causal relationship between variables 's ancestor nodes are and , where can directly affect and can also indirectly affect through , because only the information that the parent variables have an impact on the child variables needs to be captured. As shown in Figure 3(b), are the first latent variable, the second latent variable, and the third latent variable respectively. In the neural network, only one pointing to path is required. As shown in Figure 3(c). 's ancestor nodes are also and , but can only indirectly affect by affecting , that is has no direct causal relationship with . Also, because in the space-based graph neural network, each path represents a causal message passing, so in order to capture 's impact on , as shown in Figure 3(d), are the first hidden layer parameters, the second hidden layer parameters, and the third hidden layer parameters respectively. In the neural network, one hidden layer is required to capture 's causal relationship of indirectly affecting by affecting . Thus, when and only when the number of hidden layers in the decoder is greater than or equal to δ−1, the neural network can satisfy causal factorization, where δ is the length of the longest shortest path between any two endogenous nodes
[0040] Based on the above conclusion, the observed distribution in the neural network can be fitted as:
[0041] Among them, represents the distribution of the set of endogenous variables X given the set of latent variables Z and the causal graph A. , is the total number of endogenous variables, indicating the distribution of the endogenous variable given the set of latent variables Z and the causal graph A. is the model parameter.
[0042] The overall architecture of the observed distribution fitting module is as Figure 4 shown. The calculation process of this model can be expressed as:
[0043] Among them, is the observed distribution 404, p(Z) is the distribution of the set of latent variables of the data in the standard dataset, A is the causal graph 403 corresponding to the data in the standard dataset, is a graph neural network 401 with
[0044] As shown in , starting from the input data, the observed distribution fitting module first processes the input data according to the number of causal graph nodes to meet the requirements of the decoder input. Then, the set of latent variables 402 and the causal graph 403 corresponding to the data in the standard dataset are input into the graph neural network 401 with
[0045] as parameters. By adjusting the number of hidden layers to achieve causal information transmission between different nodes, the fitted observed distribution 404 is generated. As Figure 5 shown, the calculation process of the intervention distribution fitting module can be expressed as:
[0046] Among them, is the causal graph 504 after intervention, is the set of endogenous variables 503 after intervention, 505 is the set of latent variables after intervention, is a graph neural network with as parameters. By encoding the variables and causal graph after intervention, the set of latent variables after intervention is obtained. By decoding the latent variable distribution p(Z), the generated intervention distribution fitting result
[0047] For the causal graph A and the observed distribution Intervene on the set of endogenous variables to obtain the intervened causal graph 504 and the intervened set of endogenous variables 503. Then the parameter is The graph neural network 501 is used to extract the intervened set of latent variables 505. The set of latent variables 402 and the intervened set of latent variables 505 are input into the graph neural network with the parameter By adjusting the number of hidden layers, causal information transmission between different nodes is achieved, and a fitted intervened distribution 507 is generated.
[0048] (3) Counterfactual distribution fitting module As Figure 6 shown, the calculation process of the counterfactual distribution fitting module can be expressed as:
[0049] Among them, represents the set of endogenous variables 604 of a given instance, A represents the causal graph 403 of the data in the standard dataset, represents the intervened set of endogenous variables 503, represents the intervened causal graph 504. and respectively represent the graph neural network 401 with as the parameter and the graph neural network 501 with as the parameter. represents the generated counterfactual data 601, that is, the generated pedestrian flow.
[0050] The input data of the counterfactual distribution fitting module includes two parts: intervention and given instance. The data format is processed according to the number of causal graph nodes of the two respectively. Then, the encoder composed of the graph neural network extracts the latent variables of the intervention data and the instance data respectively, and obtains the distribution of the set of latent variables 606 of the given instance and the intervened set of latent variables 505. The intervention nodes in the set of latent variables 505 of the intervention are used to replace the intervention nodes in the set of latent variables 606 of the given instance, and are input into the graph neural network 401 with as the parameter. By adjusting the number of hidden layers, causal message passing is fitted to generate the final counterfactual data 601, that is, the generated pedestrian flow.
[0051] Step S3: Train the causal inference generation model using the standard dataset.
[0052] In some embodiments, for the causal inference generation model, the model parameters can be updated by minimizing the loss function as the optimization direction and using the gradient descent method to complete the training of the causal inference generation model. There are relatively mature training methods for various neural networks in the prior art, and the present invention does not limit the training method of the neural network.
[0053] Step S4: Input the historical urban traffic operation data to be generated into the trained causal inference generation model to obtain the generated traffic flow.
[0054] In the embodiments of the present invention, experimental verification is performed on the provided traffic flow generation method based on the structural causal model.
[0055] The Beijing Xicheng District traffic flow dataset is used to train the causal inference generation model. The time interval of the used Beijing Xicheng District pedestrian flow dataset is 30 minutes, and the dataset is divided into a training set (80%), a validation set (10%), and a test set (10%) in the time dimension. In this embodiment, the traffic flow after intervention is generated in groups of three hours.
[0056] Training is performed on the Linux operating system using an Intel(R) Core(TM) i9-10980XE CPU and a GeForce RTX3090 GPU. The batch processing parameter is set to 64, and the initial learning rate is set to 0.001.
[0057] The prediction results of the above embodiments are compared with the prior art, and regional pedestrian flow prediction is performed on the same dataset. The comparison results are shown in Tables 1 and 2. The average maximum difference (MMD), the estimated squared error of the mean (MeanE), the estimated squared error of the standard deviation (StdE), and the standard deviation of the squared error (SSE) are used to evaluate the generation results. The lower the error, the better the prediction effect. The present invention compares two prediction methods in the prior art.
[0058] The first one is MultiCVAE, which performs causal inference by fitting a conditional variational autoencoder to the conditions of the Markov decomposition implied by the causal graph.
[0059] The second one is CAREFL, which performs causal inference through autoregressive normalizing flow.
[0060] It can be clearly seen from the comparison results in Table 1 that the fitting effect of the traffic flow generation method based on the structural causal model proposed by the present invention is better than that of the prior art.
[0061] Table 1
[0062] Although the specific embodiments of the present invention depict various actions or steps in a particular order, this should be understood as requiring such actions or steps to be performed in the particular order shown or in a sequential order, or requiring all of the illustrated actions or steps to be performed to achieve the desired result. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although a number of specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single implementation. Conversely, the various features described in the context of a single implementation may also be implemented separately or in any suitable sub-combination in multiple implementations. As described above, the above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
[0063] As described above, the above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A traffic flow generation method based on a structural causal model, characterized in that: The following steps are involved: Step S1, collecting urban traffic operation data, preprocessing the urban traffic operation data, and establishing a standard data set; Step S2: establishing a causal reasoning generation model based on the structural causal model, wherein the causal reasoning generation model performs observation, intervention and counterfactual fitting processing on the structural causal model of the urban traffic operation data; Step S3, using the standard data set to train the causal reasoning generation model; Step S4: input the historical urban traffic operation data to be generated into the trained causal reasoning generation model to obtain the generated traffic flow.
2. The traffic flow generation method based on the structural causal model according to claim 1 is characterized in that: Step S1 specifically includes: Step S1-1, collecting urban traffic operation data, wherein the urban traffic operation data includes the city where the data is located, temperature, topography, bicycle boarding and disembarking flow, taxi boarding and disembarking flow, bus boarding and disembarking flow, time, corresponding weather and overall traffic speed; Step S1-2, standardizing the bicycle passenger flow, taxi passenger flow, and bus passenger flow in each time period to obtain a standardized passenger flow in each time period; Step S1-3, taking the standardized passenger flow in each time period and the corresponding weather information, the city where the data is located, temperature, topography and overall traffic speed information as the standard data set.
3. The traffic flow generation method based on the structural causal model according to claim 2 is characterized by: In step S1-2, the standardization process specifically includes: normalizing the bicycle boarding and disembarking flow, taxi boarding and disembarking flow, and bus boarding and disembarking flow respectively.
4. The traffic flow generation method based on the structural causal model according to claim 3 is characterized in that: In step S2, the causal reasoning generation model is established by the observation distribution fitting module, the intervention distribution fitting module and the counterfactual distribution fitting module, which specifically includes: Step S2-1, establishing an observation distribution fitting module, wherein the observation distribution fitting module fits the data distribution of the standard data set to obtain an observation distribution; Step S2-2, establishing an intervention distribution fitting module, wherein the intervention distribution fitting module intervenes in the constraints generated by the causal graph established by the structural causal model based on the observed distribution to obtain an intervention distribution; Step S2-3: establishing a counterfactual distribution fitting module, wherein the counterfactual distribution fitting module performs exogenous variable decoupling and instance intervention based on the intervention distribution to obtain a generated flow of people.
5. The traffic flow generation method based on the structural causal model according to claim 4 is characterized in that: The process of establishing a causal graph using the structural causal model specifically includes: The standardized passenger flow in each time period in the standard data set, as well as the corresponding weather information and overall traffic speed information are used as endogenous variables; the city and landform where the data in the standard data set are located are used as exogenous variables; The endogenous variables are used as nodes and the nodes are connected to form pre-set directed edges, and finally the causal graph is obtained.
6. The traffic flow generation method based on the structural causal model according to claim 5 is characterized in that: In step S2-1, the calculation expression of the observation distribution fitting module is: in, is the observed distribution, p(Z) is the latent variable distribution of the data in the standard data set, Z is the latent variable set, A is the causal graph corresponding to the data in the standard data set, So Graph neural network with parameters .
7. The traffic flow generation method based on the structural causal model according to claim 6 is characterized in that: In step S2-2, the causal graph A and the observed distribution corresponding to the data in the standard data set are The endogenous variable set is intervened to obtain the causal diagram after intervention and the set of endogenous variables after intervention ; The calculation expression of the intervention distribution fitting module is: in, is the intervention distribution, is the set of latent variables after intervention, So Graph neural network with parameters .
8. The traffic flow generation method based on the structural causal model according to claim 7 is characterized in that: In step S2-3, the calculation expression of the counterfactual distribution fitting module is: in, represents the generated counterfactual data, i.e., the generated traffic volume, Represents the set of endogenous variables for a given instance.
9. The traffic flow generation method based on the structural causal model according to claim 8 is characterized in that: Step S3 specifically includes: The training of the causal reasoning generation model is completed by minimizing the loss function as the optimization direction and updating the parameters of the causal reasoning generation model by gradient descent.