Traffic flow prediction method, electronic equipment, storage medium and program product

By adopting a deep learning neural network model based on control differential equations in traffic flow prediction, the limitations of the existing technology in continuous time modeling and nonlinear problem processing are solved, and more efficient and adaptive traffic flow prediction is achieved.

CN119559803APending Publication Date: 2025-03-04TUS CLOUD CONTROL (BEIJING) TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411454858.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The existing traffic flow prediction technology has limitations in continuous time modeling, nonlinear problem handling and model generalization, and it is difficult to accurately capture the dynamic changes of traffic data and adapt to different environmental conditions.

Method used

A deep learning neural network model based on control differential equations is adopted to solve the state changes of traffic flow data over continuous time by controlling differential equation solver, and adjust the flow state through control functions to construct a time-dynamic adaptive traffic flow prediction model.

Benefits of technology

This model can capture continuous changes in time series data more naturally, improves the accuracy and adaptability of traffic flow predictions, and reduces the need for environmentally specific adjustments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119559803A_ABST
    Figure CN119559803A_ABST
Patent Text Reader

Abstract

The invention provides a traffic flow prediction method, electronic equipment, a storage medium and a program product. The method comprises the following steps: acquiring a traffic flow data set; preprocessing the traffic flow data set to obtain a time sequence enhanced data set; a traffic flow prediction model integrated with at least one control function and a control differential equation solver is constructed based on the control differential equation, and the control differential equation solver is used for solving the state change of the time sequence enhancement data set in continuous time through the control differential equation and adjusting the state change through the control function; inputting the training set into a traffic flow prediction model to obtain a traffic flow prediction result; and generating a loss value from the traffic flow prediction result and the label value through a loss function of the traffic flow prediction model, and updating the traffic flow prediction model according to the loss value until convergence so as to obtain a trained traffic flow prediction model. According to the invention, the continuous change of the time sequence data can be captured more naturally, so that the traffic flow can be predicted more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a traffic flow prediction method, electronic equipment, storage medium and program product. Background Art

[0002] In the field of traffic management and planning, accurate prediction of traffic flow is crucial to optimize traffic flow, reduce congestion and enhance road safety.

[0003] Existing traffic flow prediction technologies are mainly based on historical data analysis. The statistical models used in these technologies include: autoregressive moving average (ARMA) model, seasonal autoregressive integrated moving average model (SARIMA), and machine learning methods such as support vector machine (SVM) and random forest.

[0004] While these models are effective to a certain extent, they have several major flaws:

[0005] 1. Time discreteness processing: Most existing models process discrete time data, which makes it difficult to accurately capture the dynamic changes of flow data in continuous time. This makes the model less sensitive to sudden events or drastic changes in flow in a short period of time.

[0006] 2. Limited ability to handle nonlinear problems: Traffic flow changes are usually affected by multiple factors and are highly nonlinear. Existing models and some simple machine learning methods have limited effectiveness in handling complex nonlinear relationships.

[0007] 3. Insufficient model generalization ability: Most existing models require a lot of customization based on specific scenarios, which limits their adaptability and generalization ability in different or new environments. Summary of the invention

[0008] In view of the shortcomings of the prior art, the present invention provides a traffic flow prediction method, electronic device, storage medium and program product, aiming to solve the limitations of the existing traffic flow prediction technology in continuous time modeling, nonlinear problem processing and model generalization, so as to provide more accurate and reliable traffic flow prediction results.

[0009] In order to achieve the above purpose and other advantages, the present invention adopts the following technical solutions:

[0010] In a first aspect, the present invention provides a traffic flow prediction method, comprising:

[0011] Obtain a traffic flow data set, wherein the traffic flow data set is divided into a training set, a validation set, and a test set according to a preset ratio, and is used for model training, validation, and testing, respectively;

[0012] Preprocessing the traffic flow data set to obtain a time series enhanced data set;

[0013] A traffic flow prediction model is constructed based on a control differential equation, which integrates at least one control function and a control differential equation solver, wherein the control differential equation solver is used to solve the change of the flow state of the time series enhanced data set in continuous time through the control differential equation, and adjust the flow state through the control function;

[0014] Inputting the training set as input data into a traffic flow prediction model to obtain a traffic flow prediction result output by the traffic flow prediction model;

[0015] The traffic flow prediction result and the label value are subjected to the loss function of the traffic flow prediction model to generate a loss value, and the traffic flow prediction model is updated according to the loss value until convergence to obtain the trained traffic flow prediction model. During the training cycle of the traffic flow prediction model, the hyperparameters of the traffic flow prediction model are adjusted according to the fitting situation of the validation set.

[0016] According to a traffic flow prediction method provided by the present invention, the traffic flow prediction model comprises: an initialization layer, a linear layer and an output layer, wherein the linear layer is defined in the control function;

[0017] Inputting the input data into the initialization layer to extract feature data and time series information of the input data;

[0018] The linear layer extracts an initial hidden state and an initial feature state from the feature data as initial conditions of a control differential equation;

[0019] In the forward propagation process of the model, based on the initial conditions, time series information and the control function, the control differential equation solver is called to perform numerical solutions at different time points to obtain the flow state after time evolution, and the control function calculates the rate of change of the flow state in the time dimension to update the flow state, and the flow state includes: hidden state and characteristic state;

[0020] The output layer receives the traffic state and converts it into the final traffic flow prediction result.

[0021] According to a traffic flow prediction method provided by the present invention, when the control differential equation solver performs numerical solutions at different time points, the tolerance of absolute error and / or relative error is used to control the accuracy of the numerical solution.

[0022] According to a traffic flow prediction method provided by the present invention, the step of preprocessing the traffic flow data set to obtain a time series enhanced data set includes:

[0023] Performing data standardization processing on the traffic flow data set to obtain a first traffic flow data set;

[0024] The first traffic data set is expanded in time dimension by using window partitioning to obtain a second traffic data set;

[0025] The second traffic data set is subjected to data smoothing processing to obtain a third traffic data set, and the third traffic data set is used as a time series enhanced data set for model training, verification and testing.

[0026] According to a traffic flow prediction method provided by the present invention, the step of performing data standardization processing on the traffic flow data set to obtain a first traffic flow data set includes:

[0027] Calculating the mean and standard deviation of the traffic flow data set;

[0028] Based on the mean and the standard deviation, each data point of the traffic flow data set is converted into a standard score value, thereby obtaining the first traffic data set.

[0029] According to a traffic flow prediction method provided by the present invention, the step of performing time dimension expansion on the first traffic data set by using window partitioning to obtain a second traffic data set includes:

[0030] Generating input feature data and target output data for the training set, the validation set, and the test set, respectively, according to the set observation window and the prediction horizon;

[0031] Create a uniformly distributed time vector, use the observation window to scan the input feature data, splice the time vector with each input feature window in dimension to achieve time dimension expansion, and then obtain the second traffic data set to help the model understand the changing pattern of traffic flow at different time points or time periods.

[0032] According to a traffic flow prediction method provided by the present invention, the step of performing data smoothing on the second traffic data set to obtain a third traffic data set includes:

[0033] The second traffic data set is traversed, and discrete time points in the second traffic data set are smoothed into a continuous time curve using a cubic spline interpolation method, so that the time series in the data set is converted into continuous time information, thereby obtaining the third traffic data set.

[0034] In a second aspect, the present invention provides an electronic device, the electronic device comprising:

[0035] One or more processors; and a memory storing computer program instructions, wherein when the computer program instructions are executed, the processor performs the steps of any of the above-mentioned traffic flow prediction methods.

[0036] In a third aspect, the present invention provides a computer-readable storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements the steps of any of the above-described traffic flow prediction methods.

[0037] In a fourth aspect, the present invention provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of any of the traffic flow prediction methods described above.

[0038] The present invention provides a traffic flow prediction method, electronic device, storage medium and program product. The method comprises the following steps: obtaining a traffic flow data set, dividing the traffic flow data set into a training set, a validation set and a test set according to a preset ratio, and using them for model training, validation and testing respectively; preprocessing the traffic flow data set to obtain a time series enhanced data set; constructing a traffic flow prediction model based on a control differential equation and integrating at least one control function and a control differential equation solver, wherein the control differential equation solver is used to solve the state change of the time series enhanced data set in continuous time through the control differential equation, and adjusting the state change through the control function; inputting the training set as input data into the traffic flow prediction model to obtain a traffic flow prediction result output by the traffic flow prediction model; generating a loss value by using the loss function of the traffic flow prediction model to obtain the traffic flow prediction result and the label value, and updating the traffic flow prediction model according to the loss value until convergence, so as to obtain a trained traffic flow prediction model, and adjusting the hyperparameters of the traffic flow prediction model according to the fitting condition of the validation set during the training cycle of the traffic flow prediction model. The present invention constructs a time-dynamic adaptive deep learning neural network model based on the control differential equation, which can simulate the dynamic changes of data in continuous time, so that the model can more naturally capture the continuous changes of time series data, thereby more accurately predicting the short-term and long-term changes in traffic flow. At the same time, the control function constructed using the deep learning neural network can learn complex nonlinear dependencies, which makes the model more adaptable and accurate in prediction in a changing traffic environment. Moreover, compared with existing models, this model can maintain good performance in different traffic scenarios and conditions, reducing the need for environment-specific adjustments. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other implementation methods can be obtained based on these drawings without paying any creative work.

[0040] Figure 1 is a flow chart of a traffic flow prediction method provided by an embodiment of the present invention;

[0041] Figure 2 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0042] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following specifically cites a preferred embodiment and describes it in detail with the accompanying drawings as follows.

[0043] It should be noted that it is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present invention can be combined with other embodiments without conflict. Unless otherwise defined, the technical terms or scientific terms involved in the present invention should be the usual meanings understood by people with ordinary skills in the technical field to which the present invention belongs. The words "one", "a", "a", "the" and the like involved in the present invention do not indicate a quantitative limitation and may represent the singular or plural. The terms "including", "comprising", "having" and any of their variations involved in the present invention are intended to cover non-exclusive inclusions; the terms "first", "second", "third", etc. involved in the present invention are merely to distinguish similar objects and do not represent a specific ordering of objects.

[0044] To facilitate understanding of the embodiments of the present invention, the following is an explanation of the key terms / technical abbreviations in the present invention:

[0045] Governing differential equations (CDEs): Governing differential equations are a mathematical framework used to describe how the state of a system changes continuously over time and is affected by a series of control inputs. In machine learning, CDEs are often used to model data with time dependencies.

[0046] Neural Network Layer: Neural Network Layer is the basic unit of deep learning neural network model. Each layer consists of multiple neurons and can perform a series of computing tasks, such as linear transformation and nonlinear activation.

[0047] Non-linear Activation Function: In a neural network model, the activation function is used to introduce nonlinear factors, enabling the network to learn and represent complex data patterns. Common activation functions include ReLU, Sigmoid, and Tanh.

[0048] Reference Figure 1 As shown, an embodiment of the present invention provides a traffic flow prediction method, comprising:

[0049] Step S1: Obtain a traffic flow data set, which is divided into a training set, a validation set, and a test set according to a preset ratio, which are used for model training, validation, and testing, respectively.

[0050] In this step, traffic flow refers to the traffic flow from the starting area to the end area within a certain time period, that is, the number of traffic entities passing through a certain area, a certain road section or a certain lane within the selected time period. The traffic flow here can specifically include pedestrian flow, vehicle flow, mobile equipment flow, etc. This application does not make any restrictions on the specific objects corresponding to the traffic flow. Traffic flow data includes: pedestrian flow, vehicle flow and corresponding directions and speeds. Traffic flow data can be collected by roadside collection equipment such as video, radar, geomagnetic, ETC, ground sensor coils and other equipment, or the vehicle's motion data can be uploaded to the cloud server through a vehicle-mounted terminal with Internet of Vehicles function and traffic flow data can be generated by calculation. Traffic flow data can be stored in a specified data file (such as .npy or .csv files, etc.).

[0051] Use the Load_Dataset function to read data from the specified data file. These data files store lane traffic data sorted by time, and each record includes lane traffic counts, timestamps, and other information. Use the Load_Dataset function to load, ensuring that the data has the correct format and data type, ensuring that the timestamp format is uniform, and that the traffic counts are integers or floating point numbers.

[0052] The dataset will be divided into 80% training set, 20% validation set and 10% test set according to the set ratio. Ensure that the time order of the data is not destroyed, especially for time series data, maintaining time continuity is important to avoid data leakage and model overfitting.

[0053] Step S2: Preprocess the traffic flow dataset to obtain a time series enhanced dataset.

[0054] In this embodiment, step S2 specifically includes:

[0055] Step S201: performing data standardization processing on the traffic flow data set to obtain a first traffic flow data set, specifically including:

[0056] Step S2011: Calculate the mean and standard deviation of the traffic flow data set;

[0057] Step S2012: Based on the mean and standard deviation, each data point of the traffic flow data set is converted into a standard score value, thereby obtaining a first traffic flow data set.

[0058] Specifically, the traffic flow data is converted into a form more suitable for machine learning model processing, mainly by reducing the scale differences between data features through standardization methods, and improving the training efficiency and convergence speed of the model. First, the mean and standard deviation of the entire data set are calculated. For column normalization (column_wise = True), the mean and standard deviation of each feature (column) are calculated separately, which is suitable for situations where the scale differences between features are large; otherwise, the unified mean and standard deviation of the entire data set are calculated. Using the calculated mean and standard deviation, each data point is converted to a standard score: (data point - mean) ÷ standard deviation. After the conversion process, the mean of the data is 0 and the standard deviation is 1. The conversion process not only helps to deal with potential outliers, but also makes different features have the same scale, so that the model convergence is more stable when using optimization algorithms such as gradient descent.

[0059] Step S202: The first traffic data set is expanded in the time dimension by using window partitioning to obtain a second traffic data set, specifically including:

[0060] Step S2021: Generate input feature data and target output data for the training set, validation set, and test set, respectively, according to the set observation window and prediction horizon;

[0061] Step S2022: Create a uniformly distributed time vector, use the observation window to scan the input feature data, splice the time vector with each input feature window in dimension to achieve time dimension expansion, and then obtain a second traffic data set to help the model understand the changing pattern of traffic flow at different time points or time periods.

[0062] Specifically, through the windowing method, the model is able to learn relationships based on past information to predict future events. The windowing function accepts three parameters: the dataset, the window size, and the prediction horizon. The window size (lag) determines the length of historical data required to define the model input, and the prediction horizon (horizon) defines the future period to be predicted starting from the end point of the window. Therefore, for each time point t, the input features are the data from t-lag to t, and the target output is the data from t+1 to t+horizon. In this way, the model can predict the time series pattern of future traffic flow by learning from past traffic flow patterns. For the training set, validation set, and test set, the windowing division is as follows:

[0063] x_tra,y_tra=Add_Window_Horizon(data_train,args.lag,args.horizon,single=False)

[0064] Among them, x_tra: input feature data in the training set, that is, the traffic data in the past time window that the model will use for training; y_tra: target output data in the training set, that is, the traffic data at future time points that the model will predict; data_train: training set; args.lag: window size; args.horizon: predicted horizon.

[0065] x_val,y_val=Add_Window_Horizon(data_val,args.lag,args.horizon,single=False)

[0066] Among them, x_val: input feature data in the validation set, used to evaluate the performance of the model during training; y_val: target output data in the validation set, used to calculate the prediction error on the validation set; data_val: validation set.

[0067] x_test,y_test=Add_Window_Horizon(data_test,args.lag,args.horizon,single=False)

[0068] Among them, x_test: input feature data in the test set, used to evaluate the final performance of the model after training is completed; y_test: target output data in the test set, used to compare the prediction results on the test set and calculate the final performance index; data_test: test set.

[0069] To enhance the model's ability to capture the periodicity and trends of time series, this method introduces time as an additional dimension of data. The torch.linspace function is used to generate a time vector that is evenly distributed within the specified start and end time, and it is fused with each input feature window to ensure that time information is fully utilized in model training. This helps the model capture the periodicity and trends of time series, and understand and predict the changing patterns of traffic flow at different time points or time periods.

[0070] Create a time vector times. You can use torch.linspace to generate a time series containing multiple time points to provide a time context for the model for subsequent control differential equation solver (CDE solver):

[0071] times=torch.linspace(0,args.lag+args.horizon-1,steps=args.lag+

[0072] args.horizon)

[0073] The time vector and the feature window are concatenated on the input feature data x_tra, x_val, and x_test of the training set, validation set, and test set respectively to perform time amplification. After amplification, they are x_tra_aug, x_val_aug, and x_test_aug, as shown below:

[0074] x_tra_aug=torch.cat([x_tra, times.repeat(x_tra.shape[0],1,1)],dim=2)

[0075] x_val_aug=torch.cat([x_val, times.repeat(x_val.shape[0],1,1)],dim=2)

[0076] x_test_aug=torch.cat([x_test, times.repeat(x_test.shape[0],1,1)],dim=2)

[0077] Step S203: Perform data smoothing processing on the second traffic data set to obtain a third traffic data set. The third traffic data set is used as a time series enhanced data set for model training, verification and testing.

[0078] In this step, the function NaturalCubicSpline is used for cubic spline interpolation. Cubic spline interpolation is a method of approximating data points using cubic polynomial function segments, while natural cubic spline interpolation ensures that the second-order derivative (i.e., curvature) is zero at both ends of the interpolation point (i.e., the start and end points of the data set), thereby producing a more natural curve. A natural cubic spline interpolator is generated by calling controldiffeq.NaturalCubicSpline to smooth the time series in the data set and calculate the derivatives of the time points. This enables the model to capture the continuous dynamic changes of the time series and smooth discrete time points into a continuous time curve. This step converts the time series into continuous time information, enabling the model to capture subtle changes in the time series.

[0079] Step S3: Based on the control differential equation, a traffic flow prediction model is constructed that integrates at least one control function and a control differential equation solver. The control differential equation solver is used to solve the changes in the flow state of the time series enhanced data set in continuous time through the control differential equation, and adjust the flow state through the control function.

[0080] In this embodiment, the traffic flow prediction model includes: an initialization layer, a linear layer and an output layer, wherein the linear layer is defined in the control function;

[0081] Input the input data to the initialization layer to extract the feature data and time series information of the input data;

[0082] The linear layer extracts the initial hidden state and initial feature state from the feature data as the initial conditions of the control differential equation;

[0083] In the forward propagation process of the model, based on the initial conditions, time series information and control function, the control differential equation solver is called to perform numerical solutions at different time points to obtain the flow state after time evolution. The control function calculates the rate of change of the flow state in the time dimension to update the flow state. The flow state includes: hidden state and characteristic state;

[0084] The output layer receives the traffic status and converts it into the final traffic flow prediction result.

[0085] Step S4: input the training set as input data into the traffic flow prediction model to obtain the traffic flow prediction result output by the traffic flow prediction model.

[0086] Specifically, the AB_NCDE class is a deep learning neural network model based on the control differential equation (CDE), namely the traffic flow prediction model, which inherits from PyTorch's nn.Module and is used to process time series data. Its core purpose is to model the dynamic evolution of time series data through the control differential equation, so as to realize the traffic flow prediction based on the control differential equation on the time series.

[0087] The traffic flow prediction model consists of an initialization layer and an output layer. The initialization layer extracts the feature data and time series information of the input data and converts the input data into an initial state that the model can process:

[0088] self.initial_layer=nn.Linear(args.input_dim,args.hid_dim)

[0089] self.initial_layer: represents the initialization layer of the model, which is the first layer of the model and is used to process input data. Its function is to receive the input feature data and map it to the initial state that the model can process, that is, the hidden state.

[0090] args.input_dim: represents the input dimension of the model, that is, the dimension of the input feature data. It is usually consistent with the number of features, such as the number of features in the time window.

[0091] args.hid_dim: represents the dimension of the hidden layer, that is, the dimension to which the initialization layer maps the input data. This value usually determines the size of the hidden state and the complexity of the model.

[0092] The control functions control_function_f and control_function_g are built based on linear layers and activation functions. Each control function contains a linear layer (nn.Linear), which projects the input features into a new feature space.

[0093] self.linear=nn.Linear(input_dim,hidden_dim)

[0094] input_dim is the input dimension of the model between time steps, and hidden_dim is the transformed dimension.

[0095] At each step of the model's state evolution, the linear layer combines with the activation function to transform the flow state. initial_h and initial_z are the linear layers of the two control functions. Their function is to convert the input feature data into the initial hidden state h0 and initial feature state z0 of the model, that is, to generate the initial hidden state h0 and initial feature state z0 from the initial point times[0] of the cubic spline interpolation. These states serve as the initial conditions of the control differential equation.

[0096] h0=self.initial_h(spline.evaluate(times[0]))

[0097] z0=self.initial_z(spline.evaluate(times[0]))

[0098] In the forward propagation method of the model, the model first processes the input data x through the initialization layer, and then updates the traffic state using the control function and the CDE solver (represented here by the solve_cde function).

[0099] The state update and the solution of the CDE solver are handled in the forward method by the cdeint_gde_dev function. This function is responsible for inputting the control function, initial state and time series into the CDE solver and calculating the evolution of the traffic flow state through numerical solution.

[0100] def forward(self,times,coeffs):

[0101] spline=controldiffeq.NaturalCubicSpline(times,coeffs)

[0102] h0=self.initial_h(spline.evaluate(times[0]))

[0103] z0=self.initial_z(spline.evaluate(times[0]))

[0104] z_t=controldiffeq.cdeint_gde_dev(dX_dt=spline.derivative, h0=h0, z0=z0, func_f=self.func_f, func_g=self.func_g, t=times, method=self.solver, atol=self.atol, rtol=self.rtol)

[0105] z_T=z_t[-1:,...].transpose(0,1)

[0106] output = self.end_conv(z_T)

[0107] output=output.squeeze(-1).reshape(-1,self.horizon,self.output_dim,self.num_node)

[0108] output=output.permute(0,1,3,2)

[0109] return output

[0110] Among them, coeffs represents the time series coefficients generated by cubic spline interpolation, which represents the changes in continuous time. These coefficients ensure that the model can smoothly process time series data.

[0111] times is time series information, which is used by the CDE solver to solve at different time points.

[0112] spline.derivative represents the derivative of the time series and is used to define dX / dt in the governing differential equation, i.e., the rate of change of state over time.

[0113] atol and rtol: Tolerances for absolute and relative errors, used to control the accuracy of numerical solutions. They determine the accuracy of the CDE solver during the solution process.

[0114] The cdeint_gde_dev function calls the CDE solver to solve the control differential equation. By solving the differential control equation, the changes of the flow state z_t at different time points are calculated.

[0115] Take out the traffic state z_T at the last time point in the traffic state z_t and process it through the convolution layer end_conv to generate the output. This convolution layer is the final output layer and is used to generate the final traffic prediction result.

[0116] z_T=z_t[-1:,...].transpose(0,1)

[0117] output = self.end_conv(z_T)

[0118] This process converts the input feature data into a dynamic flow state of a time series through a fully connected network, simulates the continuous change of the flow state over time through control functions and CDE solvers, and finally outputs the prediction results. In this way, the dynamic behavior of time series data is effectively processed without using convolutional layers to process spatial information, which is suitable for application scenarios that need to process continuous time-dependent data, such as traffic flow prediction.

[0119] Step S5: Generate a loss value by using the loss function of the traffic flow prediction model to combine the traffic flow prediction result and the label value. Update the traffic flow prediction model according to the loss value until convergence to obtain a trained traffic flow prediction model. During the training cycle of the traffic flow prediction model, adjust the hyperparameters of the traffic flow prediction model according to the fitting of the validation set.

[0120] The parameters of the model are optimized through the training set, and the generalization ability of the model is evaluated using the validation data.

[0121] Cycle training: In multiple training cycles range, the model model uses the training set train_loader for forward and backward propagation, calculates the loss criterion and optimizes the loss function train_loss.

[0122] Validation: After each training epoch range, the model model is evaluated on the validation set val_loader to calculate the loss criterion and other performance metrics.

[0123] for epoch in range(args.epochs):

[0124] train_loss=train_epoch(model,train_loader,optimizer,criterion)

[0125] val_loss=validate(model,val_loader,criterion)

[0126] Among them, the optimizer is preferably RMSprop, and the function for evaluating the loss criterion can adopt multiple performance indicators such as mean absolute error (MAE, the average of the absolute values ​​of the differences between all predicted values ​​and true values) and root mean square error (RMSE, the square root of the average of the squares of the differences between all predicted values ​​and true values) to comprehensively evaluate the prediction accuracy and robustness of the model.

[0127] Therefore, the control function and CDE solver designed based on the control differential equation serve as the infrastructure of the deep learning neural network model. The control function is not just a simple mathematical expression, but is implemented through a deep learning framework, allowing the model to learn complex nonlinear relationships. This continuous-time modeling approach has the following benefits compared to existing prediction models based on discrete-time data processing (such as RNN):

[0128] 1. Higher prediction accuracy: This model can continuously simulate the time evolution of traffic conditions, not only taking into account the impact of historical traffic data, but also adapting to the dynamic changes of future conditions. In traffic flow forecasting, this means more accurate predictions of traffic peaks, the impact of emergencies on traffic flow, and daily traffic fluctuations.

[0129] 2. Better model generalization ability: Through the flexible design of control functions, this model can learn and adapt to dynamic changes in various traffic modes and different environmental conditions, rather than just directly inferring from training data. It can better adapt to new or unseen traffic conditions, such as special traffic on holidays or traffic changes after the introduction of new traffic rules.

[0130] 3. Improved computational efficiency: This model processes continuous-time data through an effective mathematical framework (control differential equations), reducing the need for complex calculations at each time step, and can operate more efficiently on long sequences compared to models that require frequent state updates (such as RNNs). This makes the model more efficient when processing large-scale traffic flow data, reduces computational costs, and improves the feasibility of real-time predictions.

[0131] 4. Improve the model's interpretability: The state update of this model is achieved through control equations with clear physical meanings, which is different from the black-box deep learning model and can provide a clearer causal explanation for each prediction. Therefore, the transparency and interpretability of this model enable traffic managers and decision makers to better understand the motivations behind the model's predictions, thereby making more reasonable traffic control and planning decisions.

[0132] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0133] In addition, some embodiments of the present application also provide an electronic device. The electronic device may be a digital computer in various forms, such as a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, etc. The electronic device may also be a mobile device in various forms, such as a personal digital processing, a cellular phone, a smart phone, a wearable device, and other similar computing devices.

[0134] The electronic device includes: one or more processors; and a memory storing computer program instructions, and when the computer program instructions are executed, the processor executes the steps of the traffic flow prediction method provided by any one or more of the above embodiments. Figure 2 An exemplary structural diagram of the electronic device is disclosed. Figure 2As shown, the electronic device includes: one or more processors 1101, memory 1102, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Among them, the components shown in this article, their connections and relationships, and their functions are only used as examples, and are not intended to limit the implementation of the present application described and / or required herein.

[0135] The electronic device may further include: an input device 1103 and an output device 1104. The processor 1101, the memory 1102, the input device 1103 and the output device 1104 may be connected via a bus or other means. Figure 2 The example of connecting through bus is taken in the following.

[0136] The input device 1103 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 1104 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0137] To provide interaction with a user, the electronic device may be a computer. The computer has: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball), through which the user can provide input to the computer. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0138] In the embodiments of the present application, a computer program / instruction is stored on a computer-readable medium, and when the computer program / instruction is executed by a processor, the steps of the traffic flow prediction method provided by any one or more of the above embodiments are implemented. The computer-readable medium may be included in the electronic device described in the above embodiments; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more computer-readable instructions.

[0139] The memory 1102 can be used as a non-transient computer-readable storage medium, which can be used to store non-transient software programs, non-transient computer executable programs and modules. The processor 1101 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 1102, so as to implement the program instructions / modules corresponding to the method provided by any one or more embodiments in the embodiments of the present application.

[0140] The memory 1102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1102 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 1102 may optionally include a memory remotely arranged relative to the processor 1101, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0141] It should be noted that more specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0142] Computer readable storage media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.

[0143] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0144] In the above-described embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. For example, it can be implemented by using an application specific integrated circuit (ASIC), a general-purpose computer or any other similar hardware device. In certain embodiments, the software program of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented by hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0145] The computer program product provided in the embodiment of the present application includes one or more computer programs / instructions, and when the computer program / instructions are executed by the processor, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from a computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0146] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0147] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily mention changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims, and the above embodiments should be regarded as exemplary and non-restrictive.

Claims

1. A traffic flow prediction method, characterized in that: include: Obtain a traffic flow data set, wherein the traffic flow data set is divided into a training set, a validation set, and a test set according to a preset ratio, and is used for model training, validation, and testing, respectively; Preprocessing the traffic flow data set to obtain a time series enhanced data set; A traffic flow prediction model is constructed based on a control differential equation, which integrates at least one control function and a control differential equation solver, wherein the control differential equation solver is used to solve the change of the flow state of the time series enhanced data set in continuous time through the control differential equation, and adjust the flow state through the control function; Inputting the training set as input data into a traffic flow prediction model to obtain a traffic flow prediction result output by the traffic flow prediction model; The traffic flow prediction result and the label value are subjected to the loss function of the traffic flow prediction model to generate a loss value, and the traffic flow prediction model is updated according to the loss value until convergence to obtain the trained traffic flow prediction model. During the training cycle of the traffic flow prediction model, the hyperparameters of the traffic flow prediction model are adjusted according to the fitting situation of the validation set.

2. The traffic flow prediction method according to claim 1, characterized in that: The traffic flow prediction model includes: an initialization layer, a linear layer and an output layer, wherein the linear layer is defined in the control function; Inputting the input data into the initialization layer to extract feature data and time series information of the input data; The linear layer extracts an initial hidden state and an initial feature state from the feature data as initial conditions of a control differential equation; In the forward propagation process of the model, based on the initial conditions, time series information and the control function, the control differential equation solver is called to perform numerical solutions at different time points to obtain the flow state after time evolution, and the control function calculates the rate of change of the flow state in the time dimension to update the flow state, and the flow state includes: hidden state and characteristic state; The output layer receives the traffic status and converts it into the final traffic flow prediction result.

3. The traffic flow prediction method according to claim 2, characterized in that: When the control differential equation solver performs numerical solutions at different time points, the tolerance of absolute error and / or relative error is used to control the accuracy of the numerical solutions.

4. The traffic flow prediction method according to claim 1, characterized in that: The step of preprocessing the traffic flow data set to obtain a time series enhanced data set includes: Performing data standardization processing on the traffic flow data set to obtain a first traffic flow data set; The first traffic data set is expanded in time dimension by using window partitioning to obtain a second traffic data set; The second traffic data set is subjected to data smoothing processing to obtain a third traffic data set, and the third traffic data set is used as a time series enhanced data set for model training, verification and testing.

5. The traffic flow prediction method according to claim 4, characterized in that: The step of performing data standardization processing on the traffic flow data set to obtain a first traffic flow data set includes: Calculating the mean and standard deviation of the traffic flow data set; Based on the mean and the standard deviation, each data point of the traffic flow data set is converted into a standard score value, thereby obtaining the first traffic data set.

6. The traffic flow prediction method according to claim 4, characterized in that: The step of performing time dimension amplification on the first traffic data set by using window partitioning to obtain a second traffic data set includes: Generating input feature data and target output data for the training set, the validation set, and the test set, respectively, according to the set observation window and the prediction horizon; Create a uniformly distributed time vector, use the observation window to scan the input feature data, splice the time vector with each input feature window in dimension to achieve time dimension expansion, and then obtain the second traffic data set to help the model understand the changing pattern of traffic flow at different time points or time periods.

7. The traffic flow prediction method according to claim 4, characterized in that: The step of performing data smoothing on the second flow data set to obtain a third flow data set includes: The second traffic data set is traversed, and discrete time points in the second traffic data set are smoothed into a continuous time curve using a cubic spline interpolation method, so that the time series in the data set is converted into continuous time information, thereby obtaining the third traffic data set.

8. An electronic device, characterized in that: The electronic device comprises: One or more processors; and a memory storing computer program instructions, wherein when the computer program instructions are executed, the processor executes the steps of the traffic flow prediction method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the traffic flow prediction method according to any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the traffic flow prediction method as described in any one of claims 1-7 are implemented.