Traffic signal control method, device and equipment based on reinforcement learning, medium and product
By combining offline learning, sequence modeling and spatiotemporal dependence modeling, the traffic signal control method solves the problems of exploration risk of online reinforcement learning and insufficient offline learning performance in the existing technology, and achieves more efficient and stable traffic signal control. , making full use of the complex correlation between traffic signals to improve the overall traffic flow efficiency.
Patent Information
- Application Number
- CN202411080776.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-08-08
AI Technical Summary
Existing traffic signal control methods have exploration risks and inefficiencies in online reinforcement learning. Offline reinforcement learning methods have insufficient performance under complex traffic flow patterns and cannot fully utilize the complex correlations between traffic signals, resulting in poor control effects. .
A traffic signal control method based on reinforcement learning is adopted, combining offline learning, sequence modeling and spatiotemporal dependence modeling. Through a spatiotemporal encoder and a reward-based action decoder, the road network graph and historical trajectory data are used to capture the relationship between traffic signals. dynamic spatial dependence to optimize the traffic signal control strategy.
It effectively improves the overall performance of traffic signal control, reduces traffic congestion and accident risks, improves the efficiency and stability of model training, ensures excellent performance in various traffic scenarios, and provides a stable and efficient traffic management solution.
Smart Images

Figure CN118609386A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traffic signal control, and in particular to a traffic signal control method, device, equipment, medium and product based on reinforcement learning. Background Art
[0002] Traffic signal control (TSC) alleviates congestion at urban intersections by optimizing the flow of vehicles in different directions. With the development of machine learning technology, TSC methods based on reinforcement learning (RL) have been widely studied. However, existing traffic signal control methods have the following disadvantages: Online RL methods require extensive exploration in the real environment, which may lead to serious traffic congestion or accident risks during model training. In addition, the model performance is poor in the exploration phase, resulting in inefficiency and instability in actual deployment, limiting its application in actual signal control. Although offline RL methods can avoid the risks of real-time interaction, their performance may be inferior to that of online RL methods in some cases due to the lack of iterative optimization of data distribution. For example, offline RL methods such as behavior cloning and conservative Q learning may not achieve optimal control effects when dealing with complex traffic flow patterns. Although TSC methods based on sequence modeling show good performance by predicting actions through historical trajectory data, they still have shortcomings in capturing the dynamic spatial dependencies between data samples at different intersections and fail to fully utilize the complex associations between traffic signals, which may lead to suboptimal control effects. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a traffic signal control method, device, equipment, medium and product based on reinforcement learning, which captures the dynamic spatial dependencies between traffic signals by combining offline learning, sequence modeling and spatiotemporal dependency modeling, makes full use of the complex connections between intersections, and effectively improves the overall performance of traffic signal control.
[0004] In order to achieve the above object, an embodiment of the present invention provides a traffic signal control method based on reinforcement learning, comprising: Obtaining traffic status data and a road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; Inputting the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; According to the target phase action, the traffic light at the target intersection is controlled to perform the target phase action.
[0005] As an improvement of the above solution, the training process of the traffic signal prediction model includes: Acquire historical traffic status data of different intersections and generate historical trajectory sequences of all traffic signals; wherein the historical trajectory sequences include state sequences, action sequences and reward sequences; Inputting the historical trajectory sequence and the road network graph into the spatiotemporal encoder to obtain a spatiotemporal enhanced representation output by the spatiotemporal encoder; Inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder; The optimization target is determined by reward-based contrastive learning, and iterative training is performed to obtain a trained traffic signal prediction model.
[0006] As an improvement of the above solution, the spatiotemporal encoder includes a marking representation module and a dual spatiotemporal aggregation module, and the historical trajectory sequence and the road network diagram are input into the spatiotemporal encoder to obtain the spatiotemporal enhanced representation output by the spatiotemporal encoder, specifically including: Inputting the state sequence into the first fully connected layer in the mark representation module to obtain a state mark representation of the state sequence; Inputting the action sequence into the second fully connected layer in the tag representation module to obtain an action tag representation of the action sequence; For the reward sequence, a lane-level self-attention mechanism is introduced, the features of multiple lanes at the intersection are input into the self-attention unit in the tag representation module as basic tags, and the lane-level representation is aggregated to obtain the reward tag representation of the reward sequence; The state mark representation, the action mark representation, the reward mark representation and the road network diagram are input into the dual-time-space aggregation module to obtain the spatiotemporal enhanced representation output by the dual-time-space aggregation module.
[0007] As an improvement of the above solution, the dual spatiotemporal aggregation module includes a spatial encoder and a temporal encoder, and the state mark representation, the action mark representation, the reward mark representation and the road network graph are input into the dual spatiotemporal aggregation module to obtain the spatiotemporal enhanced representation output by the dual spatiotemporal aggregation module, specifically including: Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the spatial encoder, and learning the spatial dependencies between different traffic signals through the spatial encoder to obtain a spatial enhanced representation; Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the time encoder, and learning the time dependency between different time steps of each traffic signal through the time encoder to obtain a time enhanced representation; The spatial enhanced representation and the temporal enhanced representation are fused through a gate mechanism to obtain a spatiotemporal enhanced representation.
[0008] As an improvement of the above scheme, the spatiotemporal enhanced representation includes a spatiotemporal enhanced state representation, an action representation, and a reward representation, and the spatiotemporal enhanced representation is input into the reward-based action decoder to obtain the phase action output by the reward-based action decoder, specifically including: Encoding the reward representation into the state representation and the action representation respectively to generate an encoded trajectory sequence; The trajectory sequence is input into a causal decoder, and the predicted phase action is obtained by autoregressive prediction through a causal self-attention mask.
[0009] As an improvement of the above scheme, the optimization target is determined by reward-based contrastive learning, and iterative training is performed to obtain a trained traffic signal prediction model, which specifically includes: For a specific anchor point return label, construct the corresponding positive and negative samples; Using a binary classification discriminator to classify the positive sample and the negative sample, and determining a binary classification cross entropy loss; The binary cross entropy loss and the cross entropy loss are used as optimization targets of the traffic signal prediction model, and iterative training is performed until a preset stop condition is reached to obtain a trained traffic signal prediction model.
[0010] The embodiment of the present invention further provides a traffic signal control device based on reinforcement learning, comprising: A data acquisition module, used to acquire the traffic status data and road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; An action prediction module, used for inputting the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; A signal control module is used to control the traffic light at the target intersection to perform the target phase action according to the target phase action.
[0011] An embodiment of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the reinforcement learning-based traffic signal control method described in any one of the above items is implemented.
[0012] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned traffic signal control methods based on reinforcement learning.
[0013] An embodiment of the present invention further provides a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, any of the above-mentioned traffic signal control methods based on reinforcement learning is implemented.
[0014] Compared with the prior art, the beneficial effects of a traffic signal control method, device, equipment, medium and product based on reinforcement learning provided by the embodiments of the present invention are: by obtaining the traffic status data and road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; the traffic status data and the road network diagram are input into a preset traffic signal prediction model to obtain the target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder and reward-based contrastive learning; according to the target phase action, the traffic lights at the target intersection are controlled to perform the target phase action. The embodiments of the present invention capture the dynamic spatial dependencies between traffic signals by combining offline learning, sequence modeling and spatiotemporal dependency modeling, make full use of the complex connections between intersections, and effectively improve the overall performance of traffic signal control. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flow chart of a preferred embodiment of a traffic signal control method based on reinforcement learning provided by the present invention; Figure 2 It is a traffic signal light control phase diagram in a traffic signal control method based on reinforcement learning provided by the present invention; Figure 3 It is a schematic diagram of a framework of a traffic signal prediction model in a traffic signal control method based on reinforcement learning provided by the present invention; Figure 4 It is a structural schematic diagram of a preferred embodiment of a traffic signal control device based on reinforcement learning provided by the present invention; Figure 5 It is a structural schematic diagram of a preferred embodiment of a terminal device provided by the present invention. DETAILED DESCRIPTION
[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0017] See also Figure 1 , Figure 1 1 is a flow chart of a preferred embodiment of a traffic signal control method based on reinforcement learning provided by the present invention. The traffic signal control method based on reinforcement learning comprises: S1, obtaining the traffic status data and road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; S2, inputting the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; S3: According to the target phase action, control the traffic light at the target intersection to perform the target phase action.
[0018] Specifically, the embodiment of the present invention studies the change of the phase of traffic lights in the traffic signal control (TSC) task. Figure 2 , Figure 2It is a traffic signal control phase diagram in a traffic signal control method based on reinforcement learning provided by the present invention. The green light phase refers to the period of time during which traffic in a specific direction is allowed to pass. There are two ways of making decisions in signal light control. One is to focus on controlling the order of green light phases while determining the fixed duration of each phase. The other is to decide the time to switch to the next phase on the basis of maintaining the predefined green light phase order. Both methods are intended to reduce congestion at intersections. An embodiment of the present invention provides a traffic signal control method based on reinforcement learning, by acquiring traffic status data and a road network diagram of a target intersection at the current moment. The traffic status data includes the number of lanes at the intersection and the traffic flow of each lane, and the traffic flow also includes the status data of the vehicle. The traffic status data and the road network diagram are input into a preset trained traffic signal prediction model to obtain the target phase action output by the traffic signal prediction model. The traffic signal prediction model in the embodiment of the present invention includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning. Among them, the spatiotemporal encoder is used to obtain the spatiotemporal enhanced representation of states, actions and rewards; the reward-based action decoder predicts actions in a causal manner; and the reward-based contrastive learning is used to enhance the model's ability to distinguish data samples into specific auxiliary tasks, each of which reflects a unique traffic flow pattern. After obtaining the target phase action output by the traffic signal prediction model, the traffic lights at the target intersection are controlled to perform the target phase action according to the target phase action.
[0019] The embodiment of the present invention adopts an offline learning method to avoid the exploration risk in online reinforcement learning and reduce the possibility of causing traffic congestion or accidents during actual deployment. At the same time, offline learning improves the efficiency and stability of model training. By using spatiotemporal sequence modeling technology, the offline reinforcement learning strategy is improved, so that excellent control effects can be maintained under different traffic flow modes, making up for the shortcomings of traditional offline learning methods in dealing with complex traffic environments, and can better capture the dynamic spatial dependencies between traffic signals, make full use of the complex associations between various intersections, and effectively improve the overall performance of traffic signal control. Through the reward-based comparative learning mechanism, the adaptive ability of the model in different types of traffic flow modes is enhanced, so that the model can automatically adjust the control strategy according to the changes in the traffic flow mode, ensuring excellent performance in various traffic scenarios. The embodiment of the present invention provides a stable and efficient traffic management solution, which can effectively optimize urban traffic signal control, improve overall traffic flow efficiency, meet the needs of complex traffic environments in modern cities, and has broad practical application prospects.
[0020] In another preferred embodiment, the training process of the traffic signal prediction model includes: S10, acquiring historical traffic status data of different intersections, and generating a historical trajectory sequence of all traffic signals; wherein the historical trajectory sequence includes a state sequence, an action sequence, and a reward sequence; S20, inputting the historical trajectory sequence and the road network graph into the spatiotemporal encoder to obtain a spatiotemporal enhanced representation output by the spatiotemporal encoder; S30, inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder; S40, using reward-based contrastive learning to determine the optimization target, and performing iterative training to obtain a trained traffic signal prediction model.
[0021] Specifically, in reinforcement learning, the environment can be modeled as a Markov decision process consisting of a tuple (S, A, P, R, ) definition. Where S represents the state space, A represents the action space, P represents the transition probability matrix, R and denote the reward function and the reward discount factor, respectively. For traffic signal control based on reinforcement learning, the state space S is composed of the traffic characteristics of different entry and exit lanes of the intersection. The action space A is the index of determining the duration of the current phase given a fixed phase plan, or selecting the next green light phase under the premise of considering the shortest green light phase duration. The reward metric R includes congestion indicators, such as the total queue length in the incoming direction, the average travel time, the average waiting time, etc.
[0022] See also Figure 3 , Figure 3 The figure is a schematic diagram of a traffic signal prediction model in a traffic signal control method based on reinforcement learning provided by the present invention. The embodiment of the present invention can formulate the offline traffic signal control problem as follows: given an offline data set (i.e., historical traffic status data) collected from each intersection and a road network diagram ; Where N represents the total number of traffic signals, Represents a set of real numbers. Generates a historical trajectory sequence represented by the global structure , and ; Where K represents the length of the trajectory sequence, L represents the number of lanes at each intersection, and D represents the feature space dimension of the state. According to the historical trajectory sequence of all signals ( , , ,..., , ), the training model fits the phase action in an autoregressive manner . The historical trajectory sequence and the road network graph are input into the spatiotemporal encoder to obtain the spatiotemporal enhanced representation output by the spatiotemporal encoder. The spatiotemporal enhanced representation is input into the reward-based action decoder to obtain the phase action output by the reward-based action decoder. The reward-based contrastive learning is used to determine the optimization target, and iterative training is performed to obtain a trained traffic signal prediction model. Exemplarily, during the model evaluation, the model is forced to be based on the maximum possible target reward (i.e. ) Predict the best phase action. Through the above input, the goal of the embodiment of the present invention is to consider the dynamic interaction between signals, so as to achieve the best action prediction of traffic signals.
[0023] In another preferred embodiment, the spatiotemporal encoder includes a label representation module and a dual spatiotemporal aggregation module, and the step S20, inputting the historical trajectory sequence and the road network diagram into the spatiotemporal encoder to obtain the spatiotemporal enhanced representation output by the spatiotemporal encoder, specifically includes: S201, inputting the state sequence into the first fully connected layer in the mark representation module to obtain a state mark representation of the state sequence; S202, inputting the action sequence into the second fully connected layer in the tag representation module to obtain an action tag representation of the action sequence; S203, for the reward sequence, introducing a lane-level self-attention mechanism, inputting the features of multiple lanes at the intersection as basic tags into the self-attention unit in the tag representation module, and aggregating the lane-level representation to obtain a reward tag representation of the reward sequence; S204, inputting the state mark representation, the action mark representation, the reward mark representation and the road network diagram into the dual-space-time aggregation module to obtain the space-time enhanced representation output by the dual-space-time aggregation module.
[0024] Specifically, the spatiotemporal encoder in the embodiment of the present invention includes a tag representation module and a dual spatiotemporal aggregation module. The tag representation module is used to encode the input tags; the dual spatiotemporal aggregation module is used to capture the dynamics and inter-signal dependencies in the embedding. Considering the different dimensions of the heterogeneous input tags, the embodiment of the present invention maps these tags to a unified representation space. The state sequence is input to the first fully connected layer in the tag representation module. , and obtain the state tag representation of the state sequence. The action sequence is input into the second fully connected layer in the tag representation module. , and obtain the action tag representation of the action sequence. For example, for the state sequence and action sequence, the fully connected layer is used respectively. and , generating feature representation vectors of state sequences and action sequences, and . For the reward sequence, the prior art directly applies the Vanilla neural network to the rewards of each intersection, ignoring the intrinsic relationship between different lanes. In order to provide a more effective and comprehensive reward representation, the embodiment of the present invention introduces a lane-level self-attention mechanism to adaptively combine the features of different lanes. The features of multiple lanes at the intersection are input as basic tags into the self-attention unit in the tag representation module, and the lane-level representation is aggregated to obtain the reward tag representation of the reward sequence. Exemplarily, the feature representation of the lane is as follows: ; Among them, input Indicated in The time step The intersection Traffic characteristics of lanes; matrix , , is a learnable parameter. On this basis, the embodiment of the present invention further aggregates the lane-level representation to obtain the reward mark embedding. Exemplarily, the pooling operation is applied to all lanes in a single intersection as follows: .
[0025] After mapping each type of tag to a unified embedding space, each tag is modeled in spatial and temporal dimensions. The state tag representation, action tag representation, reward tag representation, and road network graph are input into the dual spatiotemporal aggregation module to obtain the spatiotemporal enhanced representation output by the dual spatiotemporal aggregation module.
[0026] In another preferred embodiment, the dual spatiotemporal aggregation module includes a spatial encoder and a temporal encoder, and the step S204, inputting the state mark representation, the action mark representation, the reward mark representation, and the road network graph into the dual spatiotemporal aggregation module to obtain the spatiotemporal enhanced representation output by the dual spatiotemporal aggregation module, specifically includes: S214, inputting the state mark representation, the action mark representation, the reward mark representation and the road network graph into the spatial encoder, and learning the spatial dependencies between different traffic signals through the spatial encoder to obtain a spatial enhanced representation; S224, inputting the state label representation, the action label representation, the reward label representation and the road network graph into the time encoder, and learning the time dependency between different time steps of each traffic signal through the time encoder to obtain a time enhanced representation; S234, fusing the spatial enhanced representation and the temporal enhanced representation through a gate mechanism to obtain a spatiotemporal enhanced representation.
[0027] Specifically, the dual spatiotemporal aggregation module in the embodiment of the present invention includes a spatial encoder and a temporal encoder. The spatial encoder is used to capture the spatial correlation between markers of different traffic signals, and the temporal encoder is used to capture the temporal dynamics of traffic modes at different time steps. The state marker representation, action marker representation, reward marker representation, and road network diagram are input into the spatial encoder, and the spatial dependencies between different traffic signals are learned through the spatial encoder to obtain a spatial enhanced representation. The state marker representation, action marker representation, reward marker representation, and road network diagram are input into the temporal encoder, and the temporal dependencies between different time steps of each traffic signal are learned through the temporal encoder to obtain a temporal enhanced representation. The spatial enhanced representation and the temporal enhanced representation are fused through a gate mechanism to obtain a spatiotemporal enhanced representation.
[0028] For example, the following selection of return mark indicates Provide detailed descriptions of the status flags. and action markers The same process is performed.
[0029] The traditional approach is to use graph neural networks (GNNs), such as GCN, to capture intrinsic spatial patterns and associations on a predefined road network. However, since GNNs are mainly good at modeling local topological information, directly relying on the adjacency relationship between nodes may not be able to fully capture the spatial associations between traffic signals. Therefore, the embodiment of the present invention adopts a transformer-like architecture to process the reward representation from a spatial perspective without introducing additional inductive biases. The embodiment of the present invention first introduces a learnable spatial position encoding for each tag type. For the reward tag, the encoding is represented as , which is initialized with the road network adjacency matrix. Subsequently, the encoding is concatenated with the hidden token representation consistently at each time step. At this stage, to maintain uniform dimensionality, subsequent linear layers are applied. Formally, the spatial location-aware reward representation can be obtained by It is concluded that, represents a linear mapping, and || represents a connection operation. Along this direction, the embodiment of the present invention further utilizes a spatially oriented multi-head attention mechanism and residual connections to capture the potential spatial dependencies between different traffic signals: .
[0030] In addition to capturing the spatial correlation between traffic signals, it is also important to capture the temporal dynamics of traffic patterns at different time steps. Similar to the spatial encoder described above, the embodiment of the present invention assigns a temporal position code to each marker type, represented as a matrix , which is initialized by a discrete time step one-hot embedding. Subsequently, the encoding is consistently connected to the hidden tag representation at each node. The embodiment of the present invention can achieve a temporal position-aware reward representation as shown below: ,in, Represents a linear mapping function. At this stage, the embodiment of the present invention also uses a time-oriented multi-head attention mechanism and residual connection to capture the potential time dependencies between different time steps of each traffic signal, as shown below: .
[0031] At this time, time enhancement means and spatially enhanced representation It has been learned separately that in order to promote the integration of multi-source information, the embodiment of the present invention designs a gate mechanism to fuse hidden embeddings in spatial and temporal dimensions. Specifically, the embodiment of the present invention considers spatial and temporal representations to control the gate mechanism, thereby context-awarely fusing the two sources of information. Formally, the process can be formulated as: ; in, represents the sigmoid activation function, and represents two learnable parameters, Represents element-wise multiplication.
[0032] In another preferred embodiment, the spatiotemporal enhanced representation includes a spatiotemporal enhanced state representation, an action representation, and a reward representation, and the step S30 of inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder specifically includes: S301, encoding the reward representation into the state representation and the action representation respectively to generate an encoded trajectory sequence; S302, input the trajectory sequence into a causal decoder, and perform autoregressive prediction through a causal self-attention mask to obtain a predicted phase action.
[0033] Specifically, the spatiotemporal enhanced representation in the embodiment of the present invention includes a spatiotemporal enhanced state representation, action representation, and reward representation. After the spatiotemporal enhanced state representation, action representation, and reward representation are obtained through the spatiotemporal encoder, a causal decoder is used to predict the next action. In order to effectively "index" the state and action representations based on the rewards, the embodiment of the present invention combines a reward-based embedding subspace transformation scheme to convert the input data into different subspaces within the input dimension. Specifically, for each time step, the embodiment of the present invention converts the reward representation Encoded into state representation and action representation respectively, the process can be formulated as: and ; where ⊙ represents the element-wise product between two vectors. Thus, the representation of the reward encoding is and It can be used as the input of the causal decoder to predict the action label. Therefore, the input trajectory sequence is converted to the following structure: .
[0034] Subsequently, the reassembled trajectory sequence is fed into the causal decoder, which is autoregressively predicted via the causal self-attention mask to obtain the predicted phase action.
[0035] Exemplarily, the embodiment of the present invention uses the front The tokens replace the softmax and generate the following predictions: .
[0036] In another preferred embodiment, the step S40, using reward-based contrastive learning to determine the optimization target and performing iterative training to obtain a trained traffic signal prediction model, specifically includes: S401, for a specific anchor point reward mark, construct corresponding positive samples and negative samples; S402, classifying the positive sample and the negative sample using a binary classification discriminator to determine a binary classification cross entropy loss; S403, using the binary cross entropy loss and the cross entropy loss as optimization targets of the traffic signal prediction model, and performing iterative training until a preset stop condition is reached, thereby obtaining a trained traffic signal prediction model.
[0037] Specifically, since the embodiment of the present invention formulates the task as a reward-based action prediction task, the embodiment of the present invention further designs an auxiliary task to enhance the distinguishability of the reward representation. Specifically, given a specific anchor reward label, the embodiment of the present invention uses two data enhancement techniques to obtain the corresponding positive and negative samples. For the positive sample, it is represented as , the embodiment of the present invention masks the input features of the anchor point return with a constant (such as 0). In order to generate negative samples , the embodiment of the present invention processes each time step separately and performs row-by-row randomization on the feature matrix within the time step. Therefore, for each anchor point return label, there is exactly one positive sample and one negative sample. Then, the embodiment of the present invention adopts a binary classification discriminator The anchor-positive sample pairs and anchor-negative sample pairs are classified. The embodiment of the present invention further uses the binary cross entropy loss to optimize the contrastive learning process: ; in, represents the sigma activation function, Represents the label of the paired input. The goal of this design is to encourage the model to model topological gaps and challenge the model to recognize random graph structures, thereby strengthening its ability to recognize spatial patterns. Since the true value of the action contains four traffic phases, the embodiment of the present invention formulates the prediction task as a classification problem. Therefore, the embodiment of the present invention adopts cross entropy loss as the optimization target, which is defined as follows: .
[0038] Therefore, the final loss function of the traffic signal prediction model is: ; in, Controls the weights of the two loss functions.
[0039] The above-mentioned binary cross entropy loss and cross entropy loss are used as the optimization objectives of the traffic signal prediction model, and iterative training is performed until the preset stop condition is reached to obtain a trained traffic signal prediction model.
[0040] Exemplarily, the embodiment of the present invention evaluates the performance of the STLight model of the embodiment of the present invention on two public real-world datasets, namely Hangzhou 4x4 and Jinan 3x4, with a total number of traffic signals of 16 and 12 respectively. In order to obtain offline data, the embodiment of the present invention trains a state-of-the-art RL-based TSC model, namely AdvancedColight, and saves the trajectory of state, action, and reward at each time step. In addition, the embodiment of the present invention preprocesses long trajectories by iteratively creating slices with a sequence length of K=4. During model evaluation, the embodiment of the present invention uses the traffic simulator CityFlow as the environment for real-time traffic simulation. Each training / evaluation epoch lasts 3600s, and the green light time for all possible phases lasts 15s. The embodiment of the present invention trains all models for 100 epochs, performs online evaluation every 10 epochs, and the evaluation results show the average value of the last 5 evaluation epochs.
[0041] This embodiment of the present invention compares STLight with three types of benchmark methods: Heuristic Methods: MaxPressure is a classic rule-based method that selects the phase based on the pressure of queued vehicles in different entry and exit directions.
[0042] Online RL: Colight and AdvancedColight are multi-agent DQN models and GAT for neighbor information aggregation.
[0043] Offline RL: Behavior Cloning is an imitation learning baseline that reproduces actions given states as input. Decision Transformer is a sequence modeling-based approach that autoregressively predicts actions given rewards and states from historical trajectories. DataLight is an offline RL model with conservative Q-learning. TransformerLight uses a gated transformer for causal signal phase action prediction.
[0044] In terms of evaluation indicators, the embodiment of the present invention selects three evaluation indicators commonly used in TSC tasks, including average queue length (AQL), average pressure (AP) and average travel time (ATT).
[0045] The present invention reports a comparative analysis between the STLight model and the baseline method in Table 1 below. The results show that STLight outperforms the competing methods on both the Hangzhou 4x4 and Jinan 3x4 datasets. Specifically, offline models such as Decision Transformer and TransformerLight eliminate the need for online exploration while maintaining competitive performance, which verifies the effectiveness of the transition from online RL based TSC methods to offline modeling. Among these offline methods, the model of the present invention improves the average queue length by 7.2% and 12.0% relative to the best performing DataLight model in the Hangzhou dataset. This highlights the significance of sequence modeling and capturing the sequence dependency of MDPs, because DataLight learns from a single MDP token instead of a sequence. In addition, relative to the offline sequence modeling method TransformerLight, which is also adapted from Decision Transformer, the method of the present invention improves the average queue length and average pressure by 11.0% and 14.7% respectively in the Jinan 3x4 dataset, which shows the effectiveness of space-time series modeling in traffic signal control tasks. Overall, the experimental results show that the model of the present invention outperforms the most advanced baseline model in the TSC task.
[0046] Table 1 Comparison of model performance Correspondingly, the present invention also provides a traffic signal control device based on reinforcement learning, which can implement all the processes of the traffic signal control method based on reinforcement learning in the above embodiment.
[0047] See also Figure 4 , Figure 4 1 is a schematic diagram of a preferred embodiment of a traffic signal control device based on reinforcement learning provided by the present invention. The traffic signal control device based on reinforcement learning comprises: The data acquisition module 401 is used to acquire the traffic status data and the road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; An action prediction module 402 is used to input the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; The signal control module 403 is used to control the traffic light at the target intersection to perform the target phase action according to the target phase action.
[0048] Preferably, the training process of the traffic signal prediction model includes: Acquire historical traffic status data of different intersections and generate historical trajectory sequences of all traffic signals; wherein the historical trajectory sequences include state sequences, action sequences and reward sequences; Inputting the historical trajectory sequence and the road network graph into the spatiotemporal encoder to obtain a spatiotemporal enhanced representation output by the spatiotemporal encoder; Inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder; The optimization target is determined by reward-based contrastive learning, and iterative training is performed to obtain a trained traffic signal prediction model.
[0049] Preferably, the spatiotemporal encoder includes a label representation module and a dual spatiotemporal aggregation module, and the inputting of the historical trajectory sequence and the road network graph into the spatiotemporal encoder to obtain the spatiotemporal enhanced representation output by the spatiotemporal encoder specifically includes: Inputting the state sequence into the first fully connected layer in the mark representation module to obtain a state mark representation of the state sequence; Inputting the action sequence into the second fully connected layer in the tag representation module to obtain an action tag representation of the action sequence; For the reward sequence, a lane-level self-attention mechanism is introduced, the features of multiple lanes at the intersection are input into the self-attention unit in the tag representation module as basic tags, and the lane-level representation is aggregated to obtain the reward tag representation of the reward sequence; The state mark representation, the action mark representation, the reward mark representation and the road network diagram are input into the dual-time-space aggregation module to obtain the spatiotemporal enhanced representation output by the dual-time-space aggregation module.
[0050] Preferably, the dual spatiotemporal aggregation module includes a spatial encoder and a temporal encoder, and the state mark representation, the action mark representation, the reward mark representation and the road network graph are input into the dual spatiotemporal aggregation module to obtain the spatiotemporal enhanced representation output by the dual spatiotemporal aggregation module, specifically including: Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the spatial encoder, and learning the spatial dependencies between different traffic signals through the spatial encoder to obtain a spatial enhanced representation; Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the time encoder, and learning the time dependency between different time steps of each traffic signal through the time encoder to obtain a time enhanced representation; The spatial enhanced representation and the temporal enhanced representation are fused through a gate mechanism to obtain a spatiotemporal enhanced representation.
[0051] Preferably, the spatiotemporal enhanced representation includes a spatiotemporal enhanced state representation, an action representation, and a reward representation, and the step of inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder specifically includes: Encoding the reward representation into the state representation and the action representation respectively to generate an encoded trajectory sequence; The trajectory sequence is input into a causal decoder, and the predicted phase action is obtained by autoregressive prediction through a causal self-attention mask.
[0052] Preferably, the method of using reward-based contrastive learning to determine the optimization target and performing iterative training to obtain a trained traffic signal prediction model specifically includes: For a specific anchor point return label, construct the corresponding positive and negative samples; Using a binary classification discriminator to classify the positive sample and the negative sample, and determining a binary classification cross entropy loss; The binary cross entropy loss and the cross entropy loss are used as optimization targets of the traffic signal prediction model, and iterative training is performed until a preset stop condition is reached to obtain a trained traffic signal prediction model.
[0053] In the specific implementation, the working principle, control process and technical effect achieved by the traffic signal control device based on reinforcement learning provided in the embodiment of the present invention are the same as those of the traffic signal control method based on reinforcement learning in the above-mentioned embodiment, and will not be repeated here.
[0054] See also Figure 5 , Figure 51 is a schematic diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a processor 501, a memory 502, and a computer program stored in the memory 502 and configured to be executed by the processor 501. When the processor 501 executes the computer program, the traffic signal control method based on reinforcement learning described in any of the above embodiments is implemented.
[0055] Preferably, the computer program may be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory 502 and executed by the processor 501 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the terminal device.
[0056] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor 501 may be any conventional processor. The processor 501 is the control center of the terminal device, and various parts of the terminal device are connected using various interfaces and lines.
[0057] The memory 502 mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory 502 can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory 502 can also be other volatile solid-state storage devices.
[0058] It should be noted that the above terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art will understand that Figure 5The structural diagram is only an example of the above-mentioned terminal device and does not constitute a limitation of the above-mentioned terminal device. It may include more or less components than shown in the figure, or combine certain components, or different components.
[0059] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the traffic signal control method based on reinforcement learning described in any of the above embodiments.
[0060] An embodiment of the present invention further provides a computer program product, which includes a computer program or computer instructions. When the computer program or the computer instructions are executed by a processor, the traffic signal control method based on reinforcement learning described in any of the above embodiments is implemented.
[0061] The embodiment of the present invention provides a traffic signal control method, device, equipment, medium and product based on reinforcement learning, by obtaining the traffic status data and road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; the traffic status data and the road network diagram are input into a preset traffic signal prediction model to obtain the target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder and reward-based contrastive learning; according to the target phase action, the traffic lights at the target intersection are controlled to perform the target phase action. The embodiment of the present invention combines offline learning, sequence modeling and spatiotemporal dependency modeling to capture the dynamic spatial dependencies between traffic signals, make full use of the complex connections between intersections, and effectively improve the overall performance of traffic signal control.
[0062] It should be noted that the system embodiment described above is merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the system embodiment provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0063] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A traffic signal control method based on reinforcement learning, characterized in that: include: Obtaining traffic status data and a road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; Inputting the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; According to the target phase action, the traffic light at the target intersection is controlled to perform the target phase action.
2. The traffic signal control method based on reinforcement learning according to claim 1, characterized in that: The training process of the traffic signal prediction model includes: Acquire historical traffic status data of different intersections and generate historical trajectory sequences of all traffic signals; wherein the historical trajectory sequences include state sequences, action sequences and reward sequences; Inputting the historical trajectory sequence and the road network graph into the spatiotemporal encoder to obtain a spatiotemporal enhanced representation output by the spatiotemporal encoder; Inputting the spatiotemporal enhanced representation into the reward-based action decoder to obtain a phase action output by the reward-based action decoder; The optimization target is determined by reward-based contrastive learning, and iterative training is performed to obtain a trained traffic signal prediction model.
3. The traffic signal control method based on reinforcement learning as claimed in claim 2, characterized in that: The spatiotemporal encoder includes a marking representation module and a dual spatiotemporal aggregation module, and the historical trajectory sequence and the road network diagram are input into the spatiotemporal encoder to obtain the spatiotemporal enhanced representation output by the spatiotemporal encoder, specifically including: Inputting the state sequence into the first fully connected layer in the mark representation module to obtain a state mark representation of the state sequence; Inputting the action sequence into the second fully connected layer in the tag representation module to obtain an action tag representation of the action sequence; For the reward sequence, a lane-level self-attention mechanism is introduced, the features of multiple lanes at the intersection are input into the self-attention unit in the tag representation module as basic tags, and the lane-level representation is aggregated to obtain the reward tag representation of the reward sequence; The state mark representation, the action mark representation, the reward mark representation and the road network diagram are input into the dual-time-space aggregation module to obtain the spatiotemporal enhanced representation output by the dual-time-space aggregation module.
4. The traffic signal control method based on reinforcement learning as claimed in claim 3, characterized in that: The dual spatiotemporal aggregation module includes a spatial encoder and a temporal encoder, and the state mark representation, the action mark representation, the reward mark representation, and the road network graph are input into the dual spatiotemporal aggregation module to obtain the spatiotemporal enhanced representation output by the dual spatiotemporal aggregation module, specifically including: Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the spatial encoder, and learning the spatial dependencies between different traffic signals through the spatial encoder to obtain a spatial enhanced representation; Inputting the state label representation, the action label representation, the reward label representation and the road network graph into the time encoder, and learning the time dependency between different time steps of each traffic signal through the time encoder to obtain a time enhanced representation; The spatial enhanced representation and the temporal enhanced representation are fused through a gate mechanism to obtain a spatiotemporal enhanced representation.
5. The traffic signal control method based on reinforcement learning as claimed in claim 2, characterized in that: The spatiotemporal enhanced representation includes a spatiotemporal enhanced state representation, an action representation, and a reward representation, and the spatiotemporal enhanced representation is input into the reward-based action decoder to obtain a phase action output by the reward-based action decoder, specifically including: Encoding the reward representation into the state representation and the action representation respectively to generate an encoded trajectory sequence; The trajectory sequence is input into a causal decoder, and the predicted phase action is obtained by autoregressive prediction through a causal self-attention mask.
6. The traffic signal control method based on reinforcement learning as claimed in claim 2, characterized in that: The optimization target is determined by reward-based contrastive learning, and iterative training is performed to obtain a trained traffic signal prediction model, which specifically includes: For a specific anchor point return label, construct the corresponding positive and negative samples; Using a binary classification discriminator to classify the positive sample and the negative sample, and determining a binary classification cross entropy loss; The binary cross entropy loss and the cross entropy loss are used as optimization targets of the traffic signal prediction model, and iterative training is performed until a preset stop condition is reached to obtain a trained traffic signal prediction model.
7. A traffic signal control device based on reinforcement learning, characterized in that: include: A data acquisition module, used to acquire the traffic status data and road network diagram of the target intersection at the current moment; wherein the traffic status data includes the number of lanes at the intersection and the traffic flow of each lane; An action prediction module, used for inputting the traffic state data and the road network diagram into a preset traffic signal prediction model to obtain a target phase action output by the traffic signal prediction model; wherein the traffic signal prediction model includes a spatiotemporal encoder, a reward-based action decoder, and reward-based contrastive learning; A signal control module is used to control the traffic light at the target intersection to perform the target phase action according to the target phase action.
8. A terminal device, characterized in that: The invention comprises a processor and a memory, wherein a computer program is stored in the memory and the computer program is configured to be executed by the processor, and when the processor executes the computer program, the traffic signal control method based on reinforcement learning as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the traffic signal control method based on reinforcement learning as described in any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, the traffic signal control method based on reinforcement learning as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Multi-intersection intelligent traffic signal lamp control method and system based on federal reinforcement learning
CN113643553A
Large-scale traffic signal control method and device based on deep reinforcement learning
CN115331460A
Universal attention-based reinforcement learning model for control systems
US11080602B1
Reinforcement learning model-based information control method and apparatus, and computer device
WO2021051870A1
Cited By
Traffic signal intelligent control method and system based on time-space comparative learning
CN120877541A
A traffic signal intelligent control method and system based on spatio-temporal contrast learning
CN120877541B
Dynamic traffic signal control method and device
CN121148163A
Single-intersection traffic signal control method and system based on video detection result
CN122050168A
A single intersection traffic signal control method and system based on video detection results
CN122050168B
