An emergency vehicle priority and queuing optimization collaborative control method
By using a multi-objective reinforcement learning algorithm based on the LSTM-Transformer-PPO model to dynamically generate signal timing strategies, the problem of emergency vehicles struggling to pass through saturated traffic during peak hours is solved. This enables coordinated control of rapid and safe passage for emergency vehicles and optimization of queuing for other vehicles, thereby improving the operational efficiency and emergency response capabilities of the urban road network.
Patent Information
- Application Number
- CN202511759932.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2045-11-27
AI Technical Summary
During peak traffic hours, emergency vehicles are prone to congestion in urban core areas and main roads. Existing signal priority control strategies disrupt traffic flow balance under saturated flow conditions, leading to increased difficulty for emergency vehicles to pass and a surge in queues for other vehicles. Existing methods are unable to achieve coordinated control of rapid and safe passage for emergency vehicles and optimization of queues for other vehicles under peak saturated flow scenarios.
A dual-branch traffic prediction model integrating LSTM and Transformer architectures is adopted, combined with a PPO agent, and a multi-objective reinforcement learning algorithm is used to dynamically generate signal timing strategies. This enables dynamic priority allocation of emergency vehicles and adaptive optimization of phase timing for social vehicles. A segmented reward function is constructed to collaboratively optimize the passage of emergency vehicles and the queuing of social vehicles.
It significantly improves the operational efficiency of intersections under complex traffic loads, enhances the response efficiency of emergency vehicles, alleviates delays and queues of social vehicles, achieves balanced traffic flow in multiple directions, and improves the overall traffic capacity of the urban road network.
Smart Images

Figure CN121214701B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation technology, and in particular relates to a method for coordinated control of emergency vehicle priority and queuing optimization. Background Technology
[0002] During peak traffic hours, urban core areas and main roads generally experience high traffic loads. Emergency vehicles performing urgent tasks are highly susceptible to getting stuck at congestion points and bottlenecks, significantly increasing response time and exacerbating the risk of loss of life and property. Therefore, implementing signal priority right-of-way for emergency vehicles at intersections with saturated traffic flow to ensure their safe and efficient passage is urgently needed. However, under saturated traffic conditions, the absolute priority behavior of emergency vehicles (such as forced green light extensions or red light cutoffs based on phase-preemption strategies) significantly disrupts existing signal timing schemes at intersections, breaking the fragile balance of traffic flow. Especially when queue lengths at each approach lane are close to saturation, such interference can easily induce a surge in queues in specific directions, further worsening congestion. Therefore, how to coordinate the dual objectives—ensuring the rapid and safe passage of emergency vehicles and simultaneously optimizing the timing and queuing of other vehicles—becomes the core challenge of emergency priority control during peak hours. The unique characteristic of intersections during peak hours is that queues in all directions are generally under high pressure, and traffic arrival rates fluctuate greatly. This not only increases the difficulty of passage for emergency vehicles but also amplifies the negative traffic effects of priority strategies. Compared to traditional signal control research, which focuses on the smooth transition of timing schemes in steady-state scenarios, the fundamental problem in emergency priority scenarios transforms into how to complete a two-stage operation of spatiotemporal coordination within an extremely small time window:
[0003] 1. Right-of-way priority control: Emergency vehicles are given absolute right-of-way through the signal priority control mechanism to ensure that they have priority passage at intersections.
[0004] 2. Queue optimization control: After emergency vehicles pass through the intersection, the signal timing needs to be dynamically optimized in real time. By reconstructing the phase sequence and adaptively adjusting the green light duration, the queue of the disturbed phases is actively controlled, and the traffic efficiency of the intersection during peak hours is optimized.
[0005] Therefore, signal control strategies in emergency priority scenarios should be able to minimize delays for emergency vehicles and efficiently dissipate and balance queues of other vehicles in saturated traffic conditions through multi-objective optimization mechanisms. This requires the strategy to not only respond to the needs of emergency vehicles but also accurately predict and quickly intervene in the disturbances caused by priority behavior to social traffic flow, maximizing road network resilience while ensuring rescue efficiency.
[0006] Currently, research on emergency vehicle right-of-way priority control both domestically and internationally mainly forms three methodological systems: traditional transition strategies (covering schemes such as direct transition, green light duration adjustment, phased transition, and smooth transition), optimized control models (signal control methods based on multi-objective functions), and intelligent adaptive algorithms (control strategies with dynamic optimization capabilities). While traditional strategies demonstrate practicality in regular traffic scenarios, they face risks of dynamic response lag and queue control failure under peak-hour saturated traffic conditions. Optimized control models, although capable of constructing multi-objective functions, suffer from algorithmic efficiency bottlenecks due to the diversity of objectives under saturated conditions, making it difficult to achieve coordinated control at complex intersections. Intelligent adaptive algorithms, while dedicated to the coordinated optimization of emergency priority and social vehicle traffic management, still suffer from high computational complexity and insufficient real-time performance. Existing research generally lacks comprehensive consideration of the following three aspects: insufficient adaptability to saturated scenarios, lack of multi-agent collaborative optimization, and limited proactive control capabilities. Summary of the Invention
[0007] The purpose of this invention is to provide a collaborative control method for emergency vehicle priority and queuing optimization, which achieves multi-objective collaborative optimization of minimizing delays of social vehicles, queuing equalization, and overflow prevention while ensuring low-delay passage of emergency vehicles; and improves the response efficiency of emergency vehicles and the queuing efficiency of entrance lanes during peak hours.
[0008] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is a collaborative control method for emergency vehicle priority and queuing optimization, which is carried out according to the following steps:
[0009] S1. Construct a road network topology model of road intersections and collect multi-source traffic status data;
[0010] S2. Preprocess the collected data and extract multi-source heterogeneous features to construct a standardized feature vector;
[0011] S3. Construct a time series dataset based on the preprocessed data;
[0012] S4. Establish a two-branch traffic prediction model that integrates LSTM and Transformer architectures:
[0013] S5. Train the dual-branch traffic prediction model; use a multi-task mean square error loss function that includes queue evolution prediction loss and emergency vehicle operation status prediction loss to optimize and fuse the parameters of the dual-branch traffic prediction model until convergence.
[0014] S6. Construct a PPO intelligent agent, wherein the state space of the PPO intelligent agent integrates real-time traffic conditions, historical observation data and the prediction results of the dual-branch traffic prediction model;
[0015] S7. Design a segmented reward function to guide the PPO agent to perform multi-objective collaborative optimization, and balance the priority of emergency vehicles and the optimization objectives of social vehicles through dynamic weight coefficients.
[0016] S8. Train the PPO agent; The PPO agent interacts with the traffic simulation environment to sample trajectory data, determines the excess revenue of state actions through advantage function estimation, and combines pruning to optimize the target update policy network and value network parameters.
[0017] S9. Deploy the trained dual-branch traffic prediction model, input real-time collected traffic state data, and obtain the future lane queuing evolution trend and emergency vehicle trajectory prediction results; Based on the real-time traffic state data and the prediction results, the PPO agent outputs signal phase selection and green light duration decisions, and controls the traffic lights to execute the corresponding timing scheme. The signal phase selection only switches between the four main green light phases to achieve priority passage for emergency vehicles and optimization of social vehicle queuing.
[0018] Furthermore, the central intersection adopts a four-stage eight-phase timing scheme, which includes two straight-to-left phases in the east-west direction and two straight-through and left-turn phases in the north-south direction. The lengths of the four approach lanes of the central intersection are 800m, 450m, 386m, and 400m, respectively. One straight-through lane and one left-turn lane are selected as the research and control objects for each approach lane. The traffic simulation environment uses the SUMO simulation platform, with a simulation duration of 1 hour. The multi-source traffic state data output from the simulation is saved as a CSV file.
[0019] Furthermore, S2 specifically involves constructing synthetic features of queue / flow ratio and net growth queue through feature engineering, removing redundant information through correlation analysis, mutual information evaluation, VIF multicollinearity detection and feature importance screening, and then normalizing the features to obtain a standardized feature vector.
[0020] Among them, standardized feature vector for:
[0021]
[0022] in, It is a very small constant. This represents the mean of the features across each dimension in the training set. The standard deviation of each dimension of the features in the training set. These are the feature vectors before standardization.
[0023] Furthermore, in S3, the specific process of constructing the time series dataset is as follows:
[0024] Let the original time series data be:
[0025] (2)
[0026] in, express The input at any given time is the feature vector of all lanes. express The length of the output queue at any given time. Indicates the length of the time series;
[0027] Establish the input sequence for each time step and predict target sequence :
[0028]
[0029]
[0030] The final dataset for:
[0031] (5)
[0032] in, Indicates the length of the input time series. Indicates the length of the output time series.
[0033] Furthermore, the dataset is divided into a training set and a test set in a 7:3 ratio.
[0034] Furthermore, in S4, the dual-branch traffic prediction model includes an LSTM encoder, a Transformer encoder, and a dual-branch prediction head. The LSTM encoder captures the local temporal dynamics of traffic flow, the Transformer encoder captures the global spatiotemporal dependence, and the dual-branch prediction head outputs the prediction results of the lane queuing evolution trend and the trajectory status of emergency vehicles in the future time period, respectively.
[0035] The LSTM encoder has 112 hidden layers and a total of 3 layers.
[0036] The Transformer encoder has 3 layers, 4 attention heads, a feedforward layer size of 128, a dropout rate of 0.1, an output window of 5, and a state prediction output dimension of 2 for each emergency vehicle.
[0037] Furthermore, the multi-task mean squared error loss function in S5 Specifically:
[0038]
[0039] in, These are uncertainties between tasks, used to represent the difficulty of each task. This is a regularization term for the uncertainty variable, used to constrain the model's estimation of uncertainty. Predicting loss for queue evolution:
[0040]
[0041] in, and They represent the first The predicted value output at the predicted time, the first prediction time. Output the true value at each predicted time point;
[0042] Predicted losses based on emergency vehicle operational status: Assuming each emergency vehicle It contains 4 predictor variables, totaling For vehicles, the emergency prediction dimension is: ,but:
[0043]
[0044] in, and They represent the first The predicted output of the first emergency vehicle, the first The actual output value of each emergency vehicle. This indicates the dimension of emergency prediction.
[0045] Furthermore, the final state of the PPO agent in S6 Represented as:
[0046]
[0047] in, For the time The normalized original input states include the queue length of the main road lanes, vehicle waiting time, lane flow, one-hot encoding of signal status, intersection throughput, simulation time, and the lane, position, and speed of emergency vehicles; Additional indicators to assist strategies in determining when to make decisions based on forecast information; To refine the future The temporal correlation encoding vector of the step; This is a vector concatenation operation.
[0048] Furthermore, the segmented reward function in S7 Including emergency vehicle rewards Social vehicle rewards Phase switching penalty Combinations:
[0049] (10)
[0050] in, For a moment An adaptive weighting coefficient is used between the two types of rewards: emergency priority and social vehicle queuing optimization. Specifically:
[0051]
[0052] in The distance from the emergency vehicle to the intersection is represented by exp, which is the natural exponential function. The maximum delay constant, Parameters used to control the steepness of the curve.
[0053] Furthermore, the aforementioned emergency vehicle reward Specifically:
[0054] (12)
[0055] in, and Indicates that if the emergency vehicle is at the right time The signal for the lane is green or yellow; a value of 1 indicates the corresponding light color, otherwise a value of 0. , They are respectively and Component weights; Indicates the speed increment. for The weight, The increment of the potential function, for The weights;
[0056] The social vehicle reward Specifically:
[0057]
[0058]
[0059]
[0060] in, This represents the increase in outflow volume for this step; These are the component weights for maximum queueing potential difference, normalized delay, queueing balance potential difference, and normalized number of departing vehicles, respectively. To shape the overall strength of society; The maximum observable outflow rate; Average lane waiting time; The maximum delay constant; The difference of the maximum queuing potential function; The difference of the potential function for queuing equilibrium; Core rewards for social vehicles; Shaping rewards for the potential function of social vehicles;
[0061] The phase switching penalty Specifically:
[0062] (16)
[0063] in, This indicates the duration of the green light. The effective distance threshold indicating emergency priority Indicates the tolerance threshold. Indicates the phase switching penalty weight. This indicates the upper limit of tolerance for the effective distance threshold for emergency priority.
[0064] Furthermore, the process of determining the dominance function in S8 is specifically as follows:
[0065] (17)
[0066] In the state Take action below The immediate reward received afterward; This is a discount factor used to attenuate the impact of future value. For the value network to the next state The estimate; For the value network to the current state The estimate;
[0067] The overall optimization objective of the PPO agent is: :
[0068] (18)
[0069] in, This indicates the addition of a policy entropy term to encourage exploration. and These represent the value loss coefficient and the entropy coefficient, respectively. Tailor the target to the strategy; This represents the loss function of the value.
[0070] Compared with existing technologies, the beneficial effects of this invention include the following aspects: This invention constructs a multi-dimensional traffic state perception system covering the central intersection and the four directly associated peripheral intersections' approach lanes, integrating key features such as queue length, traffic flow, signal timing status, and emergency vehicle operation information to achieve refined modeling and real-time analysis of the lane-level traffic flow evolution process. Based on this, the invention employs the Proximal Policy Optimization (PPO) multi-objective reinforcement learning algorithm to dynamically generate differentiated signal timing strategies based on the predicted traffic state parameters. This enables adaptive optimization of dynamic right-of-way priority allocation for emergency vehicles and phase timing for social vehicles, significantly improving the operational efficiency and responsiveness of intersections under complex traffic loads.
[0071] This invention designs a dual-branch neural network model that integrates LSTM and Transformer architectures. The model receives standardized multi-feature time-series data at the input layer, utilizes the LSTM module to capture the fundamental temporal dynamics of traffic flow, and introduces the Transformer's self-attention mechanism to enhance the extraction of key spatiotemporal features. A customized gating fusion mechanism further leverages the advantages of both approaches. The model employs a dual-branch structure to output predictions of lane-specific queuing evolution trends and emergency vehicle state parameters, respectively, meeting the differentiated needs of heterogeneous traffic entities in terms of prediction accuracy and timeliness.
[0072] This invention constructs a segmented reward function mechanism, decoupling the signal control process into two collaborative optimization stages: Emergency Vehicle Priority (TSC) and Social Vehicle Queue Management (TSC) Recovery. It leverages the temporal decision-making capabilities of the PPO algorithm to achieve multi-objective joint optimization. This design effectively avoids the "curse of dimensionality" problem caused by excessively high state space dimensionality in traditional methods. In urban road network scenarios with high saturation traffic, especially during peak hours and emergency response situations, this invention can significantly improve the passage efficiency of rescue vehicles while alleviating delays and queue accumulation for social vehicles, achieving balanced traffic flow in multiple directions and improving overall traffic capacity. It has broad application prospects in intelligent traffic control of complex urban road networks. Attached Figure Description
[0073] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. 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 effort.
[0074] Figure 1 This is a flowchart of the overall process of the method of the present invention;
[0075] Figure 2 This is a SUMO simulation road network topology diagram;
[0076] Figure 3 It is a heatmap of key feature correlations;
[0077] Figure 4 The diagram shows the lane-level queue evolution prediction results for the centrally controlled intersection. (a) compares the predicted queue value for lane E00_0 with the true value (MAE=0.43, RMSE=0.73); (b) compares the predicted queue value for lane E00_1 with the true value (MAE=1.01, RMSE=1.69); (c) compares the predicted queue value for lane E04_0 with the true value (MAE=0.33, RMSE=0.62); and (d) compares the predicted queue value for lane E04_1 with the true value (MAE=0.9). (e) Comparison of lane queuing prediction and true value for lane E05_0 (MAE=0.21, RMSE=0.42); (f) Comparison of lane queuing prediction and true value for lane E05_1 (MAE=0.47, RMSE=0.83); (g) Comparison of lane queuing prediction and true value for lane E06_0 (MAE=0.29, RMSE=0.55); (h) Comparison of lane queuing prediction and true value for lane E06_1 (MAE=0.84, RMSE=1.55).
[0078] Figure 5 This is a convergence curve of lane-level queue evolution prediction at a centrally controlled intersection;
[0079] Figure 6 It is a convergence curve of emergency vehicle trajectory state prediction;
[0080] Figure 7 The following are scatter plots of the prediction errors of the trajectory state parameters of emergency vehicles; where (a) is a scatter plot of the predicted position of emergency vehicles (ty2.0, raw meters); (b) is a scatter plot of the predicted speed of emergency vehicles (ty2.0, raw meters / second); (c) is a scatter plot of the predicted position of emergency vehicles (ty1.0, raw meters); and (d) is a scatter plot of the predicted speed of emergency vehicles (ty1.0, raw meters / second).
[0081] Figure 8 It is a heat map of lane-level queuing balance at a centrally controlled intersection;
[0082] Figure 9 This is a graph showing the change in entropy of the PPO agent. Detailed Implementation
[0083] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0084] This embodiment provides a collaborative control method for emergency vehicle priority and queuing optimization at intersections. Specifically, it is a collaborative control method for emergency vehicle priority and queuing optimization at intersections based on the fusion of LSTM-Transformer-PPO. This embodiment is designed for an integrated "priority-guidance" signal control framework for saturated intersections during peak hours. By integrating the LSTM-Transformer algorithm model architecture, it achieves queuing evolution prediction and emergency vehicle operation status prediction through multiple feature inputs. Based on the PPO algorithm, it dynamically generates signal control strategies, fully considering the diversity of optimization objectives and subjects. Based on the traffic flow and queuing characteristics during urban peak hours, it separates and connects the priority of emergency vehicles and the queuing optimization process of social vehicles. It uses deep reinforcement learning to predict the queuing evolution of each approach lane, while predicting the trajectory information such as the position and speed of emergency vehicles. Based on the prediction results, it performs hierarchical control of traffic lights and rapid connection to the queuing optimization of social vehicles after the emergency vehicles pass smoothly.
[0085] In some specific implementations, the emergency vehicle priority and queuing optimization coordinated control method is as follows: Figure 1 As shown:
[0086] S1. Construct a road network topology model of road intersections and collect multi-source traffic status data. The research scenario and data acquisition module functions specifically include road network information acquisition, traffic flow collection and preprocessing, simulation operation, and export of traffic status information.
[0087] S101. Construct the road network topology of road intersections. In this embodiment, the research scenario is an intersection area under saturated traffic flow in an urban road network; this includes determining the number, type, number of lanes, speed range, signal timing scheme, and traffic flow of each intersection, etc. The road network topology is as follows: Figure 2 , Figure 3 As shown.
[0088] The road network topology model of the described intersection is an associated area of five intersections (including the central intersection and four peripheral intersections directly connected to it). The controlled intersection uses a four-stage, eight-phase timing scheme, including two straight-to-left phases in the east-west direction and two straight-through and left-turn phases in the north-south direction. The lengths of the four approach lanes of the central intersection are 800m, 450m, 386m, and 400m, respectively. Each direction is an urban arterial road with multiple straight-through and left-turn lanes. There are non-motorized vehicle lanes, dedicated right-turn lanes, and pedestrian crossings. It is a typical signalized intersection on an urban arterial road with heavy traffic during peak hours. The speed limit on the arterial road is 50-60km / h. Based on preliminary data surveys, this embodiment selects one typical straight-through and left-turn lane for each approach lane as the main research and control object during implementation. Several traffic paths were defined, flowing from one peripheral intersection to another, passing through a central intersection. The traffic demand for each path exhibited saturation flow characteristics. This flow data was obtained from field surveys and statistics. The road network and traffic flow parameter files established in SUMO were saved for subsequent reading and use by the LSTM-Transformer traffic prediction model and the PPO control optimization model. The specific road network topology is as follows: Figure 2 As shown.
[0089] S102. Obtain traffic status data. Use the road network and traffic data to conduct a 1-hour simulation test to obtain real-time traffic flow data. Export the traffic status information of each intersection approach lane required for model training from SUMO (including queue length, traffic volume, phase status, phase remaining time, headway (mean, median, 85th percentile), headway at the stop line, emergency vehicle status information (speed, position, phase information, headway), etc.), and save it as a CSV file for subsequent data preprocessing.
[0090] S103, Data Preprocessing.
[0091] In this embodiment, the data preprocessing involves taking the acquired raw data (mainly targeting the feature engineering required for queuing prediction), including the queue length, traffic flow, signal light information, and the corresponding headway and headway of each approach lane, and other feature information required for queuing prediction, and performing multi-dimensional feature analysis. The system evaluates the feature value and feature coherence, reduces redundant information, improves prediction efficiency, and finally outputs correlation indicators between different features.
[0092] In some specific implementations, the data processing involves inputting the raw traffic state data related to queue prediction obtained from SUMO in step S102, covering key features such as queue lengths at five intersections, traffic flow and signal light information, and headway and headway at each approach lane. The preprocessing side then conducts domain-knowledge-driven feature engineering to construct synthetic features such as queue / flow ratio and net growth queues to enhance prediction sensitivity and interpretability. Based on this, through correlation analysis, mutual information evaluation, and VIF multicollinearity detection, combined with random forest importance, SHAP value interpretation, and stability selection, the system evaluates feature value and relevance, reducing data redundancy and improving modeling efficiency. According to information theory and statistical significance principles, key prediction factors are identified lane-by-lane; for example, in the target prediction lane E04_0, the focus is on its own lane queue state (E04_0_queue) and upstream traffic flow (E04_0_up_E08_1_queue). The output side generates an index matrix and scoring results regarding the correlation between different features (including mutual information score, VIF report, importance and stability ranking, and SHAP contribution overview). Based on this, the key feature set and interpretation framework for each lane are determined, providing data-driven support for intelligent transportation system optimization. This data is saved as a new CSV file for subsequent use by the LSTM-Transformer traffic prediction model. For specific feature engineering correlation analysis, see [link to relevant documentation]. Figure 4 (a)~(h) show that the model performs well overall in predicting queue length, with relatively ideal prediction results. The prediction error in most scenarios does not exceed one car, and the error in other cases is also basically controlled within the range of 1 to 2 cars, demonstrating that the model has high accuracy and strong practicality.
[0093] S2. System initialization and configuration module for the dual-branch traffic prediction model integrating LSTM and Transformer architecture. First, the prediction model in this embodiment consists of two algorithmic parts (LSTM and Transformer), employing a temporal prediction framework of single encoder + dual-branch decoding. It comprises an LSTM encoder (local temporal modeling), a Transformer encoder (global dependency modeling), and a dual-branch prediction head (queue prediction and emergency vehicle trajectory state prediction). The specific architecture and prediction design of this model will be explained in detail in step S5. In this step, data loading is completed by reading the previously created feature engineering CSV file, road network configuration, traffic flow definition, model save files, and parameter configurations.
[0094] S201. Read the configuration file and parameters. Load traffic flow data and road network topology information (including the CSV file saved in configuration file S102 after data preprocessing, and various road network, traffic flow, and other files and parameters generated when establishing the road network topology in S101), define the mapping relationships between intersections and the mapping relationships between each approach lane and traffic lights. Set the output window size of the LSTM-Transformer traffic prediction model to 5, the input window size to 30, the batch size to 32, and the number of training epochs (50 epochs for the first training session).
[0095] S202, Emergency Vehicle Configuration. Define the type information and list data of emergency vehicles, and design the mapping and driving routes of emergency vehicles on lanes.
[0096] S203. Save the LSTM-Transformer traffic prediction model configuration. Save the model's specific configuration information as a JSON file, including the size of the input and output windows, the dimensions of the emergency vehicle data output, the center lane, and the emergency vehicle list, etc.
[0097] S3. Feature Engineering Processing Module. This module preprocesses the input intersection and emergency vehicle status information and normalizes and standardizes the multi-feature data. Since feature engineering involves multi-source heterogeneous data, this module performs multi-source heterogeneous feature extraction and state representation. In this implementation, the traffic intersection prediction problem is viewed as a multi-source heterogeneous time-series modeling task: on one hand, it introduces main queue data (queue length, flow rate, remaining phase time, etc. for each approach lane) and the queue and signal status of its upstream adjacent intersections; on the other hand, it incorporates the full-process trajectory information of emergency vehicles (EVs) (lane ID, signal status, position, speed, remaining phase, etc.). These data sources contain both continuous numerical features with varying scales and distributions at the same time step, as well as high-dimensional category and state features obtained through one-hot conversion, and are then concatenated into a fixed-length time-series input through a sliding window. After normalization and standardization, the above multimodal inputs are fed into a dual-branch LSTM-Transformer framework to capture the spatial correlation and temporal dependency of time series information, thereby enabling joint prediction of the behavior of regular queues and emergency vehicles in complex traffic scenarios.
[0098] S301. First, initialize the feature container and define the global feature matrix as an empty list.
[0099] S302. Construct feature vectors; iterate through all lanes and time steps, for any lane... Time step Construct a set of input feature vectors :
[0100] (1)
[0101] in:
[0102] The current queue length;
[0103] : Current lane signal status One-hot encoding (red, green, yellow);
[0104] : Remaining time of the current lane signal phase;
[0105] Traffic flow in the current lane;
[0106] Queue length of the corresponding lane at the upstream associated intersection;
[0107] One-hot encoding of the corresponding lane signal status at the upstream associated intersection;
[0108] : Remaining time of the corresponding lane signal phase at the upstream associated intersection;
[0109] In addition, in the above feature vectors For the trajectory characteristics of emergency vehicles, for each emergency vehicle ,extract:
[0110]
[0111] in:
[0112] The lane where the emergency vehicle is currently located;
[0113] The position of the emergency vehicle in the current lane;
[0114] Instantaneous velocity;
[0115] The status of the traffic lights in the current lane.
[0116] S303, Standardization Processing; Assume the total time step is... The input feature vector at each time step is The data matrix composed of all the sample matrices is:
[0117] (3)
[0118]
[0119] in, For lane collection, This indicates the total number of lanes.
[0120] All input features need to be normalized before entering the LSTM-Transformer traffic prediction model to avoid the adverse effects of numerical scale differences on model training, especially for scale-sensitive parameter optimization in the LSTM and attention modules. To accelerate convergence and improve training stability, this implementation applies the following standardization formula to all numerical features: Let the mean and standard deviation of each dimension of the features in the training set be: Let d be a d-dimensional real vector space, then the standardized eigenvectors are... for:
[0121]
[0122] in, It is a very small constant to prevent division by zero. For a moment For the lane Dimensional input feature vector.
[0123] Therefore, for each dimension The specific mean and standard deviation are calculated as follows:
[0124]
[0125] N represents the Nth time step; Indicates the first The observation (or time step) at the ... The original values on each feature dimension.
[0126] The normalized sample is obtained as follows:
[0127]
[0128] This is the numerical stability term, which is usually set to 0. .
[0129] This represents the d-th component of the input feature vector of the l-th lane at time t. In this embodiment, the corresponding normalized lane queue length in the feature arrangement is... .
[0130] S4. Establish the dataset construction module. This module defines and initializes the lane queue dataset, completes the basic parameter settings, loads the queue and stored feature data, calculates various functions, transforms data, and forms the final multi-feature data for model training input.
[0131] S401. After completing multi-source feature extraction and standardization, the continuous time series needs to be organized into supervised learning samples acceptable to the LSTM-Transformer traffic prediction model, specifically including the input sequence and the corresponding prediction target. Let the original time series data be:
[0132] (7)
[0133] :express Input of all lane feature vectors at time step
[0134] : Describes the length of the output queue (prediction target) at the corresponding time.
[0135] To construct a time series prediction task, a sliding window approach is used to generate training samples. For each time step, the input sequence and the target prediction sequence are defined as follows:
[0136] (8)
[0137] (9)
[0138] The final dataset for:
[0139] (10)
[0140] When constructing the data, iterate through the starting point of the time window. and each group As samples, they are added to the training set. Indicates the length of the time series. Indicates the length of the input time series. Indicates the length of the output time series. This represents "the maximum value of the starting index minus 1" when constructing samples using a sliding window. Equivalently, it reflects the remaining time steps the window can slide. Therefore, This indicates the number of samples that can be formed.
[0141] S402, Tensor Transformation. For batch training of the input deep learning model, all input features and output targets need to be converted into floating-point tensor representations:
[0142] (11)
[0143] (12)
[0144] in, The matrix space representing the input time window samples. The vector space representing the output (prediction) time window is 32 floating-point numbers.
[0145] The final training sample pairs are:
[0146] (13)
[0147] in, Indicates the number of data samples processed at one time (batch size). Let represent the Cartesian product space of mini-batch training samples.
[0148] Furthermore, to accommodate the batch training process of the model, all samples will be further organized into fixed-size mini-batches and loaded using the DataLoader mechanism. The training and test sets are typically split by the DataLoader in a 7:3 ratio to ensure the model's generalization ability is evaluated on unseen data.
[0149] S5. Establish a dual-branch traffic prediction model architecture that integrates LSTM and Transformer architectures; train the model using the dataset to predict future time-period lane queuing evolution trends and emergency vehicle trajectory states. Define the class for the LSTM_Transformer model, complete model initialization, set the encoding, and construct the dual output branches.
[0150] S501. Initialization function. Set the input dimension of the LSTM_Transformer prediction model to d, the hidden layer of the LSTM encoder to 112, the total number of layers to 3, the number of Transformer encoder layers to 3, the number of attention heads to 4, the feedforward layer size to 128, the dropout rate to 0.1, the output window to 5, and the output dimension of the state prediction for each emergency vehicle to 2.
[0151] S502. Establish the LSTM model encoding module;
[0152] LSTM is used to model local temporal dependencies. The LSTM gate unit computation within time step t includes the input gate, forget gate, output gate, candidate state, updated state, and hidden state output. The specific computation content is as follows:
[0153] Input Gate:
[0154]
[0155] Forgotten Gate:
[0156]
[0157] Output gate:
[0158]
[0159] Candidate state:
[0160]
[0161] Update status:
[0162] (18)
[0163] Output hidden state:
[0164] (19)
[0165] in:
[0166] :time The input feature vector;
[0167] :time Hidden state (output)
[0168] The previous moment Hidden state (output from the previous time step);
[0169] The previous moment Unit status;
[0170] : : Input gate, forget gate, output gate;
[0171] Candidate cell status;
[0172] :time The unit state;
[0173] The weight matrix and bias of the input gate;
[0174] The weight matrix and bias of the candidate states;
[0175] : Weight matrix and bias of the output gate;
[0176] Weight matrix and bias of forget gate;
[0177] : sigmoid activation function;
[0178] (): Hyperbolic tangent (tanh) activation function;
[0179] Element-wise multiplication.
[0180] Output sequence This serves as the input for the next stage. Based on the parameters of the initialization function from the previous step, the encoder parameters (input dimension, hidden layers, and dropout rate, etc.) are set for the LSTM. Additionally, the positional encoding module is configured, with the relevant parameters consistent with the encoder.
[0181] S503. Establish the Transformer encoder module. The Transformer encoder is used for global dependency modeling, specifically to capture the global spatiotemporal dependencies of traffic flow. Its input design (the concatenated matrix) is as follows:
[0182] (20)
[0183] in, Form a shape for all real number elements. OK, A set of matrices for each column. Then, the time steps... The LSTM output (hidden state) and the position encoding at that time step By performing element-wise addition, we obtain a representation with positional information. This is used in the Transformer self-attention module below:
[0184]
[0185] The self-attention mechanism of the Transformer model is key to global temporal pattern learning, and the dimensionality of feature engineering determines the number of attention points:
[0186]
[0187] The attention setting in this implementation is:
[0188] (twenty three)
[0189] Transpose of a matrix
[0190] Multi-head attention is then expressed as:
[0191] (twenty four)
[0192] The design of its residual connection and feedforward network is expressed as follows:
[0193]
[0194] in:
[0195] : The output or input matrix of the previous layer, and , number of rows For time series length, dimension (In this embodiment, the original multi-lane and emergency features are uniformly mapped to this dimension after linear embedding or LSTM encoding.)
[0196] : Projection matrix, Published into the Query, Key, and Value spaces;
[0197] Scaling factor;
[0198] : No. The size of the attention output;
[0199] The weights of multiple heads spliced together and then linearly projected;
[0200] : These represent the weights and biases of the first layer, respectively. Similarly);
[0201] Activation function.
[0202] The final model will output This is the final prediction output of the Transformer model (taken at the last time step). Additionally, the encoder settings remain consistent with the initial model settings.
[0203] S504, dual-branch prediction structure. The ZT connection output of the Transformer module connects two fully connected layers: one for queue length prediction and the other for the other.
[0204] (26)
[0205] Emergency vehicle status prediction output:
[0206] (27)
[0207] in: These represent the output weights and biases of the queue prediction, respectively. ).
[0208] S505, Loss Function and Training Objective: The LSTM-Transformer traffic prediction model uses a dual-branch prediction structure to read multiple feature engineerings and complete multi-layer prediction tasks. Therefore, a multi-task mean squared error loss function is used for joint training.
[0209] Task 1: Predict the loss of queue evolution, using Mean Squared Error (MSE) to measure the difference between the model's predicted queue length and the actual value.
[0210]
[0211] in, and They represent the first The predicted value output at the predicted time and the predicted value at the predicted time. Output the true value at each predicted time.
[0212] Task 2: Predicting losses based on the operational status of emergency vehicles, assuming each emergency vehicle... It contains 4 predictor variables (see Formula 2), totaling For vehicles, the emergency prediction dimension is: Emergency vehicle predicted losses are defined using the MSE (Mean Self-Effective) form:
[0213]
[0214] in, and They represent the first The predicted output of the first emergency vehicle and the first The actual output value of each emergency vehicle. This indicates the dimension of emergency prediction.
[0215] Finally, the weighted multi-task approach yields the following total loss function:
[0216]
[0217] in The weighting parameter represents the preference for the importance of queue length and emergency prediction tasks. Let be the set of positive real numbers. To enhance model stability and adaptability, inter-task uncertainty variables are introduced. Indicates the difficulty of each task. Here, we have an uncertainty regularization term used to constrain the estimation of uncertainty; the optimization objective becomes:
[0218]
[0219] This loss form originates from multi-task Gaussian uncertainty modeling, which helps with the automatic balancing of weights.
[0220] S6. Evaluation Metrics Setting. To comprehensively measure the model's performance in traffic prediction tasks, this implementation uses the following commonly used metrics: Training Loss (HuberLoss):
[0221]
[0222] Mean Absolute Error (MAE):
[0223]
[0224] Mean Absolute Percentage Error (MAPE):
[0225]
[0226] S7. Training the LSTM-Transformer Traffic Prediction Model. The main training process for the LSTM-Transformer traffic prediction model is divided into two phases: training and testing. During training, the model calculates the prediction output through forward propagation, evaluates the prediction errors of queue length and emergency vehicle status using a loss function, updates parameters through backpropagation and gradient pruning, and periodically saves the model and output training loss. During testing, the model performs inference with fixed parameters, collects and returns comparative data on queue length predictions, emergency vehicle status predictions, and actual values for performance evaluation. The entire process adopts a modular design, supporting independent training and validation for multiple lanes. The final output can be used to analyze the model's performance in traffic prediction tasks.
[0227] S8. Constructing the PPO Intelligent Agent. This implementation establishes an emergency priority and queuing optimization system based on the Proximal Policy Optimization (PPO) algorithm. By controlling the phase selection and duration of traffic lights, it achieves dual-objective optimization for both emergency vehicles and regular vehicles. The system is simulated in the SUMO environment. The state is composed of multi-source features, and the actions are signal phase selection and duration. The reward function combines the EV priority potential function and SV traffic efficiency. This implementation implements a PPO multi-objective optimization algorithm for traffic signal control, combining the SUMO simulation environment, a traffic prediction model (LSTM-Transformer), and a multi-objective reward function to execute priority strategies and optimize traffic light control.
[0228] S801. Multi-source heterogeneous feature extraction and state representation. In this embodiment, the state space input of the PPO agent is formed by the fusion of three time-series information streams: First, multi-source static features, which integrate the real-time queue, flow, and signal status of the main road and upstream lanes, as well as the trajectory information such as the position and speed of each emergency vehicle; Second, historical data, which extracts the original sequence and statistics (maximum, minimum, mean, variance) of queue, delay, and signal sequences through short-term (5-step) and long-term (30-step) sliding windows to capture the evolution trend of traffic flow; Third, multi-source heterogeneous prediction information, which first outputs the queue and emergency vehicle trajectories of the future step by the Transformer, and then encodes them into fixed vectors by a small LSTM set inside the PPO and combines them with validity flags, so that the strategy can both review the past and focus on the present, and also see the upcoming traffic situation, thereby generating a more comprehensive, robust, safe and efficient signal control strategy at each decision moment.
[0229] S8011, Main Road and Upstream Vehicle Characteristics. For each main road lane... Extract the six-dimensional vector at time t.
[0230] (35)
[0231] in:
[0232] : Normalized time Lane queue length is used to measure the maximum queue length and balance of a lane;
[0233] Vehicle waiting time, used to calculate features such as average delay;
[0234] : for time Lane flow;
[0235] : One-hot encoding for red, yellow, and green light states;
[0236] : Control the throughput of the intersection per unit time;
[0237] Simulation time indicates periodicity.
[0238] Dimensions are The real vector space. Additionally, all different superscripts below... Both represent vector spaces of different dimensions (determined by the superscript).
[0239] S8012, Characteristics of Emergency Vehicles. Regarding the... Emergency vehicles, if they are If it occurs at a certain time, then:
[0240] (36)
[0241] in:
[0242] The lane where the emergency vehicle is currently located;
[0243] The location of the lane;
[0244] Instantaneous velocity;
[0245] The one-hot code of the lane where the emergency vehicle is located;
[0246] Dimensions are The real vector space.
[0247] S8013, Global State and Normalization. Concatenate all the above static features to obtain the original global state:
[0248] (37)
[0249] in, Each of them and Representing time respectively For each lane The constructed single-lane feature vector and the single-vehicle input feature vector of each emergency vehicle, The total number of lanes. This represents the total feature dimension for all predicted lanes and emergency vehicles. For dimension The real vector space.
[0250] For each dimension According to the training set mean Standard deviation Standardize:
[0251] (38)
[0252] and Representing time respectively No. The normalized and unnormalized values of each input dimension are given, and the normalized vector is denoted as . , It is a numerically stable term.
[0253] S8014. Historical observation data, which includes short-window historical sequences and long-window sliding statistics. To reflect traffic evolution trends, both short-window and long-window histories are maintained in the environment.
[0254] Where the short window length is... In this embodiment, =5, as detailed below:
[0255] (39)
[0256] in, These represent the queue, delay, and corresponding one-hot encoded concatenated information of the signal at the past five steps. Additionally, That is, at time The set of queue lengths for all lanes. and Similarly, represent time respectively. The average delay set for all lanes and the one-hot set of traffic light coding information.
[0257] Let the length of the long window be This implementation method takes =30 Calculate the sliding statistic:
[0258] (40)
[0259] in These represent the team leader and the delay time, respectively. In Record the maximum, minimum, average, and standard deviation of the normalized queue length and vehicle delay for each lane in the last 30 steps. Vectorize the features of the short and long windows, flatten them, and record them as follows: .
[0260] S8015, Multi-source heterogeneous prediction information. The LSTM-Transformer traffic prediction model is called to obtain future... (Predicted sequence with a value of 5 steps):
[0261] (41)
[0262] in, Represents a set of numbers whose elements are real numbers and have lines and A set of columns of matrices, Representing the future Predictive information on pedestrian lane queuing and emergency vehicle trajectories (location, speed), This is the total dimension for predicting all lane queues and the trajectory information such as the position and speed of emergency vehicles, and To avoid the PPO algorithm failing to truly understand the temporal information contained in the prediction results due to direct state concatenation, this embodiment designs a small LSTM network within the PPO for temporal encoding. The LSTM encoder uses parameters... For time input sequence The result of mapping 3D embedding vector:
[0263] (42)
[0264] in, This indicates a function notation that takes parameters as conditions, and is not a vector concatenation.
[0265] At the same time, valid flag information is introduced:
[0266]
[0267] S8016, Final State Representation. The normalized original state, prediction validity, and LSTM encoding are concatenated to form the complete state for input to the PPO policy network:
[0268]
[0269] Here, `concat()` is a vector concatenation operation, which concatenates the above vectors... The three elements are concatenated according to their feature dimensions to form a complete state vector, which constitutes the single-step input of the PPO agent for action decision-making. The dimension d is determined by the main path and emergency features, with additional labels. The assisting strategy determines when to make decisions based on predictive information, encoding vectors. Extracting the future The temporal correlation of steps avoids the semantic sparsity caused by directly splicing high-dimensional prediction sequences. The total dimension of the policy network input vector is represented by the original input state normalized at time t. 1. Validity marker and predictive embedding It is composed of three parts:
[0270] S802, Reinforce learning environment and action transition.
[0271] S8021, Action Definition. This embodiment includes two types of action selection in the control: phase selection and duration control. Based on the real-time changes in traffic flow and queue length in each lane, the main phase of the controlled traffic light and the green light duration are selected and controlled in real time. The specific phase selection and duration control are expressed as follows:
[0272]
[0273]
[0274] in This indicates that the system only switches between the four "green light main phases," with the numbers corresponding to the green light states allowed to operate in the SUMO timing file. The phase number indicates the intersection geometry and traffic flow direction, and only the four main traffic phases are allowed to pass. and These represent the preset shortest and longest green light durations, respectively. This indicates the duration of the green light, expressed in integer seconds, representing how long the green light lasts.
[0275] S8022, Environment Transition. The execution of actions within the environment involves two steps: first, the agent's actions are switched to the specified action space via traci. The green light phase is activated, then the simulation proceeds. Seconds (the status is read and the time is accumulated every second); then switch to the corresponding yellow light phase, and continue for a fixed transition duration. Finally, the simulation is terminated based on the accumulated phase duration and the final phase.
[0276] S803, a segmented reward function design, wherein the reward function includes an emergency vehicle priority passage reward and a social vehicle queuing guidance reward, used to guide the PPO agent to perform multi-objective collaborative optimization; the overall reward is based on emergency vehicle rewards. Social vehicle rewards Phase switching penalty Linear combination:
[0277]
[0278] in, For a moment An adaptive weighting coefficient is used between the two types of rewards: emergency priority and social vehicle queuing optimization. Emergency vehicles are given priority, and their weight is dynamically calculated and adjusted by a potential function.
[0279] S8031, Emergency Vehicle Rewards. Rewards will be given to emergency vehicles that meet the priority clearance distance requirements. :
[0280]
[0281] in, and Indicates that if the emergency vehicle is at the right time The signal for the lane is green or yellow; a value of 1 indicates the corresponding light color, otherwise a value of 0. , They are respectively and Component weights; This indicates a speed increment, encouraging emergency vehicles to accelerate, and As weight; The increment of the potential function, The weights are as follows:
[0282] ,
[0283] in It is the distance from the emergency vehicle to the intersection. As a normalization constant, finally for Perform online mean-variance normalization and truncation to .
[0284] S8032, Social Vehicle Rewards. Considering the maximum queuing, delay, balance, and throughput of all social vehicles, a potential function mechanism is adopted. The complex optimization objective during peak periods is decomposed into two parts: absolute core optimization and potential function plasticity. Annealing is used to balance the potential difference.
[0285] Reward 1: Core Reward for Social Vehicles. The core reward for social vehicles is expressed as an absolute reward. Because the PPO optimization control environment requires an immediate reward to be returned at each time step, rather than waiting until the end of the entire cycle to give a large reward, we use outflow traffic... (Measured by the number of cars added in this step), rather than using a cumulative total. Delays are also measured using... The average wait time for all vehicles in this step is normalized, rather than being the average at the end of the cycle. This ensures that the Policy Optimization Process (PPO) receives immediate feedback on whether it was "done well" or "done poorly" at each step, guaranteeing the effectiveness of policy gradient updates under the Markov Decision Process (MDP). Specifically, it is expressed as follows:
[0286]
[0287] Reward Two: Social Vehicle Latent Function Shaping Reward: The potential function shaping of social vehicles ensures policy invariance by shaping the maximum queuing and balance of social vehicles, guaranteeing that PPOs focus on queue peaks and imbalances without altering the optimal policy set. First, the latent function for the maximum queuing and balance indices is defined as the maximum queue potential. and unbalanced potential The specific expression is as follows:
[0288]
[0289]
[0290] Classic latent function shaping reward at time 1 Given:
[0291]
[0292] in, The discount coefficient for the potential function. For the state Calculate the potential function.
[0293] Based on the classical potential function difference theory, the maximum potential defined above is... and unbalanced potential Expressed as the difference of the maximum queuing potential function and the difference of the potential function for queuing equilibrium :
[0294]
[0295]
[0296] Finally, the two potential function differences are weighted and integrated, using... The second component representing the social vehicle target reward is the "maximum queue length and balance" shaping term based on the potential function difference, which measures the value at time t. compared to Whether the maximum queue size and queue imbalance have been improved is used to guide strategies to reduce bottlenecks and imbalances while prioritizing emergency response, as detailed below:
[0297]
[0298] Therefore, the total reward for social vehicles It is a weighted average of the core reward and the latent function shaping reward:
[0299]
[0300] in:
[0301] Average lane waiting time: a measure of the cost of delay;
[0302] Maximum delay constant;
[0303] : The increase in outflow volume in this step;
[0304] : Maximum observable outflow rate;
[0305] : Normalization constant, generally taken as the maximum queue length of the lane;
[0306] Standard deviation of queue length measures balance;
[0307] Maximum queue length;
[0308] : Shaping discount factor (usually related to PPO main) (Consistent numerical values) to ensure smooth potential decay;
[0309] These are the component weights of the maximum queuing potential difference, normalized delay, queuing balance potential difference, and normalized number of departing vehicles (throughput), respectively.
[0310] Overall strength of social shaping.
[0311] S8033. Dynamically Adjusting Latent Function Shaping. This embodiment introduces a periodic annealing mechanism into the emergency priority strategy to dynamically adjust the shaping weights. Upon emergency arrival, immediately increase to maximum value. The incentive guidance for social vehicles in the directions of "queue balance" and "preventing overflow" offsets the risk of emergency switching disrupting queue balance; after the emergency leaves, linear annealing will smoothly restore the vehicle from the maximum value to the baseline level in the subsequent 5 main phase cycles, thus ensuring the rapid passage of emergency vehicles while smoothly transitioning back to regular traffic optimization.
[0312]
[0313] in, This indicates the number of cycles an emergency vehicle has passed after leaving the controlled intersection. Indicates the annealing cycle, total transition time. Next cycle This represents the baseline weight after annealing. Prioritizing emergency vehicles maximizes queue balance; after emergency vehicles leave, the importance of "balance" is gradually reduced to avoid sacrificing traffic efficiency due to an excessive pursuit of balance in the long term.
[0314] S8034, bit switching penalty. If a phase change occurs and its duration is too short, then:
[0315]
[0316] in, This indicates the duration of the green light. The effective distance threshold indicating emergency priority This indicates the tolerance threshold; if the switching time during the control process is too short, This indicates the upper limit of tolerance for the effective distance threshold for emergency priority, then execution... punish, This represents the phase switching penalty weight.
[0317] S8035, EV priority weight Dynamically adjusted. Sigmoid weights are designed based on the location of emergency vehicles and their distance relative to the tail end of the queue in the corresponding lane at the controlled intersection.
[0318]
[0319] in The distance from the emergency vehicle to the intersection is represented by exp, which is the natural exponential function with parameters. To control the steepness of the curve, dynamic balancing EV is prioritized over SV optimization.
[0320] S804, Algorithm Training. S is calculated using PPO. t Generational Strategy Network and value network The process involves three steps: data sampling, estimating advantage, and optimizing objectives.
[0321] S8041, Data Sampling. Under the current strategy... The system interacts with the environment to obtain a trajectory:
[0322]
[0323] :time The state;
[0324] Actions sampled according to the old strategy;
[0325] :action Instant rewards obtained in the environment;
[0326] The new state reached after the action;
[0327] The length of an episode (or the truncation length).
[0328] S8042, Dominance Function Estimation. Let... Indicates the state Next, execute The "excess returns" obtained:
[0329]
[0330] In state Take action below The immediate reward received afterward;
[0331] Discount factor: Used to reduce the impact of future value;
[0332] Value network for the next state The estimate;
[0333] Value network for the current state The estimate;
[0334] One-step TD goal refers to a single-step bootstrapping reward.
[0335] S8043, PPO Optimization Objective. The core of PPO is to limit the update magnitude. The following formulas respectively represent the optimization objective pruning and the MSE fitting of the TD objective. :
[0336]
[0337]
[0338] in, For the first The reward objective of each step is used to train the value function. for The strategy of tailoring the target, For strategy parameters, For the trimming operator, For parameters The value function loss, i.e., the loss of parameters value network For return target Calculate the mean squared error.
[0339] Finally, the overall optimization loss objective is expressed as:
[0340]
[0341] in, This represents the clipping factor, and the clipping range is []. ],ensure When the deviation is too large, the target is no longer increased, thereby controlling the magnitude of the strategy update. This indicates the addition of a policy entropy term to encourage exploration. and These represent the value loss coefficient and the entropy coefficient, respectively.
[0342] S9. Training Process: During the training process of PPO, the agent first adopts the current policy. Interact with the environment to continuously collect a segment of trajectory data. And perform necessary normalization or prediction enhancement on the state; then utilize the value network Calculate the one-step TD target and advantage estimation Next, multiple rounds of joint optimization of the policy and value networks were performed on this batch of data—the policy network used gradient ascent with pruning objectives, while the value network minimized the mean squared error and additionally added policy entropy regularization to encourage exploration; this completed the optimization. After the round of updates, the new strategy parameters will be... Synchronize Clear the sampling buffer and enter the next sampling-new loop until the policy converges or the training budget is reached.
[0343] This implementation combines the SUMO simulation environment, the LSTM-Transformer traffic prediction model, and the PPO reinforcement learning agent to optimize traffic light control strategies. The model's goal is to optimize a multi-objective function by designing a suitable reward strategy, thereby improving traffic flow and emergency vehicle passage efficiency.
[0344] This implementation addresses the technical challenge of urban traffic signal control and emergency vehicle priority passage by developing an intelligent traffic signal control system based on deep reinforcement learning in the Python environment. The system integrates PPO and LSTM-Transformer traffic prediction models to analyze dynamic traffic flow characteristics in real time and optimize traffic light control strategies, achieving efficient traffic flow management. The system architecture comprises three core modules: a traffic flow prediction module driven by multi-source heterogeneous data, a PPO-based agent training module, and a real-time signal optimization control module.
[0345] This implementation employs deep reinforcement learning technology to achieve intelligent control of intersection traffic lights. It accurately predicts the queue length and emergency vehicle operation status of each lane in future time periods using an LSTM-Transformer traffic prediction model, and uses the prediction results as state input to the Point of Interest (PPO) for decision-making. An innovative reward mechanism integrating multi-dimensional features such as traffic status, emergency vehicles, and signal optimization is designed, enabling the agent to autonomously optimize signal control strategies. This improves the efficiency of emergency vehicle passage in saturated traffic conditions while reducing the impact of emergency vehicle priority passage on other vehicles and improving overall traffic conditions. Compared to traditional priority passage and signal optimization schemes, this invention balances emergency response efficiency and intersection traffic efficiency, achieving fully data-driven dynamic control with stronger environmental adaptability and a higher level of intelligence. Figure 5As shown, during the training process of this invention, both the training loss and validation loss of the model for the lane-level queue evolution prediction task show a rapid decreasing trend with the increase of the number of iterations, and eventually tend to stabilize. This indicates that the model has converged well and can provide reliable prior information for subsequent queue behavior analysis. Figure 6 As shown, the predicted losses for the position, speed, and lane status of emergency vehicles also exhibit a continuous decreasing trend and eventually stabilize, proving that the forward trajectory prediction module used in this invention has usability and robustness, and can effectively support subsequent decision-making and control. Figure 7 As shown in (a) to (d) (where Ty1.0 and ty2.0 represent the emergency vehicle types, corresponding to ambulances and fire trucks respectively), the scatter distribution of the prediction errors of the trajectory state parameters of the two emergency vehicles in this embodiment closely revolves around the zero point, and the mean is close to zero, indicating a small degree of dispersion. This suggests that there is no significant systematic bias in the prediction results, and the variance is effectively controlled, with the prediction accuracy meeting the design requirements. Figure 8 As shown in the heatmap, the queuing balance heatmap clearly demonstrates that in peak congestion scenarios, the distribution of vehicles across lanes is more uniform, verifying that the equalization shaping method proposed in this invention can effectively improve the queuing distribution between lanes and enhance the overall traffic flow balance. Figure 9 As shown, during the reinforcement learning training process, the entropy value of the PPO policy in this embodiment gradually decreases from a high level and eventually maintains a small oscillation within a small range. This change process shows that the agent fully explores in the early stage of learning and then gradually converges to a stable and efficient policy, indicating that the training process is reasonable and effective.
[0346] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0347] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. An emergency vehicle priority and queuing optimization collaborative control method, characterized in that, According to the following steps: S1, construct a road intersection road network topology model and collect multi-source traffic state data; S2, pre-process the collected data and extract multi-source heterogeneous features to construct a standardized feature vector; S3, construct a time series data set based on the pre-processed data; S4, establish a dual-branch traffic prediction model that integrates LSTM and Transformer architecture: S5, train the dual-branch traffic prediction model; use a multi-task mean square error loss function that includes queue evolution prediction loss and emergency vehicle operating state prediction loss to optimize the parameters of the integrated dual-branch traffic prediction model until convergence; S6, construct a PPO agent, the state space of which integrates real-time traffic state, historical observation data, and the prediction results of the dual-branch traffic prediction model; S7, design a segmented reward function to guide the PPO agent to perform multi-objective collaborative optimization, and balance the emergency vehicle priority and social vehicle optimization objectives through dynamic weight coefficients; The piecewise reward function Combination with emergency vehicle reward , social vehicle reward With phase switch penalty (1) Wherein, For time An adaptive weight coefficient between the two types of rewards of emergency priority and social vehicle queuing optimization, and Specifically: ; wherein represents the distance of the emergency vehicle to the intersection, exp is the natural exponential function, is a maximum delay constant, is a parameter controlling the steepness of the curve. S8, train the PPO agent; the PPO agent interacts with the traffic simulation environment to sample trajectory data, determines the state-action excess return through advantage function estimation, and updates the policy network and value network parameters in combination with the clipping optimization objective; S9, deploy the trained dual-branch traffic prediction model, input real-time collected traffic state data, and obtain future lane-by-lane queuing evolution trends and emergency vehicle trajectory prediction results; the PPO agent outputs signal phase selection and green light duration decisions based on real-time traffic state data and the prediction results, controls the traffic signal lights to execute the corresponding timing scheme, and the signal phase selection only switches between the four green light main phases, achieving emergency vehicle priority and social vehicle queuing optimization.
2. The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, The intersection road network topology model in S1 is the associated area of five intersections, the center intersection uses a four-stage eight-phase timing scheme, which includes two straight left phases in the east-west direction and two straight and left turn phases in the north-south direction; the lengths of the four entrance roads of the center intersection are 800m, 450m, 386m, and 400m respectively, and one straight lane and one left turn lane are selected for each entrance road as the research and control object; the traffic simulation environment uses the SUMO simulation platform, and the simulation duration is 1 hour, the multi-source traffic state data output by the simulation is saved as a CSV file. 3.The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, S2 specifically constructs the queue / flow ratio and net growth queue composite features through feature engineering, removes redundant information through correlation analysis, mutual information evaluation, VIF multicollinearity detection, and feature importance screening, and then normalizes the features to obtain a standardized feature vector; where the normalized feature vector is: ; wherein, is a very small constant, is the mean of each dimension feature in the training set, is the standard deviation of each dimension feature in the training set, is the feature vector before normalization.
4. The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, In S3, the specific process of constructing the time series data set is: Let the original time series data be: (4); wherein, represents the input all-lane feature vector at the time instant, represents the output queue length at the time instant, represents the time series length; establishing an input sequence for each time step and a predicted target sequence : ; ; The final dataset Is: (7); wherein, denotes the input time series length, denotes the output time series length, And the data set is divided into training set and test set in the ratio of 7:
3.
5. The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, In the S4, the double-branch traffic prediction model comprises an LSTM encoder, a Transformer encoder and a double-branch prediction head, the LSTM encoder captures local time sequence dynamic characteristics of traffic flow, the Transformer encoder captures global space-time dependence, and the double-branch prediction head respectively outputs prediction results of lane-by-lane queuing evolution trend and trajectory state of emergency vehicles in a future period. In the S4, the LSTM encoder has 112 hidden layers and 3 total layers. In the S4, the Transformer encoder has 3 layers, 4 attention heads, a feedforward layer with a size of 128, a dropout rate of 0.1, an output window of 5 and a state prediction output dimension of 2 for each emergency vehicle.
6. The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, Final state of the PPO agent in S6 is represented as: ; in, For the time The normalized original input states include the queue length of the main road lanes, vehicle waiting time, lane flow, one-hot encoding of signal status, intersection throughput, simulation time, and the lane, position, and speed of emergency vehicles; Additional indicators to assist strategies in determining when to make decisions based on forecast information; To refine the future The temporal correlation encoding vector of the step; This is a vector concatenation operation.
7. The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, The emergency vehicle reward Specifically: (9); wherein, and represents 1 if the emergency vehicle is in the lane with green or yellow signal at time , otherwise 0, and , are the component weights of and , respectively; represents the speed increment, is the weight of , is the potential function increment, is the weight of . The social vehicle reward Specifically: ; ; ; wherein, is the increment of the outflow traffic volume of the current step; are the component weights of the maximum queue potential difference, the normalized delay, the queue equilibrium potential difference, and the normalized number of departing vehicles, respectively; is the overall strength of the social shaping; is the maximum observable outflow traffic volume; is the average waiting delay of the lane; is the maximum delay constant; is the maximum queue potential function difference; is the queue equilibrium potential function difference; is the core reward of the social vehicle; is the potential function shaping reward of the social vehicle; The phase switch penalty Specifically: (13); wherein, represents the current green light duration, represents the emergency priority effective distance threshold, represents the tolerance threshold, represents the phase switch penalty weight, represents the tolerance upper limit of the emergency priority effective distance threshold. 8.The emergency vehicle priority and queuing optimization cooperative control method of claim 1, wherein, In the S8, the advantage function estimation determination process is specifically as follows: (14); to take action in a state the immediate reward obtained after; is a discount factor that attenuates the influence of future values; is the estimate of the value network for the next state ; is the estimate of the value network for the current state ; The total optimization objective of the PPO agent is : ; wherein, represents an increased policy entropy term for encouraging exploration, and respectively represent a value loss coefficient and an entropy coefficient; is a policy clipping target; is a value function loss.
Citation Information
Patent Citations
Emergency vehicle priority passing control method based on parameterized reinforcement learning
CN119832755A
Short-time rail transit flow prediction method and device based on decoupling process
CN120125052A