Abstract
Reinforcement Learning (RL) often faces safety challenges during exploration in stochastic environments. Traditional "offline" shielding methods suffer from state-space explosion, making them impractical for complex systems. This paper proposes an Online Shielding approach that synthesizes safety enforcers on-the-fly. By constructing local sub-MDPs and utilizing the agent's execution "dead time" for probabilistic model checking, the method ensures 100% safety during exploration with minimal overhead. Evaluated on a competitive stochastic environment, the approach demonstrates significant improvements in both safety and performance compared to unshielded agents.
Introduction
Reinforcement Learning is powerful but notoriously "reckless" during its learning phase. To find an optimal policy, an agent must explore, which often involves trial-and-error that leads to "unsafe" states, such as a robot colliding with an obstacle. The existing solution is Shielding: a "correct-by-construction" enforcer that sits between the agent and the environment, blocking any action that violates a safety specification.
However, traditional shields are computed offline. They require developers to exhaustively analyze every possible state-action combination ahead of time. This leads to the "state-space explosion" problem—for complex or multi-agent systems, the resulting shield database is too massive to compute or store, and looking up values in a giant database causes lag at runtime.
Methodology: Online Synthesis
The core innovation presented by researchers from Graz University of Technology and Silicon Austria Labs is the shift to Online Synthesis. Instead of mapping the entire world, the system only analyzes reachable states in the immediate future.
The process follows several key steps:
- Sub-MDP Construction: When an agent starts a task, the system identifies the next "decision state" and builds a small, local Markov Decision Process (sub-MDP) that models the environment and other agents (adversaries) up to a finite horizon ($h$).
- Probabilistic Model Checking: Using the Storm model checker, the system calculates the probability of a safety violation for every available action at the next decision point.
- Exploiting Execution Time: The system utilizes the "dead time" spent by the agent moving to perform these calculations. While the "avatar" is traversing a path, the shield is already computing safety for the next intersection.
- Adaptive Shielding: The shield uses a threshold ($\delta$) to block actions. If an action's risk of failure is significantly higher than the safest possible action, it is pruned.
Experimental Setup
The researchers evaluated their method using a competitive grid-world environment, specifically a 2-player version of the game Snake.
In this setup, a green snake (the RL agent) competes against a purple snake (the stochastic adversary) to collect apples. The safety property is "Collision Avoidance"—the agent must never hit a wall, itself, or the other snake. Unlike standard Snake, the multi-player setting creates a massive state space that is computationally expensive to analyze exhaustively, making it a perfect stress test for online shielding.
Key Results
The transition to online shielding yielded several critical advantages:
- Zero Collisions: The shielded RL agent never encountered a single loss due to collision, even during the earliest stages of training.
- Performance Gains: In the execution phase, the shielded RL agent won 96% of its games, compared to only 54% for the unshielded agent.
- Real-Time Efficiency: For a look-ahead horizon of 17 steps, calculations took less than one second on a standard laptop. Compared to an offline study that took 6 hours for a horizon of 10, this method provides a longer look-ahead with zero offline wait time.
- Scalability: Because the shield only cares about reachable states in the near future, the total size of the environment doesn't matter as much as it does for offline methods.
Conclusion and Future Work
Online shielding effectively bridges the gap between formal safety guarantees and the scalability requirements of modern RL. By ensuring safety for the next $h$ steps and constantly sliding that window forward, the system maintains continuous safety without the memory overhead of offline databases.
Future work includes incorporating quantitative performance measures (like cost and reward) directly into the shield's logic and applying the method to physical industrial robots. Additionally, refining adversary modeling remains a priority, as the shield's guarantees are dependent on the accuracy of the behavior models used during sub-MDP construction.
Summary updated