Safe Reinforcement Learning with Linear Function Approximation

Sanae Amani, Christos Thrampoulidis, Lin F. Yang

TL;DR

This paper introduces two new algorithms, SLUCB-QVI and RSLUCB-QVI, that achieve a "holy grail" in Reinforcement Learning: maximizing rewards while guaranteeing zero safety violations during the learning process. By leveraging linear function approximation, these algorithms scale beyond simple toy problems to handle large state-action spaces with theoretical regret bounds that nearly match those of their "unsafe" counterparts.

What Problem Does This Paper Address?

In classical Reinforcement Learning (RL), an agent learns by exploring: it tries various actions to see which ones yield the best rewards. While this works for video games, it’s a recipe for disaster in the real world. You wouldn't want a self-driving car to "explore" what happens when it drives off a cliff just to see if there's a shortcut at the bottom.

Most existing "Safe RL" methods fall into two traps:

  1. The "Oops" Factor: They allow a small number of safety violations during training (e.g., the car crashes ten times before it learns not to).
  2. Scalability Issues: They only work in "tabular" settings, where every possible state and action can be listed in a giant table. This is impossible for complex, real-world systems.

The authors tackle these gaps by focusing on Linear MDPs (Markov Decision Processes), where transitions, rewards, and safety costs are modeled as linear functions of features. Their goal is to ensure the agent never plays an unsafe action, even while it is still learning the environment's rules.

Methods

The researchers propose two primary algorithms based on the "Optimism in the Face of Uncertainty" principle, specifically building on the Least-Squares Value Iteration (LSVI-UCB) framework:

  • SLUCB-QVI (Safe Linear UCB Q/V Iteration): Designed for deterministic policies. It uses a geometric assumption called "star-convexity" to efficiently find the best safe action.
  • RSLUCB-QVI: An extension for randomized policies. This version is more flexible as it doesn't require the star-convexity assumption, making it easier to apply to a wider range of problems.

The Secret Sauce: Conservative Safe Sets Instead of guessing if an action is safe, the algorithms maintain a high-confidence "inner approximation" of the safe action set. They use a known safe action (a "baseline" behavior, like staying in the lane) to build a conservative boundary. The agent is only allowed to choose actions from this estimated safe set. As the agent gathers more data, its estimate of the safe set expands, allowing for more aggressive reward-seeking without ever crossing the line into danger.

Datasets

The authors evaluated their algorithms using two main setups:

  1. Synthetic Environments: Custom-built simulations designed to verify the theoretical regret bounds and test the algorithms' sensitivity to different parameters.
  2. Frozen Lake (OpenAI Gym): A classic RL benchmark modified for safety. In this version, the agent must navigate a grid to reach a goal while avoiding "danger" holes. Unlike standard RL, falling into a hole once is considered a catastrophic failure that the agent must avoid entirely during training.

Key Insights and Ideas

  • The Safety-Regret Trade-off ($\kappa$): The paper introduces a constant, $\kappa$, which characterizes the difficulty of the safety constraint. If the "safe" actions are very close to the "unsafe" boundary, learning becomes harder. However, the regret remains sub-linear, meaning the agent eventually performs as well as an optimal safe policy.
  • Knowledge of a "Safe Seed": The algorithms require knowing at least one safe action $a_0(s)$ for every state. This is a realistic assumption—most industrial systems have a "safe mode" or a human-designed baseline policy that is known to be non-catastrophic.
  • Linearity as a Bridge: By moving to linear function approximation, the authors provide a bridge between simple tabular models and complex deep RL. Linear models are powerful enough to handle high-dimensional features while remaining mathematically tractable for safety proofs.

Key Results

  • Zero Violations: In empirical tests, SLUCB-QVI and RSLUCB-QVI recorded zero safety violations, whereas standard "unsafe" algorithms (even those modified with penalty terms) frequently violated constraints during the early stages of learning.
  • Near-Optimal Regret: The theoretical regret bound is $\tilde{\mathcal{O}}\left(\kappa\sqrt{d^3H^3T}\right)$. This is significant because it shows that the "cost" of being perfectly safe is just a constant factor ($\kappa$) compared to algorithms that are allowed to be unsafe.
  • Efficiency: In the Frozen Lake environment, RSLUCB-QVI reached the goal faster and more reliably than CISR, a competing safe RL algorithm that relies on a "teacher" to intervene.

Limitations and Future Work

While a major step forward, the paper notes a few areas for further exploration:

  • Linearity Constraints: The proofs rely on the environment being a "Linear MDP." While many systems can be linearized, highly non-linear dynamics (like complex fluid flow or humanoid robotics) might require extending these ideas to kernel-based or neural network approximations.
  • The Safe Action Assumption: The requirement of a known safe action $a_0(s)$ is a starting point. Future work could look at "Safe Discovery," where the agent must find its first safe action without any prior knowledge.
  • Computational Overhead: Calculating the conservative safe set and optimizing over it at every step is more computationally expensive than standard RL. Streamlining these calculations for real-time applications remains a challenge.

Summary updated

Abstract

Safety in reinforcement learning has become increasingly important in recent years. Yet, existing solutions either fail to strictly avoid choosing unsafe actions, which may lead to catastrophic results in safety-critical systems, or fail to provide regret guarantees for settings where safety constraints need to be learned. In this paper, we address both problems by first modeling safety as an unknown linear cost function of states and actions, which must always fall below a certain threshold. We then present algorithms, termed SLUCB-QVI and RSLUCB-QVI, for episodic Markov decision processes (MDPs) with linear function approximation. We show that SLUCB-QVI and RSLUCB-QVI, while with \emph{no safety violation}, achieve a $\tilde{\mathcal{O}}\left(κ\sqrt{d^3H^3T}\right)$ regret, nearly matching that of state-of-the-art unsafe algorithms, where $H$ is the duration of each episode, $d$ is the dimension of the feature mapping, $κ$ is a constant characterizing the safety constraints, and $T$ is the total number of action plays. We further present numerical simulations that corroborate our theoretical findings.
BibTeX
@inproceedings{amani2021safe,
  author = {Sanae Amani and Christos Thrampoulidis and Lin F. Yang},
  title = {{Safe Reinforcement Learning with Linear Function Approximation}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure