Safe and Psychologically Pleasant Traffic Signal Control with Reinforcement Learning using Action Masking

Arthur Müller, Matthia Sabatelli

Abstract

Reinforcement Learning (RL) has demonstrated significant potential in optimizing traffic signal control (TSC) within simulated environments. However, real-world deployment remains limited due to the critical requirements of absolute safety and "psychological pleasantness"—the avoidance of erratic signal behavior that causes driver stress. This paper presents a framework that bridges this gap by utilizing action masking to ensure safe-by-design signal transitions. By integrating domain-specific traffic engineering constraints directly into the agent's decision-making process, the proposed method achieves superior convergence, higher cumulative rewards, and more predictable signal behavior compared to traditional safety-override mechanisms.

Introduction

While Reinforcement Learning (RL) agents frequently outperform traditional rule-based systems in traffic simulations, their transition to real-world city intersections is hindered by two primary factors: safety and human factors. In a live environment, an RL agent cannot be allowed to experiment with dangerous configurations, such as simultaneous green lights for conflicting directions. Furthermore, even "safe" transitions can be problematic if they are erratic—for example, switching a signal to red and back to green within a few seconds. Such behavior, while potentially optimal for mathematical flow, is psychologically taxing for human drivers.

Researchers from Fraunhofer and the University of Groningen address these challenges by moving away from post-hoc safety corrections toward a "pre-hoc" action masking framework. This approach ensures that the agent only considers actions that are both safe and socially acceptable.

The Problem with Safety Overrides

A common approach to safety in RL is the implementation of a safety layer—a separate module that intercepts and overrides hazardous actions suggested by the agent. However, this creates a fundamental mismatch: the agent perceives its action as successful, but the environment responds based on the overridden action. This discrepancy leads to inefficient exploration, slow training convergence, and a tendency for agents to become trapped in local optima where they cannot distinguish between productive and restricted behaviors.

Methodology: Action Masking and Temporal Graphs

The proposed framework replaces the safety layer with an action mask that filters the agent's available choices before a decision is made. The methodology consists of several key components:

  1. Safe-by-Design Action Space: Instead of controlling individual signal heads, the agent selects from predefined "traffic phases" consisting of non-conflicting movements.
  2. Temporal Directed Graphs: The intersection is modeled as a graph where nodes represent phases and edges represent legal transitions. This graph incorporates "intergreen times"—the yellow and red clearance intervals required for vehicles to safely clear the intersection.
  3. Action Masking: At each decision point, a mask is generated. If a transition is illegal or violates "psychological" rules (such as minimum green times to prevent flickering), the probability of selecting that action is set to zero.
  4. PPO Integration: The system utilizes Proximal Policy Optimization (PPO). To prevent the agent from becoming over-constrained, the authors modified the entropy bonus in the loss function, ensuring stable exploration despite the restricted action space.
  5. Psychological Constraints: Specific rules were defined to prevent "flickering" (e.g., Phase A → All Red → Phase A). While these sequences might be mathematically efficient in some scenarios, they are eliminated to ensure a predictable experience for drivers.

Experimental Setup

The framework was evaluated using LemgoRL, an open-source benchmark utilizing the SUMO (Simulation of Urban MObility) microscopic traffic simulator. The study focused on a realistic model of the "OWL322" intersection in Lemgo, Germany, using real-world traffic volume data recorded during a typical afternoon rush hour.

Key Results

The experimental results demonstrate that action masking significantly outperforms the traditional safety-layer baseline in several metrics:

  • Convergence Reliability: In baseline tests using a safety layer, 40% of the agents failed to find an optimal policy, getting stuck in local optima with poor reward outcomes. In contrast, 100% of the agents using action masking successfully converged to the optimal policy.
  • Training Efficiency: Masked agents reached peak performance in approximately 2.4 million steps, nearly twice as fast as the 4.3 million steps required by the baseline.
  • Traffic Flow and Stability: The masked agent achieved a higher cumulative reward (-707.1) compared to the baseline (-749.1), with significantly lower variance across training runs, indicating a more reliable and reproducible control strategy.
  • The Pleasantness Trade-off: Interestingly, the inclusion of "psychological" rules slightly reduced the maximum theoretical reward. This suggests a fundamental trade-off in traffic engineering: achieving a system that feels natural and predictable to humans requires a minor sacrifice in raw mathematical throughput.

Conclusion and Future Work

By shifting constraints from an external override to an internal mask, the authors have developed an RL approach that is both safer and more efficient for traffic control. The use of temporal directed graphs allows for the seamless integration of complex traffic engineering rules into the learning process.

Future research will focus on automating the definition of "psychological" rules, potentially learning driver preferences from real-world data rather than relying on manual coding. Additionally, the team plans to move beyond static constraints to accommodate dynamic smart-city requirements, such as emergency vehicle preemption. The ultimate goal remains the physical deployment of this architecture at the OWL322 intersection in Lemgo, marking a significant step toward RL-driven urban infrastructure.

Summary updated

BibTeX
@inproceedings{muller2022safe,
  author = {Arthur Müller and Matthia Sabatelli},
  title = {{Safe and Psychologically Pleasant Traffic Signal Control with Reinforcement Learning using Action Masking}},
  booktitle = {ITSC},
  year = {2022},
  doi = {10.1109/itsc55140.2022.9922306},
}
Figure