In many real-world scenarios we need to consider formal requirements, such as safety and constraint compliance, to deploy Reinforcement Learning (RL) agents. In this paper we introduce RecReg, a safe RL framework capable of enforcing non-Markovian regular safety properties via recovery-based shielding. RecReg is a unified approach that supports different levels of a priori knowledge and safety guarantees. The paper primarily focuses on building the theoretical foundations for RecReg in the tabular setting, providing rigorous safety and convergence guarantees that are not present in related work. We provide an extensive set of empirical results using the MASA-Safe-RL library, and we outline an extension of RecReg to deep RL domains using SOTA model-based RL. Our empirical results demonstrate that RecReg achieves efficient learning and matches the theory in this paper.
Figures & tables
Figure 1: Experimental results for the MASA-Safe-RL [ 19 ] benchmark. Normalized returns and safety probabilities are averaged over 10 random seeds for the final 100 episodes in training. The dashed horizontal line in the safety probability plots denotes the theoretical safety probability given by Theorem 1 . Scores aggregated across all environments are provided in the bottom right corner.
Algorithm
Metric
MediaStreaming
BridgeCrossing
ColourBomb…V2 (Prop. 3)
MiniPacman
1−ϵ=0.96
1−ϵ=0.95
1−ϵ=0.99
1−ϵ=0.99
RecReg-Exact
Ep. Return
−21.355±0.240
1.000±0.000
26.294±0.359
0.995±0.001
Safety Prob.
0.951±0.009
1.000±0.000
0.997±0.002
0.997±0.002
ProbShield
Ep. Return
−25.964±1.040
0.933±0.067
19.046±1.490
0.966±0.006
Safety Prob.
0.990±0.005
0.978±0.011
0.985±0.006
0.993±0.003
Table 1: Experimental results for ProbShield and RecReg-Exact . Bold text denotes the best return; grey text denotes algorithms that fail the safety threshold.
Figure 2: Learning curves for Atari Seaquest. Episodic reward and violation rate are averaged over 5 random seeds.
Appendix figures & tables35 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 3: Estimating the safety probability with RSSM.
Figure 4: Seaquest environment
Figure 5: Safety Gym vehicles.
Figure 6: Safety Gym tasks and constraints.
DreamerV3
Aug. Lag.
AMBS
Deep-RecReg
PPO-Lag
CPO
seaquest ( φ1 )
Return
2440±400
706±162
2350±340
3140±326
506±7.57
543±47.4
Viol. rate
5.30±0.657
9.83±1.39
4.20±0.215
4.43±0.187
25.6±0.468
23.9±1.97
seaquest ( φ2 )
Return
2440±400
580±54.0
2480±483
2700±364
79.6±10.5
342±17.1
Viol. rate
17.9±5.77
1.86±0.891
2.00±0.767
2.52±0.673
16.8±2.17
22.0±4.45
Appendix
Table 2: Results for the deep RL experiments on Atari Seaquest. The violation rate is scaled by 10−4 .
Figure 7: Learning curves for Atari Seaquest. Episodic reward and violation rate are averaged over 5 random seeds.
DreamerV3
Aug. Lag.
AMBS
Deep-RecReg
PointGoal1
Return
22.2±0.629
19.1±0.661
16.7±2.58
17.3±0.628
Viol. rate
0.0562±0.00239
0.0111±0.00867
0.00383±0.00346
0.00500±0.00237
PointGoal2
Return
20.6±1.22
12.7±1.58
6.42±1.04
7.88±2.08
Viol. rate
0.188±0.0177
0.0337±0.0112
0.0126±0.00909
0.0213±0.0179
CarGoal1
Return
17.4±2.13
11.2±2.96
7.26±3.52
7.56±3.23
Viol. rate
0.0836±0.0101
0.0444±0.0308
0.00552±0.00393
0.00367±0.00415
Appendix
Table 3: Results for the deep RL experiments on SafetyGym .
Figure 8: Learning curves for Safety Gym environments. Episodic reward and violation rate are averaged over 5 random seeds.
Name
Symbol
Value
Replay capacity
D
106
Batch size
B
16
Batch length
-
64
Number of envs
-
8
Train ratio
-
64
Number of MLP layers
-
5
Appendix
Table 4: Hyperparameter details for the DreamerV3-based algorithms: Aug. Lag., AMBS and Deep-RecReg .
Algorithm
Metric
MediaStreaming
BridgeCrossing
BridgeCrossingV2
Colour…World
1−ϵ=0.96
1−ϵ=0.95
1−ϵ=0.99
1−ϵ=0.95
QL
Ep. Return
−0.017±0.009
0.303±0.287
0.986±0.004
1.000±0.000
Safety Prob.
0.000±0.000
0.368±0.260
0.986±0.004
0.000±0.000
QL( λ )
Ep. Return
−22.291±0.377
0.998±0.001
0.414±0.258
1.000±0.000
Safety Prob.
0.975±0.011
0.998±0.001
0.985±0.010
0.998±0.001
RecReg
Ep. Return
−21.726±0.234
0.998±0.002
0.665±0.272
0.911±0.174
Appendix
Table 5: Experimental results with raw returns . Bold text denotes the best value among algorithms satisfying the safety threshold; grey text denotes algorithms that fail the safety threshold.
Algorithm
Metric
ColourBomb…(Prop. 2)
ColourBomb…V2
ColourBomb…V2 (Prop. 2)
Colour…V2 (Prop. 3)
MiniPacman
1−ϵ=0.95
1−ϵ=0.99
1−ϵ=0.99
1−ϵ=0.99
1−ϵ=0.99
QL
…
1.000±0.000
32.701±0.599
32.701±0.599
32.701±0.599
0.989±0.003
…
0.076±0.007
0.000±0.000
0.000±0.000
0.000±0.000
0.396±0.018
QL( λ )
…
0.996±0.002
20.484±2.408
22.663±1.379
22.394±0.364
0.925±0.009
…
0.996±0.002
0.877±0.048
0.949±0.039
0.947±0.013
0.883±0.007
RecReg
…
0.935±0.126
21.358±0.687
21.952±1.277
26.466±0.095
0.912±0.012
Appendix
Table 6: Experimental results with normalized returns . Bold text denotes the best value among algorithms satisfying the safety threshold; grey text denotes algorithms that fail the safety threshold.
Figure 9: Learning curves for Media Streaming.
Figure 10: Learning curves for Bridge Crossing.
Figure 11: Learning curves for Bridge Crossing V2.
Figure 12: Learning curves for Colour Bomb Gridworld (Property 1).
Figure 13: Learning curves for Colour Bomb Gridworld (Property 2).
Shielding is an effective approach to formally guarantee the safety of reinforcement learning agents in Markov decision processes (MDPs). However, existing shielding techniques typically assume knowledge of the safety-relevant transition dynamics - a requirement that is seldom met in practice. To address this limitation, we introduce a novel shielding framework for robust MDPs (RMDPs), i.e., MDPs with sets of transition probabilities. We define safety as the satisfaction of a linear temporal logic (LTL) formula with a certain threshold probability under the worst-case transition probabilities of the RMDP. We prove that our shielding framework is both sound and optimal for the RMDP: every policy admissible by the shield is safe, and conversely, every safe RMDP policy is admissible by the shield. We combine our approach with existing sampling methods for learning transition probabilities of MDPs with probably approximately correct (PAC) guarantees. This combination enables the construction of shields for MDPs that, with high confidence, guarantee safety while remaining minimally restrictive. Our experiments show that our shields for learned RMDPs guarantee safety in unknown MDPs while recovering strong expected return as the number of samples increases.
Edwin Hamel-De le Court, Thom Badings, Alessandro Abate +2
Department of Computer Science, University of Manchester, United Kingdom · Faculty of Computer Science & DSME, RWTH Aachen University, Germany · Department of Computer Science, University of Oxford, United Kingdom +1
Safe exploration remains a fundamental challenge in reinforcement learning (RL), limiting the deployment of RL agents in the real world. We propose Sampling-Based Safe Reinforcement Learning (SBSRL), a model-based RL algorithm that maintains safety throughout the learning process by enforcing constraints jointly across a finite set of dynamics samples. This formulation approximates an intractable worst-case optimization over uncertain dynamics and enables practical safety guarantees in continuous domains. We further introduce an exploration strategy based on constraining epistemic uncertainty, eliminating the need for explicit exploration bonuses. Under regularity conditions, we derive high-probability guarantees of safety throughout learning and a finite-time sample complexity bound for recovering a near-optimal policy. Empirically, SBSRL achieves safe and efficient exploration both in simulation and in real robotic hardware, and readily extends to practical deep-ensemble implementations that scale to high-dimensional continuous control problems.
In offline reinforcement learning (RL), we learn policies from fixed datasets without environment interaction. The major challenges are to provide guarantees on the (1) performance and (2) safety of the resulting policy. A technique called safe policy improvement (SPI) provides a performance guarantee: with high probability, the new policy outperforms a given baseline policy, which is assumed to be safe. Orthogonally, in the context of safe RL, a shield provides a safety guarantee by restricting the action space to those actions that are provably safe with respect to a given safety-relevant model. We integrate these paradigms by extending shielding to offline RL, relying solely on the available dataset and knowledge of safe and unsafe states. Then, we shield the policy improvement steps, guaranteeing, with high probability, a safe policy. Experimental results demonstrate that shielded SPI outperforms its unshielded counterpart, improving both average and worst-case performance, particularly in low-data regimes.
Maris F. L. Galesloot, Thomas Rhemrev, Nils Jansen
Radboud University · Nijmegen, The Netherlands · Ruhr University & Radboud University +1