A Transformer-based highway active control plan generation method
By applying the Transformer model in the highway, the active control plan is generated and evaluated, and the problem of difficult to effectively deal with traffic accidents and congestion in the existing technology is solved, and the effect of improving traffic safety and traffic efficiency is achieved.
Patent Information
- Application Number
- CN202410351284.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-03-26
Smart Images

Figure CN118262518B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of road traffic, and in particular relates to a method for generating an active highway control plan based on Transformer. Background Art
[0002] The number of motor vehicles and drivers in my country continues to grow. Under this trend, the traffic volume on my country's highways continues to increase, posing a huge challenge to the traffic carrying capacity and road management of some road network sections. In order to solve the existing problems of my country's highways, it is urgent to improve the control capacity and level of highways through information technology, improve traffic efficiency, and reduce risks.
[0003] Regarding the current status of research on traffic control strategies and methods for highways, foreign scholars have proposed relevant strategies and methods earlier, such as entrance ramp control methods and variable speed limit control methods. With the rapid development of domestic economy and science and technology, Chinese scholars and some academic institutions have also paid more attention to research on road traffic control. The methods and models used in existing research include feedback collaborative control models, optimal control models, cellular transmission models, etc., and Transformer is rarely combined with active highway control.
[0004] Transformer is a neural network model based on the self-attention mechanism, proposed by Google in 2017. Its core idea is to use the self-attention mechanism to capture the contextual information in the input sequence, thereby realizing the modeling of the sequence. Transformer has the characteristics of parallel computing, long-range dependency modeling, and multi-head attention mechanism. Compared with the traditional recurrent neural network model, the Transformer model can process the input sequence in parallel, effectively improving the computational efficiency. The self-attention mechanism can capture global contextual information and improve the semantic understanding ability of the model, and the model has strong generalization ability. Therefore, the Transformer model has excellent performance in many sequence data modeling tasks, but it is rarely used in the field of active highway control. Summary of the invention
[0005] The technical problem to be solved by the present invention is: to propose a method for generating active control plans for highways based on Transformer, to generate active control plans according to the traffic status of the entire highway, to effectively deal with traffic accidents, traffic congestion and other problems, and to improve traffic safety and traffic efficiency.
[0006] Technical solution: The present invention provides a method for generating an active highway control plan based on Transformer, which specifically includes the following steps:
[0007] Step 1: Obtain the traffic status of the entire line, cloud control reporting event information, and initialize the control equipment information of the entire line from the highway data center;
[0008] Step 2: The Transformer-based active control solution generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the control equipment of the entire line to initialize and generate the target information of the control objects of the entire line;
[0009] Step 3: Based on the Transformer-based full-line traffic status prediction module, the full-line traffic status and the target information of the full-line control objects are initialized to generate the full-line traffic status prediction results;
[0010] Step 4: Use the output results of the full-line traffic status prediction module to evaluate the generated active control plan, and judge whether the traffic status improvement reaches the threshold by comparing the initialized full-line traffic status with the full-line traffic status prediction results;
[0011] Step 5: If the generated active control plan is judged to be effective, the specific plan will be uploaded to the highway data center.
[0012] Furthermore, the data obtained from the highway data center in step 1 includes the traffic status of the entire line, cloud control reporting event information and initialization information of the entire line control equipment; wherein the traffic status of the entire line includes the flow rate, speed and occupancy information of each monitoring point; the cloud control reporting event information includes event number, event category, road section range, event occurrence and other information; the initialization information of the entire line control equipment includes initial status information board information (including information board number, layout location stake number, display information, display time) and toll station information (toll station name, main line stake number at the connection between the toll station entrance ramp and the highway).
[0013] Furthermore, the Transformer-based active control solution generation module in step 2 includes the following sub-steps:
[0014] Step 2.1, the active control plan generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the control equipment of the entire line, processes the input sequence at the data embedding layer and adds position coding, and inputs the obtained vector into the encoder;
[0015] Step 2.2: The encoder obtains a sequence that effectively focuses on global information through the multi-head attention module, adds it to the original sequence, and uses the Softmax normalization method to input the obtained sequence into the feedforward neural network, and then performs another addition and normalization. This process is repeated N times to obtain the output of the encoder of the active control solution generation module;
[0016] Step 2.3, the decoder of the active control scheme generation module starts calculation and generation after receiving the start symbol; after the decoder obtains the output of the previous step and adds the position code, it is input into the decoder;
[0017] Step 2.4: In the decoder, the sequence is first fed into a masked multi-head attention module, which focuses only on earlier positions in the sequence. After addition and normalization, it is fed into a cross-attention layer, along with the encoder output. The subsequent steps are the same as for the encoder. The steps in the decoder are repeated N times.
[0018] Step 2.5, after the steps in the decoder are repeated N times, the final output is obtained through linear transformation and standardization processing; the final output includes the target information of the entire line control objects including the target speed limit, signs and dynamic text information of the entire line and the restriction information of the toll station.
[0019] Furthermore, the Transformer-based full-line traffic status prediction module in step 3 includes the following sub-steps:
[0020] Step 3.1, the full-line traffic state prediction module inputs the initialized full-line traffic state, and the target information of the full-line control object output by the active control plan generation module is concatenated through the Concatenate function and then input into the encoder; the encoder has a similar structure to the active control plan generation module, and repeatedly executes the multi-head attention layer and the feedforward neural network layer M times, where the initialized full-line traffic state is the state before control, that is, the full-line traffic state at a certain time node;
[0021] Step 3.2: The encoder output is input into the decoder through the cross attention mechanism. After M rounds of calculations by the decoder, the output of the full-line traffic status prediction module is obtained, that is, the full-line traffic status prediction result;
[0022] Furthermore, when the active control plan judged to be effective is uploaded to the data center in step 5, the uploaded information includes event details, speed limit values, signs and text information on the information boards along the entire line, and traffic restriction information at toll stations along the entire line.
[0023] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0024] 1. The present invention provides a method for generating an active control plan for a highway, which uses a neural network model Transformer based on a self-attention mechanism to generate an accurate active control plan in real time according to the traffic status of the entire highway.
[0025] 2. The highway active control plan generation module proposed in the present invention can obtain the traffic status of the entire line, cloud control reporting event information, and initialize the control equipment information of the entire line from the highway data center, and upload the specific active control plan to the data center, so as to realize real-time information interaction with the highway data center.
[0026] 3. The present invention realizes the generation of active management and control solutions based on the neural network model Transformer. The neural network model can process input sequences in parallel, effectively improving the computing efficiency. The self-attention mechanism can capture global context information and has high efficiency, accuracy and stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a system flow chart of a method for generating a highway active control plan based on Transformer according to the present invention.
[0028] Figure 2 This is a schematic diagram of the structure of the active control solution generation module and the full-line traffic condition prediction module of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the application is further elaborated in detail below in conjunction with the accompanying drawings. The described embodiments are only part of the embodiments involved in the present invention. All non-innovative embodiments of other researchers in the field based on this embodiment belong to the protection scope of the present invention.
[0030] The present invention provides a method for generating an active highway control plan based on Transformer, such as Figure 1 As shown, the following steps are included:
[0031] Step 1: Obtain the traffic status of the entire line, cloud control reporting event information, and initialize the control equipment information of the entire line from the highway data center;
[0032] Step 2: The Transformer-based active control solution generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the control equipment of the entire line to initialize and generate the target information of the control objects of the entire line;
[0033] Step 3: Based on the Transformer-based full-line traffic status prediction module, the full-line traffic status and the target information of the full-line control objects are initialized to generate the full-line traffic status prediction results;
[0034] Step 4: Use the output results of the full-line traffic status prediction module to evaluate the generated active control plan, and judge whether the traffic status improvement reaches the threshold by comparing the initialized full-line traffic status with the full-line traffic status results;
[0035] Step 5: If the generated active control plan is judged to be effective, the specific plan will be uploaded to the highway data center.
[0036] In a specific embodiment of the present invention,
[0037] Step 1, obtain the traffic status of the entire line, cloud control reporting event information, and initialize the control equipment information of the entire line from the highway data center; the traffic status of the entire line includes the flow rate, speed, and occupancy information of each monitoring point; the event information reported by the cloud control includes event number, event category, road section range, event occurrence and other information; initialize the control equipment information of the entire line including the initial state information board information (including information board number, layout location stake number, display information, display time) and toll station information (toll station name, main line stake number at the connection between the toll station entrance ramp and the highway). The information obtained from the highway data center, including field name, field type, and field meaning are shown in Table 1:
[0038] Table 1: List of highway data output from the data center
[0039]
[0040] Step 2: The input sequence of the active control solution generation module is processed by the data embedding layer and position coding is added, and the resulting vector is input to the encoder; the encoder is repeated N times to obtain the output of the active control solution generation module encoder; the active control solution generation module decoder obtains the output of the previous step, and the steps in the decoder are repeated N times, and the final output is obtained through linear transformation and standardization. Step 2 includes the following sub-steps:
[0041] Step 2.1, the active control plan generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the control equipment of the entire line, and performs data embedding layer processing on the input sequence. The present invention adopts Embedding word embedding, that is, it is converted into a continuous vector through training, and the position code is added after the data is embedded. The position code is calculated by the following formula:
[0042]
[0043] Where PE represents the position vector; i represents the i-th element in the position vector; pos represents the actual position number of the unit in the sequence; d model Indicates the dimension of the input unit; Indicates frequency.
[0044] Encode each position information, and then add this encoded information to the encoding of the word at the corresponding position, so that the self-attention mechanism can consider the order information of the words while taking into account all the input words; after adding the position encoding, the resulting vector is input into the encoder;
[0045] Step 2.2: The encoder passes through the multi-head attention module to obtain a sequence that effectively focuses on the global information. The specific process is as follows:
[0046] The self-attention mechanism includes three inputs, namely Q (query), K (key), and V (value). First, the corresponding Q, K, and V are calculated according to the input vector. Three different weight matrices are multiplied with the input matrix, and the input matrix is mapped to a new dimensional space. The obtained Q, K, and V calculate the corresponding attention scores and weighted vectors. The formula is as follows:
[0047]
[0048] Where X represents the input matrix.
[0049] After calculating the matrices Q, K, and V, the attention score is calculated by doing the dot product between the query vector q and the other vector k. The calculation formula is as follows:
[0050] score = q·k
[0051] In order to avoid sharp score distribution, numerical scaling is performed, that is, dividing by And perform Softmax normalization on the attention score. Softmax normalization can transform a set of real numbers into a probability distribution. Given a real number vector x = (x 1 , x 2 , …, x n ), the calculation steps of the Softmax normalization formula are as follows: Calculate the exponential value of each element where i = 1, 2, ..., n; sum all index values Calculate the Softmax value of each element Where i = 1, 2, ..., n. Finally, the vector (p 1 , p 2 ,…,p n ) is a probability distribution, where p i Represents x i Through Softmax normalization, larger elements can be mapped to probability values closer to 1, and smaller elements can be mapped to probability values closer to 0, making the probability distribution smoother.
[0052] Multiply the attention score by the v vector of each word to get the weighted representation vector. The calculation formula is as follows:
[0053] z=∑a i v 1
[0054] The overall calculation process formula of the self-attention mechanism is as follows:
[0055]
[0056] After the attention mechanism, we get new encoding vectors with the same number of vectors. Since the new encoding vector uses the attention mechanism, it will take into account the influence of other words on it, and the degree of influence is affected by the attention score.
[0057] For each input, each head will generate an attention matrix. The attention matrices of h heads are concatenated and multiplied with the weight matrix trained with the network to obtain the attention matrix containing all head information. The formula is as follows:
[0058]
[0059] Multihead(Q,K,V)=Concat(head 1 , …, head h )W O
[0060] The sequence obtained after the multi-head attention module is processed is added to the original sequence and then normalized using the Softmax method. The resulting sequence is input into the feedforward neural network and then added and normalized again. This process is repeated N times to obtain the output of the encoder of the active control solution generation module.
[0061] Step 2.3, the decoder of the active control scheme generation module starts calculation and generation after receiving the start symbol; after the decoder obtains the output of the previous step and adds the position code, it is input into the decoder;
[0062] In step 2.4, in the decoder, the sequence is first fed into a masked multi-head attention module, which only focuses on earlier positions in the sequence. The process is as follows:
[0063] The self-attention mechanism links a vector to all vectors in a sequence, thereby extracting more information from the sequence. Unlike the encoder, the decoder only takes the result generated in the previous step as input. The model's attention mechanism should only be related to the vector before the vector, not the vector after it. This is achieved in the present invention by masking all the vectors that have not been predicted by the model. Such a mask helps the self-attention mechanism to pay attention only to the vectors that the model can use during testing. The calculation method of the attention matrix Zi for an attention head i is shown in the following formula:
[0064]
[0065] To calculate the multi-head attention with mask, there are several steps: First, calculate the dot product of the query matrix and the key matrix Afterwards, Matrix divided by the square root of the key vector dimension Get
[0066] Subsequently, the obtained matrix is applied with the Softmax function and the scores are normalized, but before applying the Softmax function, the values need to be masked; subsequently, the Softmax function is applied to the previous matrix and the result is multiplied with the value matrix Vi to obtain the final attention matrix Zi.
[0067] Similarly, calculate h attention matrices, concatenate them, and multiply the result by the new weight matrix W0 to get the final attention matrix M, which is as follows:
[0068] M=Concatenate(Z 1 ,Z 2 ,…,Z 3 )W 0
[0069] After addition and normalization, the data is input into the cross attention layer, and the output of the encoder is input at the same time. The subsequent steps are the same as those of the encoder. The steps in the decoder are repeated N times.
[0070] Step 2.5, after the steps in the decoder are repeated N times, the final output is obtained through linear transformation and standardization processing; the final output includes the target information of the entire line control objects including the target speed limit, signs and dynamic text information of the entire line and the restriction information of the toll station.
[0071] Step 4: The full-line traffic status prediction module inputs the initialized full-line traffic status, and the target information of the full-line control objects output by the active control scheme generation module is concatenated through the Concatenate function and then input into the encoder; the encoder has a similar structure to the active control scheme generation module, and repeatedly executes the multi-head attention layer and the feedforward neural network layer M times; the encoder output is input into the decoder through the cross attention mechanism, and after M rounds of calculation by the decoder, the full-line traffic status prediction module output, i.e., the full-line traffic status prediction result, is obtained;
[0072] Step 5: Use the output result of the full-line traffic status prediction module to evaluate the generated active control plan, and judge whether the traffic status improvement reaches the threshold by comparing the initialized full-line traffic status with the predicted full-line traffic status;
[0073] Step 6: If the generated active control plan is judged to be effective, the specific plan will be uploaded to the data center. The uploaded information includes event details, speed limit values, signs and text information on the information boards along the entire line, and traffic restriction information at toll stations along the entire line. The active control plan information uploaded to the highway data center includes field names, field types, and field meanings as shown in Table 2:
[0074] Table 2: List of active control plan information uploaded to the highway data center
[0075]
[0076]
Claims
1. A method for generating active highway control scheme based on Transformer, characterized in that: The specific steps are as follows: Step 1: Obtain the traffic status of the entire line, cloud control reporting event information, and initialize the control equipment information of the entire line from the highway data center; Step 2: The Transformer-based active control solution generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the initialization of the control equipment of the entire line to generate the target information of the control objects of the entire line; Step 3: Based on the Transformer-based full-line traffic status prediction module, the full-line traffic status and the target information of the full-line control objects are initialized to generate the full-line traffic status prediction results; Step 4: Use the output results of the full-line traffic status prediction module to evaluate the generated active control plan, and judge whether the traffic status improvement reaches the threshold by comparing the initialized full-line traffic status with the full-line traffic status prediction results; Step 5: If the generated active control plan is determined to be effective, the specific plan will be uploaded to the highway data center; The Transformer-based active control solution generation module in step 2 includes the following sub-steps: Step 2.1, the active control plan generation module inputs the traffic status of the entire line, the event information reported by the cloud control, and the information of the control equipment of the entire line, processes the input sequence at the data embedding layer and adds position coding, and inputs the obtained vector into the encoder; Step 2.2: The encoder obtains a sequence that effectively focuses on global information through the multi-head attention module, adds it to the original sequence, and uses the Softmax normalization method to input the obtained sequence into the feedforward neural network, and then performs another addition and normalization. After repeating N times, the output of the encoder of the active control solution generation module is obtained; Step 2.3, the active control scheme generation module decoder starts calculation and generation after receiving the start symbol; After the decoder gets the output of the previous step and adds the position code, it is input into the decoder; Step 2.4: In the decoder, the sequence is first fed into a masked multi-head attention module that focuses only on earlier positions in the sequence. After addition and normalization, it is fed into a cross-attention layer and the output of the encoder. The subsequent steps are the same as for the encoder. The steps in the decoder are repeated N times; Step 2.5, after the steps in the decoder are repeated N times, the final output is obtained through linear transformation and standardization processing; the final output includes the target information of the entire line control objects including the target speed limit, signs and dynamic text information of the entire line and the restriction information of the toll station.
2. According to claim 1, a method for generating a highway active control plan based on Transformer is characterized in that: The data obtained from the highway data center in step 1 includes the traffic status of the entire line, the event information reported by the cloud control, and the initialization information of the control equipment of the entire line; the traffic status of the entire line includes the flow rate, speed, and occupancy information of each monitoring point; the event information reported by the cloud control includes the event number, event category, road section range, and event occurrence information; the initialization information of the control equipment of the entire line includes the initial status information board information and toll station information, among which the initial status information board information includes the information board number, the layout location pile number, the display information, and the display time, and the toll station information includes the toll station name and the main line pile number at the connection between the toll station entrance ramp and the highway.
3. The method for generating a highway active control plan based on Transformer according to claim 1 is characterized in that: In step 2.1, word embedding is used, that is, it is converted into a continuous vector through training, and position coding is added after data embedding. The position coding is calculated by the following formula: Where PE represents the position vector; i represents the i-th element in the position vector; pos represents the actual position number of the position in the sequence; d model Indicates the dimension of the input unit; Indicates frequency; Encode each position information, and then add this encoded information to the encoding of the word at the corresponding position, so that the self-attention mechanism considers the order information of the words while taking into account all the input words; after adding the position encoding, the resulting vector is input into the encoder.
4. The method for generating a highway active control plan based on Transformer according to claim 3 is characterized in that: In step 2.2, the encoder obtains a sequence that effectively focuses on global information through the multi-head attention module, as follows: The self-attention mechanism includes three inputs, namely Q query, K key, and V value. First, the corresponding Q, K, and V are calculated according to the input vector. The three different weight matrices are multiplied by the input matrix to map the input matrix to a new dimensional space. The obtained Q, K, and V calculate the corresponding attention score and weighted vector. The formula is as follows: Where X represents the input matrix; After calculating the matrices Q, K, and V, the attention score is calculated by doing a dot product between the query vector q and the other vectors k. The calculation formula is as follows: score = q·k In order to avoid sharp score distribution, numerical scaling is performed, that is, dividing by And perform Softmax normalization on the attention scores; Softmax normalization converts a set of real numbers into a probability distribution. Given a real number vector x = (x1, x2, ..., x n ), the calculation steps of the Softmax normalization formula are as follows: Calculate the exponential value of each element Where i = 1, 2, ..., n; sum all index values Calculate the Softmax value of each element where i = 1, 2, ..., n; finally, the vector (p1, p2, ..., p n ) is a probability distribution, where p i Represents x i Through Softmax normalization, larger elements are mapped to probability values closer to 1, and smaller elements are mapped to probability values closer to 0, making the probability distribution smoother; The attention score is combined with the v of each word i The vector multiplication results in a weighted representation vector, which is calculated as follows: Z=∑a i in i The overall calculation process formula of the self-attention mechanism is as follows: After the attention mechanism, we get new encoding vectors with the same number of vectors. Since the new encoding vector uses the attention mechanism, it will take into account the influence of other words on it, and the degree of influence is affected by the attention score; For each input, each head will generate an attention matrix. The attention matrices of h heads are concatenated and multiplied with the weight matrix trained with the network to obtain the attention matrix containing all head information. The formula is as follows: head i =Attention(QW i Q ,KW i K ,VW i V ) i=1,2,…,h Multihead(Q,K,V)=Concat(head1,…,head h )W O The sequence obtained after processing by the multi-head attention module is added to the original sequence and then normalized using the Softmax method. The resulting sequence is input into the feedforward neural network and then added and normalized again. After repeating N times, the output of the encoder of the active control scheme generation module is obtained.
5. According to the Transformer-based highway active control plan generation method of claim 4, in step 2.4, in the decoder, the sequence is first input into a masked multi-head attention module, focusing only on the earlier positions in the sequence, as follows: The self-attention mechanism connects a vector to all vectors in the sequence to extract more information from the sequence. Unlike the encoder, the decoder only takes the result generated in the previous step as input. The model's attention mechanism should only be related to the vectors before the vector, not the vectors after it. This is achieved by masking all the vectors that have not been predicted by the model. Such a mask helps the self-attention mechanism pay attention only to the vectors used by the model during testing. The calculation method of the attention matrix Zi for an attention head i is shown in the following formula: To calculate the multi-head attention with mask, there are several steps: First, calculate the dot product of the query matrix and the key matrix Afterwards, Matrix divided by the square root of the key vector dimension Get Afterwards, the obtained matrix is applied with the Softmax function and the scores are normalized, but before applying the Softmax function, the values need to be masked; Afterwards, the Softmax function is applied to the previous matrix and the result is multiplied by the value matrix Vi to obtain the final attention matrix Zi; Similarly, calculate h attention matrices, concatenate them, and multiply the result by the new weight matrix W0 to get the final attention matrix M, which is as follows: M=Concatenate(Z1,Z2,…,Z3)W0 After addition and normalization, the data is input into the cross attention layer, and the output of the encoder is also input. The subsequent steps are the same as those of the encoder. The steps in the decoder are repeated N times.
6. The method for generating a highway active control plan based on Transformer according to claim 1 is characterized in that: The Transformer-based full-line traffic status prediction module in step 3 includes the following sub-steps: Step 3.1, the full-line traffic status prediction module inputs the initialization of the full-line traffic status, and concatenates the target information of the full-line control objects output by the active control plan generation module through the Concatenate function and then inputs it into the encoder; The encoder has a similar structure to the active control scheme generation module, and repeatedly executes the multi-head attention layer and feedforward neural network layer M times; In step 3.2, the encoder output is input into the decoder through the cross-attention mechanism. After M rounds of calculations by the decoder, the output of the full-line traffic status prediction module is obtained, that is, the full-line traffic status prediction result.
7. The method for generating a highway active control plan based on Transformer according to claim 1 is characterized in that: When the active control plan judged to be effective is uploaded to the data center in step 5, the uploaded information includes event details, speed limit values, signs and text information on the information boards along the entire line, and traffic restriction information at toll stations along the entire line.
Citation Information
Patent Citations
Control method and system based on V2X road network
CN113327421A
Traffic control method and device and electronic equipment
CN114333332A
Intersection traffic organization aided design system and device based on digital case library
CN115329664A
Highway traffic flow prediction method based on Transform and graph attention network
CN116092294A
Vehicle trajectory prediction method based on spatio-temporal characteristics, geographic semantics and driving state
CN117407711A
