Learning with Safety Constraints: Sample Complexity of Reinforcement Learning for Constrained MDPs

Aria HasanzadeZonuzy, Archana Bura, Dileep M. Kalathil, Srinivas Shakkottai

Introduction

Standard Reinforcement Learning (RL) is designed to maximize a reward signal, often through aggressive trial and error. In real-world applications—such as power grids, autonomous vehicles, or chemical plants—this "move fast and break things" approach is unacceptable. To address this, researchers use Constrained Markov Decision Processes (CMDPs), where the agent must maximize rewards while staying within strict safety bounds (e.g., maintaining temperature limits or resource budgets).

While algorithms for CMDPs exist, their "sample complexity"—the amount of data required to learn a safe and optimal policy—has been a major unknown. This paper provides the first rigorous analysis of this complexity, tackling the "Probably Approximately Correct" (PAC) framework: how many samples does an agent need to find a policy that is both high-performing and safe with high probability?

Methodology

The authors propose and analyze two model-based algorithms designed for efficiency and safety:

  1. Optimistic-GMBL (Generative Model Based Learning): A batch approach where the agent collects a fixed number of samples for every state-action pair to build a transition model, then solves an optimistic planning problem using Extended Linear Programming (ELP).
  2. Online-CRL (Online Constrained RL): A more sophisticated approach that updates its model episode-by-episode. It uses concepts of "knownness" and "importance" to prioritize exploration in critical areas of the environment.

A key innovation is the use of optimism to handle feasibility. In CMDPs, an estimated model might appear "infeasible" (no safe path exists) even if the real environment is safe. By using confidence intervals based on Bernstein and Hoeffding inequalities, the authors create a "ball" of possible models and search for the most optimistic one that remains feasible. Crucially, these inequalities ensure the constraints remain linear, allowing the use of standard, efficient Linear Programming solvers.

Theoretical Contributions: The Logarithmic Scaling Result

The most significant finding is that the sample complexity of CMDPs scales with $\log(N)$, where $N$ is the number of constraints. This "Logarithmic Surprise" suggests that adding a massive number of safety rules to a system does not significantly increase the training data required.

The authors prove that for a finite-horizon CMDP, the number of episodes needed to reach $\epsilon$-accuracy with $1-\delta$ probability is roughly: $$\tilde{O}\left(\frac{|S|^2|A|H^2}{\epsilon^2} \log \frac{N}{\delta}\right)$$ where $|S|$ is the state space, $|A|$ is the action space, $H$ is the time horizon, and $N$ is the number of constraints.

Empirical Evaluation

The researchers evaluated their algorithms using simulated Grid World environments featuring action budgets (resource limits) and state occupancy constraints (avoiding dangerous zones).

Constraint violation over time for Online-CRL and GMBL. Online-CRL demonstrates significantly lower peak violations and faster convergence to safety.
Value difference (optimality gap) over time. Online-CRL reaches optimal performance much more rapidly than the batch-based GMBL approach.

In these simulations, Online-CRL significantly outperformed the generative approach. By updating its model in real-time, it avoids wasting samples on unimportant states and focuses on the boundaries where safety constraints and rewards collide.

Discussion and Future Work

While this work establishes a strong theoretical foundation for safe RL, several challenges remain:

  • Safety During Training: The current bounds apply to the final policy. The algorithms do not guarantee safety during the exploration phase, which is critical for real-world deployment.
  • Assumed Feasibility: The analysis assumes at least one safe policy exists. The behavior of these algorithms in fundamentally "unwinnable" environments requires further study.
  • Continuous State Spaces: Extending these logarithmic scaling results to continuous spaces using deep neural networks remains an open challenge for the field.

Summary updated

BibTeX
@inproceedings{hasanzadezonuzy2021learning,
  author = {Aria HasanzadeZonuzy and Archana Bura and Dileep M. Kalathil and Srinivas Shakkottai},
  title = {{Learning with Safety Constraints: Sample Complexity of Reinforcement Learning for Constrained MDPs}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i9.16937},
}
Figure