Traffic jam detection method and system based on trajectory mining algorithm
The traffic congestion detection method based on the trajectory mining algorithm and the hybrid long-short-term memory network model solves the problem of traditional methods relying on traffic flow prediction, and achieves accurate traffic congestion prediction based on the real-time conditions of the road network.
Patent Information
- Application Number
- CN202410745044.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-24
AI Technical Summary
Traditional traffic congestion prediction methods rely on traffic flow prediction and cannot effectively consider changes in road conditions and other factors, resulting in inaccurate prediction results.
A traffic congestion detection method based on trajectory mining algorithm is adopted. By constructing a motor vehicle trajectory data set, a hybrid long-short-term memory network model is used to predict the driving path of motor vehicles, count the number of motor vehicles on the road, and determine congested roads based on preset thresholds.
It can predict traffic congestion based on the real-time conditions of the road network, which improves the accuracy and adaptability of the prediction and is independent of the traffic flow prediction results.
Smart Images

Figure CN118692235A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning, and relates to but is not limited to a traffic congestion detection method and system based on a trajectory mining algorithm. Background Art
[0002] The traffic congestion prediction methods that have been proposed include methods based on time series analysis, methods based on machine learning, and methods based on neural networks. These methods are mainly used to predict traffic flow. After the prediction is completed, it can be judged whether the road has the risk of congestion based on the traffic flow prediction results. If the future traffic flow of a road is relatively large, then the risk of traffic congestion on the road is relatively high; if the future traffic flow of a road is relatively small, then the risk of traffic congestion on the road is relatively low.
[0003] In summary, it can be found that traditional congestion prediction methods are very dependent on the results of traffic flow prediction. However, in the real environment, the occurrence of traffic congestion does not entirely depend on the traffic flow of the road, but may also be affected by related factors such as weather, environment, and changes in road conditions. If a part of a road is suddenly severely damaged, it may cause the road to change from three lanes to a single lane. In this case, even if the future traffic flow of the road is very small, it may still cause serious traffic congestion. Similarly, if the road is very wide, even if the traffic flow of the road is very large, it may still not cause traffic congestion. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a traffic congestion detection method based on a trajectory mining algorithm, which does not rely on the results of traffic flow prediction and can perform congestion prediction according to the real-time conditions of the road network.
[0005] The technical solution of the embodiment of the present invention is achieved as follows:
[0006] In a first aspect, an embodiment of the present invention provides a traffic congestion detection method based on a trajectory mining algorithm, the method comprising:
[0007] Construct a trajectory dataset T of all motor vehicles on a preset road in the recent period of time;
[0008] Filtering the trajectory information at the current moment from the trajectory data set T and obtaining the attribute information of the corresponding motor vehicle and storing it in the motor vehicle set V;
[0009] Predicting the driving path of each motor vehicle in the motor vehicle set V at the next moment by using a trained hybrid long short-term memory network model, and storing all prediction results in a prediction position set P; wherein the hybrid long short-term memory network model is trained based on the trajectory data set T;
[0010] Counting the number of motor vehicles passing through each road in the road set R at the next moment based on the elements in the predicted position set P, and storing the statistical results in the flow set N;
[0011] Each element value in the traffic set N is compared with the corresponding element value in the preset road threshold set S to obtain a congested road set.
[0012] In some possible embodiments, constructing a trajectory data set of all motor vehicles on a preset road in a recent period of time includes: collecting a license plate image of each motor vehicle and performing license plate recognition through a group of cameras installed on the preset road; for each motor vehicle, based on the position, shooting time and license plate recognition result of each camera, determining a trajectory point of the corresponding motor vehicle; storing all trajectory points of the same license plate number in the recent period of time in the same set; arranging all trajectory points in each set in chronological order and deleting duplicate trajectory points to obtain a piece of trajectory data of the corresponding motor vehicle.
[0013] In some possible embodiments, the method of counting the number of motor vehicles passing through each road in the road set R at the next moment based on the elements in the predicted position set P and storing the statistical results in the traffic set N includes: obtaining a road set R including all road information in the urban road network; constructing a traffic set N with the same length as the road set R and initializing each element to all 0s to store the number of motor vehicles passing through each road in the road set at the next moment; traversing each element in the predicted position set P, matching the road information corresponding to the element with the information of each road in the road set R; and adding 1 to the value of the corresponding element in the traffic set N of the target road whose information in the road set R matches the same.
[0014] In some possible embodiments, the comparison of each element value in the traffic set N with the corresponding element value in the preset road threshold set S to obtain a congested road set includes: traversing each element value in the traffic set N, and when the number of motor vehicles on any road in the traffic set N is greater than the corresponding vehicle threshold in the road threshold set, treating the road as a congested road; until all element values in the traffic set N are compared, the congested road set is obtained.
[0015] In some possible embodiments, the trajectory data of the i-th motor vehicle in the motor vehicle set V includes the current position x i 、The current time value H i 、What day of the week is the current date? i , and the time interval D from the previous position to the current positioni ; The input of the hybrid long short-term memory network model is x i , H i , W i , D i The concatenated sequence vector.
[0016] In some possible embodiments, the network structure of the hybrid long short-term memory network model includes a shielding layer, a long short-term memory network layer, a self-attention layer, a random drop layer and a fully connected layer; wherein the shielding layer is used to process the input sequence vector through a specific shielding value; the long short-term memory network layer is used to extract features from the processed sequence vector, including multiple memory blocks, each of which includes three gates: an input gate, a forget gate and an output gate; the self-attention layer is used to extract the long dependency relationship in the sequence vector based on the hidden state generated by the output gate; the random drop layer is used to reduce the model's dependence on training data by randomly discarding the output of a part of neurons; the fully connected layer includes two sublayers, one of which uses the Softmax function as an activation function, and the output represents the probability of the model predicting the specific location of the motor vehicle, and the other sublayer uses the Relu function as an activation function, and the output value is the time taken for the model to predict that the motor vehicle will arrive at the next location.
[0017] In some possible embodiments, the training process of the hybrid long short-term memory network model includes the following steps: based on the position sequence prediction results output by the hybrid long short-term memory network model, a first loss function is constructed using classification cross entropy; based on the arrival time series prediction results output by the hybrid long short-term memory network model, a second loss function is constructed using mean square error; the first loss function and the second loss function are weightedly summed to obtain a target loss function; using the target loss function, the hybrid long short-term memory network model is back-propagated and trained using the gradient descent method until the model converges.
[0018] In some possible embodiments, the method further includes: updating the trajectory dataset at a specific time every day; and retraining the hybrid long short-term memory network model based on the updated trajectory dataset.
[0019] In a second aspect, an embodiment of the present invention provides a traffic congestion detection system based on a trajectory mining algorithm, comprising a series of cameras arranged at fixed positions on a road, a central server and a traffic management client, wherein:
[0020] The camera is used to collect the license plate image of the motor vehicle in real time and perform license plate recognition;
[0021] The central server is used to obtain the location information, collection information and shooting time of the camera, and perform detection according to the traffic congestion detection method described in the first aspect above;
[0022] The traffic management client is connected to the central server network and is used to display the congestion prediction results of the central server in real time.
[0023] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0024] In an embodiment of the present invention, a traffic congestion prediction method based on trajectory data mining is proposed, which predicts the future travel paths of all motor vehicles in the road network based on their current trajectories and counts the number of motor vehicles that may pass through a certain road in the future based on the path prediction results. According to the statistical results, it is possible to determine which roads may be congested. This method can predict congestion based on the real-time status of the road network. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0026] Figure 1 A flow chart of a traffic congestion detection method based on a trajectory mining algorithm provided by an embodiment of the present invention;
[0027] Figure 2 A schematic diagram of the structure of a hybrid long short-term memory model provided by an embodiment of the present invention;
[0028] Figure 3 A schematic diagram of the structure of a single memory block in the LSTM layer provided in an embodiment of the present invention;
[0029] Figure 4 A schematic diagram of the connection relationship between the LSTM layer and the self-attention layer provided in an embodiment of the present invention;
[0030] Figure 5 A schematic diagram of the architecture of a traffic congestion detection system based on a trajectory mining algorithm provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0032] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0033] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present invention are only used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present invention described here can be implemented in an order other than that illustrated or described here.
[0034] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the field to which the embodiments of the present invention belong. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0035] The embodiment of the present invention provides a traffic congestion detection method based on a trajectory mining algorithm. Figure 1 A flow chart of a traffic congestion detection method based on a trajectory mining algorithm provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method comprises at least the following steps:
[0036] Step S110, constructing a trajectory dataset T of all motor vehicles on a preset road in a recent period of time.
[0037] Here, the preset roads are the roads in the urban road network that need to be detected; the recent period is a fixed time period with the current time as the end time, so that the trajectory data set within this time period is used to train the model, and the path that the motor vehicle will travel in the future can be predicted.
[0038] The trajectory data set T may include trajectory data of all motor vehicles, each piece of trajectory data corresponds to a motor vehicle, and includes multiple trajectory points collected at different times in a recent period of time.
[0039] Step S120 , filtering the trajectory information at the current moment from the trajectory data set T and obtaining the attribute information of the corresponding motor vehicle and storing it in the motor vehicle set V.
[0040] Here, all current trajectory information is filtered out from the trajectory data set T according to the time information, and attribute information such as identification ID and license plate number of all corresponding motor vehicles is obtained based on the filtered trajectory information and stored in the motor vehicle set V.
[0041] Step S130, predicting the driving path of each motor vehicle in the motor vehicle set V at the next moment through the trained hybrid long short-term memory network model, and storing all prediction results in the prediction position set P.
[0042] Here, the hybrid long short-term memory network model (hereinafter referred to as Hybrid LSTM) is trained based on the trajectory dataset T;
[0043] Step S140, based on the elements in the predicted position set P, count the number of motor vehicles passing through each road in the road set R at the next moment, and store the statistical results in the traffic set N.
[0044] Here, the prediction result of the Hybrid LSTM model is the probability value corresponding to each road. The road number with the largest probability value is selected, and the corresponding element in the road set R can be obtained through the road number. The road set N is used to store the number of motor vehicles passing through each road in the road set R at the next moment.
[0045] Step S150, comparing each element value in the traffic set N with the corresponding element value in the preset road threshold set S to obtain a congested road set.
[0046] Here, the preset road threshold set S is used to store the vehicle threshold corresponding to each road. In this process, it is necessary to compare the statistical results in the road set N with the threshold corresponding to the road. If the statistical result is greater than the threshold, it means that the road may be congested, otherwise, it means that the road will not be congested. Thus, all roads that may be congested are stored as a congested road set.
[0047] It is worth noting that, firstly, the future driving trajectory of each motor vehicle in the road network is predicted based on its current trajectory; secondly, when setting the road threshold, factors such as real-time environmental conditions and real-time road conditions can be fully considered, so that the congestion prediction results for each road are more in line with the actual situation of the road.
[0048] In an embodiment of the present invention, a traffic congestion prediction method based on trajectory data mining is proposed, which predicts the future travel paths of all motor vehicles in the road network based on their current trajectories and counts the number of motor vehicles that may pass through a certain road in the future based on the path prediction results. According to the statistical results, it is possible to determine which roads may be congested. This method can predict congestion based on the real-time status of the road network.
[0049] In some possible embodiments, the above step S110 is further implemented through the following steps: collecting the license plate image of each motor vehicle and performing license plate recognition through a group of cameras installed on the preset road; for each motor vehicle, determining a trajectory point of the corresponding motor vehicle based on the position, shooting time and license plate recognition result of each camera; storing all trajectory points of the same license plate number in the recent period of time in the same set; arranging all trajectory points in each set in chronological order and deleting duplicate trajectory points to obtain a trajectory data of the corresponding motor vehicle.
[0050] Here, the trajectory data set can be collected by cameras installed on the road. The camera can collect the license plates of all motor vehicles on the road and perform license plate recognition. According to the position of the camera, the shooting time and the result of license plate recognition, a corresponding trajectory point of a motor vehicle can be obtained. All trajectory points need to be sorted out at regular intervals. In this process, all trajectory points with the same license plate number need to be placed in the same set and all trajectory points in each set need to be arranged in chronological order. After completion, the duplicate trajectory points need to be deleted. At this time, each set is a trajectory corresponding to a motor vehicle.
[0051] In some possible embodiments, the method of counting the number of motor vehicles passing through each road in the road set R at the next moment based on the elements in the predicted position set P and storing the statistical results in the traffic set N includes: obtaining a road set R including all road information in the urban road network; constructing a traffic set N with the same length as the road set R and initializing each element to all 0s to store the number of motor vehicles passing through each road in the road set at the next moment; traversing each element in the predicted position set P, matching the road information corresponding to the element with the information of each road in the road set R; and adding 1 to the value of the corresponding element in the traffic set N of the target road whose information in the road set R matches the same.
[0052] Here, get the jth element l in the predicted position set P j , that is, the i-th motor vehicle predicts the next location to be reached, and the element l j The corresponding road is compared with the information of each road in the set R. If l j If it is the same as the u-th road in the road set R, then add 1 to the value of the u-th element in the traffic set N.
[0053] After all elements in the predicted position set P are matched, the traffic set N stores the number of motor vehicles passing through each road in the road set R at the next moment.
[0054] In some possible embodiments, the comparison of each element value in the traffic set N with the corresponding element value in the preset road threshold set S to obtain a congested road set includes: traversing each element value in the traffic set N, and when the number of motor vehicles on any road in the traffic set N is greater than the corresponding vehicle threshold in the road threshold set, treating the road as a congested road; until all element values in the traffic set N are compared, the congested road set is obtained.
[0055] Here, in this process, it is necessary to compare the statistical results with the threshold value corresponding to the road. If the number of motor vehicles on a road is greater than the corresponding vehicle threshold, traffic congestion may occur on the road. This method can predict congestion based on the real-time conditions of the road network.
[0056] In some possible embodiments, the trajectory data of the i-th motor vehicle in the motor vehicle set V includes the current position x i 、The current time value H i 、What day of the week is the current date? i , and the time interval D from the previous position to the current position i ; The input of the hybrid long short-term memory network model is x i , H i , W i , D i The concatenated sequence vector.
[0057] Here, x i , W i , H i are all one-hot vectors, where vector W i The length of the vector H is 7. i The length of D is 24. i Is a specific value in seconds (s), used to represent the time interval. i , W i, H i and D i They need to be concatenated to form a new vector, which will be input into the masking layer of the Hybrid LSTM model.
[0058] In some possible embodiments, Figure 2 As shown, the network structure of the hybrid long short-term memory network model includes a shielding layer, a long short-term memory network layer, a self-attention layer, a random drop layer and a fully connected layer; wherein the shielding layer is used to process the input sequence vector through a specific shielding value; the long short-term memory network layer is used to extract features from the processed sequence vector, including multiple memory blocks, each of which includes three gates: an input gate, a forget gate and an output gate; the self-attention layer is used to extract the long dependency relationship in the sequence vector based on the hidden state generated by the output gate; the random drop layer is used to reduce the model's dependence on training data by randomly discarding the output of a part of neurons; the fully connected layer includes two sublayers, one of which uses the Softmax function as an activation function, and the output represents the probability of the model predicting the specific location of the motor vehicle, and the other sublayer uses the Relu function as an activation function, and the output value is the time taken for the model to predict that the motor vehicle will arrive at the next location.
[0059] Here, the shielding layer mainly shields the numerical sequence through a specific shielding value. In this way, the variable-length sequence can be processed. The output value of the shielding layer is input to the LSTM layer. The LSTM layer is composed of several memory blocks. The LSTM layer mainly extracts features from the sequence. The memory block mainly contains three gates, namely the input gate, the forget gate and the output gate. The structure of the memory block is as follows: Figure 3 as shown in .
[0060] The calculation process of the input gate of the memory block is as follows:
[0061] i =δ(W ix X t +W un h t-1 +b i ) formula (1);
[0062] C′ t =tanh(W CX Xx t ++W C′h h t-1 +b C′ ) formula (2),
[0063] The calculation process of the forget gate is as follows:
[0064] ft =δ(W fx X t +W fh h t-1 +b f ) formula (3);
[0065] The calculation process of the output gate is as follows:
[0066] o t =δ(W ox X t +W oh h t-1 +b o ) formula (4);
[0067] C t =f t *C t-1 +i t *C′ t Formula (5);
[0068] h t =o t *tanh(C t ) formula (6);
[0069] X t is the input value of the LSTM layer at the tth time step, C t is the hidden unit state at the tth time step, f represents the forget gate, i represents the input gate, C represents the unit state vector, o represents the output gate, the operator “*” represents the dot product between two vectors, δ(.) represents the sigmoid function, and W fx , W fh , W ix , W ih , W ox and W oh Represents the weight matrix. The output gate can produce two results, one is the output value o t , and the other is the hidden state h t , where h t Will be used as the input value of the self-attention layer. The connection relationship between the LSTM layer and the self-attention layer is as follows Figure 4 as shown in .
[0070] The self-attention layer is mainly used to extract long dependencies from the sequence. The working principle of the self-attention layer in the hybridLSTM model is as follows:
[0071] g t,t′ =tanh(W g h t +W g′ h t′ +bg ) formula (7);
[0072] e t,t ′=δ(W a g t,t′ +b a ) Formula (8)
[0073]
[0074] A t -∑ t′ a t,t′ h t ′ Formula (10)
[0075] h t represents the output hidden state of the LSTM layer at the current time step t, h t’ represents the output hidden state of the previous time step t', δ(.) is the sigmoid function, and W a , W g and W g’ is the weight matrix, and At represents the output of the self-attention layer at the tth time step.
[0076] The output of the self-attention layer is input to the Dropout layer. The Dropout layer mainly reduces the model's dependence on training data by randomly discarding the output of some neurons, thereby preventing overfitting. The output of the Dropout layer is input to the fully connected layer, which contains two sublayers. The first sublayer uses the Softmax function as the activation function. The output of this layer is a vector. Each value in the vector corresponds to a specific location. The value is used to represent the probability of a specific location. The larger the value, the greater the probability that the motor vehicle will arrive at the location at the next moment. The second sublayer uses the Relu function as the activation function. The output value of this sublayer is a prediction of the time it takes for the motor vehicle to arrive at the next location. The output of the first sublayer is input to the output layer of the HybridLSTM model. This layer will find the location corresponding to the maximum probability from all probability values as the prediction result of the vehicle's arrival location at the next moment.
[0077] In some possible embodiments, the training process of the hybrid long short-term memory network model includes the following steps: based on the position sequence prediction results output by the hybrid long short-term memory network model, a first loss function is constructed using classification cross entropy; based on the arrival time series prediction results output by the hybrid long short-term memory network model, a second loss function is constructed using mean square error; the first loss function and the second loss function are weightedly summed to obtain a target loss function; using the target loss function, the hybrid long short-term memory network model is back-propagated and trained using the gradient descent method until the model converges.
[0078] Here, when constructing the target loss function of the model, the embodiment of the present invention uses the classification cross entropy to construct the first loss function for the part of the motor vehicle position prediction, and uses the mean square error to construct the second loss function for the part of the arrival time prediction. The expressions corresponding to the classification cross entropy function and the mean square error function are as follows:
[0079]
[0080] is the first loss function based on categorical cross entropy, Y is an observed position sequence, is a position sequence prediction result obtained by the model, J represents the trajectory point set, is the second loss function constructed based on the mean square error, D is the actual arrival time series, is the prediction result of the arrival time series, and n is the trajectory length.
[0081] Y i,j The value of is either 0 or 1. If the vehicle reaches position j at time i+1, then Y i,j The value of Y is 1, otherwise i,j The value of is 0, The value of represents the probability that the motor vehicle arrives at position j at time i+1, D i It represents the real time from trajectory point i-1 to trajectory point i, represents the predicted time from trajectory point i-1 to trajectory point i. The loss function of the HybridLSTM model is based on and The expression of the objective loss function is obtained as follows:
[0082]
[0083] Where w is the mean square error function The weight value of w will be set to 8 in a preferred embodiment.
[0084] When training the model, the target loss function given above needs to be minimized. In the embodiment of the present invention, the gradient descent method will be used to find the minimum value of the loss function, and the RMSProp algorithm will be used to complete the gradient descent process based on the loss function.
[0085] In some possible embodiments, the method further includes: updating the trajectory dataset at a specific time every day; and retraining the hybrid long short-term memory network model based on the updated trajectory dataset.
[0086] Here, the specific time of the day is set by comprehensively considering the time interval for collating the trajectory data and the actual road communication conditions, for example, it can be set to 12 o'clock in the evening or 4 o'clock in the morning, etc., and the embodiment of the present invention is not limited to this.
[0087] Figure 5 A schematic diagram of the architecture of a traffic congestion detection system based on a trajectory mining algorithm provided by an embodiment of the present invention is shown in FIG. Figure 5 As shown, the system includes a series of cameras arranged at fixed positions on the road (for example, road camera 1, road camera 2, road camera n as shown in the figure), a central server and a traffic management client, wherein: the camera is used to collect the license plate image of the motor vehicle in real time and perform license plate recognition; the central server is used to obtain the location information, collection information and shooting time of the camera, and perform detection according to the above-mentioned traffic congestion detection method; the traffic management client is connected to the central server network, and is used to display the congestion prediction results of the central server in real time.
[0088] It should be noted that the description of the above system embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the system embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding.
[0089] The traffic congestion detection system based on the trajectory mining algorithm provided by the embodiment of the present invention is applied, and the data collection process is as follows: all road cameras need to continuously perform motor vehicle license plate recognition and return the collected license plate information, camera location information and photo shooting time information to the central server. The central server needs to sort the trajectory points once every period of time. In this process, all trajectory points of the same license plate number need to be placed in the same set and all trajectory points in each set are arranged in chronological order. After completion, the duplicate trajectory points need to be deleted. At this time, each set is a trajectory corresponding to a motor vehicle. Trajectory data can be extracted through trajectory point sorting. After the extraction is completed, the proposed congestion prediction algorithm is executed based on all trajectory data and the prediction results are displayed in real time on the traffic management client. In addition, the Hybrid LSTM model stored in the central server will be retrained based on the updated trajectory data set at 12 o'clock every night.
[0090] The traffic congestion detection method based on the trajectory mining algorithm is described below in conjunction with a specific embodiment. However, it should be noted that this specific embodiment is only for better illustrating the present invention and does not constitute an improper limitation to the present invention.
[0091] The embodiment of the present invention proposes a traffic congestion prediction method based on a trajectory data algorithm. The method mainly predicts the future travel path of all motor vehicles in the road network based on their current trajectories and counts the number of motor vehicles that may pass through a certain road in the future based on the path prediction results. According to the statistical results, it can be determined which roads may be congested. The specific execution process of the trajectory actual algorithm is as follows:
[0092] S1, input trajectory dataset T, and train a Hybrid LSTM model based on the input trajectory dataset;
[0093] S2, filtering out all current trajectories from the trajectory data set T according to the time information, obtaining all corresponding motor vehicles based on the filtered trajectory information and storing them in the motor vehicle set V;
[0094] S3, initialize an empty set P to store the predicted position set;
[0095] S4, set the variable i, and set the value of i to 0;
[0096] S5, using the hybrid LSTM model to predict the next location l that the i-th vehicle in the set V will reach i ;
[0097] S6, will l i Store in set P;
[0098] S7, i=i+1;
[0099] S8, check whether the value of variable i is equal to the length value of motor vehicle set V, if yes, jump to S9, if no, jump to S5;
[0100] S9, input road set R, R is an input parameter, including all road information in the urban road network, construct a new all-zero data set N, the length of which is the same as the length of road set R, and is used to store the number of motor vehicles passing through each road in road set R at the next moment;
[0101] S10, set variable j, set the value of i to 0;
[0102] S11, get the jth element l in the set P j ;
[0103] S12, the element l j Compare the corresponding road with the information of each road in the set R;
[0104] S13, if l j is the same as the u-th road in set R, then add 1 to the value of the u-th element in set N;
[0105] S14, j=j+1;
[0106] S15, check whether the value of variable j is equal to the length of set V, if yes, jump to S16, if not, jump to S11;
[0107] S16, input the threshold set S corresponding to the road, the set S is used to store the vehicle threshold corresponding to each road, if the number of motor vehicles on a road is greater than the corresponding vehicle threshold, then the road may be congested, and an empty set C is initialized to store the congested roads;
[0108] S17, set the variable k, and set the value of k to 0;
[0109] S18, the kth element n in the set N k The value and threshold value of the kth element s in the set S k 's values for comparison;
[0110] S19, if n k Greater than s k , the i-th element in set R is stored in set C;
[0111] S20, k=k+1;
[0112] S21, check whether the value of variable k is equal to the length of set N, if yes, jump to S18, if not, jump to S22;
[0113] S22, returning to set C, which stores all congested roads.
[0114] In the embodiment of the present invention, firstly, the future driving trajectory of each motor vehicle in the road network is obtained based on the prediction of its current trajectory; secondly, when setting the road threshold, factors such as real-time environmental conditions and real-time road conditions can be fully considered, so that the congestion prediction result for each road is more in line with the actual situation of the road.
[0115] It should be noted that, in the embodiment of the present invention, if the above-mentioned traffic congestion detection method based on the trajectory mining algorithm is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present invention is not limited to any specific combination of hardware and software.
[0116] The methods disclosed in the several method embodiments provided by the present invention can be arbitrarily combined without conflict to obtain new method embodiments.
[0117] The above is only an embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A traffic congestion detection method based on trajectory mining algorithm, It is characterized in that include: Construct a trajectory dataset T of all motor vehicles on a preset road in the recent period of time; Filtering the trajectory information at the current moment from the trajectory data set T and obtaining the attribute information of the corresponding motor vehicle and storing it in the motor vehicle set V; Predicting the driving path of each motor vehicle in the motor vehicle set V at the next moment by using a trained hybrid long short-term memory network model, and storing all prediction results in a prediction position set P; wherein the hybrid long short-term memory network model is trained based on the trajectory data set T; Counting the number of motor vehicles passing through each road in the road set R at the next moment based on the elements in the predicted position set P, and storing the statistical results in the flow set N; Each element value in the traffic set N is compared with the corresponding element value in the preset road threshold set S to obtain a congested road set.
2. The method according to claim 1, It is characterized in that The step of constructing a trajectory dataset of all motor vehicles on a preset road in a recent period of time includes: A group of cameras installed on the preset road are used to collect the license plate image of each motor vehicle and perform license plate recognition; For each of the motor vehicles, based on the position, shooting time and license plate recognition result of each of the cameras, determining a trajectory point of the corresponding motor vehicle; All trajectory points of the same license plate number within the recent period of time are stored in the same set; All trajectory points in each set are arranged in chronological order and duplicate trajectory points are deleted to obtain a piece of trajectory data corresponding to the motor vehicle.
3. The method according to claim 1, It is characterized in that The counting of the number of motor vehicles passing through each road in the road set R at the next moment based on the elements in the predicted position set P, and storing the statistical results in the flow set N, includes: Obtain a road set R including all road information in the urban road network; Construct a flow set N with the same length as the road set R and initialize each element to all 0s, so as to store the number of motor vehicles passing through each road in the road set at the next moment; Traversing each element in the predicted position set P, matching the road information corresponding to the element with the information of each road in the road set R; The value of the corresponding element in the traffic set N of the target road with consistent information in the road set R is increased by 1.
4. The method according to claim 1, It is characterized in that The step of comparing each element value in the traffic set N with the corresponding element value in the preset road threshold set S to obtain a congested road set includes: Traversing each element value in the traffic set N, when the number of motor vehicles on any road in the traffic set N is greater than the corresponding vehicle threshold in the road threshold set, the road is regarded as a congested road; Until all element values in the traffic set N are compared, the congested road set is obtained.
5. The method according to any one of claims 1 to 4, It is characterized in that The trajectory data of the i-th motor vehicle in the motor vehicle set V includes the current position x i 、The current time value H i 、What day of the week is the current date? i , and the time interval D from the previous position to the current position i ; The input of the hybrid long short-term memory network model is x i , H i , W i , D i The concatenated sequence vector.
6. The method according to any one of claims 1 to 4, It is characterized in that The network structure of the hybrid long short-term memory network model includes a shielding layer, a long short-term memory network layer, a self-attention layer, a random drop layer and a fully connected layer; wherein: The masking layer is used to process the input sequence vector through a specific masking value; The long short-term memory network layer is used to extract features from the processed sequence vector, and includes a plurality of memory blocks, each of which includes three gates: an input gate, a forget gate, and an output gate; The self-attention layer is used to extract long dependencies in the sequence vector based on the hidden state generated by the output gate; The random dropout layer is used to reduce the model's dependence on training data by randomly dropping the output of a portion of neurons; The fully connected layer includes two sublayers, one of which uses the Softmax function as an activation function, and the output represents the probability of the model predicting the specific location of the motor vehicle, and the other sublayer uses the Relu function as an activation function, and the output value is the time taken by the model to predict that the motor vehicle will arrive at the next location.
7. The method according to claim 6, It is characterized in that The training process of the hybrid long short-term memory network model includes the following steps: Based on the position sequence prediction result output by the hybrid long short-term memory network model, a first loss function is constructed using classification cross entropy; Based on the arrival time series prediction results output by the hybrid long short-term memory network model, a second loss function is constructed using a mean square error; Taking a weighted sum of the first loss function and the second loss function to obtain a target loss function; The target loss function is used to perform back propagation training on the hybrid long short-term memory network model using a gradient descent method until model convergence is achieved.
8. The method according to any one of claims 1 to 4, It is characterized in that The method further comprises: updating the trajectory dataset at a specific time every day; The hybrid long short-term memory network model is retrained based on the updated trajectory dataset.
9. A traffic congestion detection system based on trajectory mining algorithm, It is characterized in that It includes a series of cameras set up at fixed locations on the road, a central server and a traffic management client, including: The camera is used to collect the license plate image of the motor vehicle in real time and perform license plate recognition; The central server is used to obtain the location information, collection information and shooting time of the camera, and perform detection according to the traffic congestion detection method according to any one of claims 1 to 8; The traffic management client is connected to the central server network and is used to display the congestion prediction results of the central server in real time.
Citation Information
Cited By
Traffic network dynamic simulation deduction system based on digital twinborn technology
CN122241939A
