Safe Reinforcement Learning with Chance-constrained Model Predictive Control

Samuel Pfrommer, Tanmay Gautam, Alec Zhou, Somayeh Sojoudi

Abstract

Real-world reinforcement learning (RL) problems often demand that agents behave safely by obeying a set of designed constraints. We address the challenge of safe RL by coupling a safety guide based on Chance-constrained Model Predictive Control (MPC) with a policy gradient method. By incorporating a safety penalty that encourages the base policy to align with the MPC-guided safe policy, we enable the agent to internalize safety constraints, eventually allowing for the removal of the computationally expensive safety guide after training.

Introduction

Reinforcement Learning (RL) has demonstrated remarkable success in mastering complex tasks through trial and error. However, in physical domains such as robotics or power grid management, errors can lead to catastrophic failures. The primary challenge lies in Safe Exploration: enabling an agent to learn without violating critical safety constraints during the training process.

Current approaches generally fall into two categories: external safety filters and constrained RL. Safety filters, like standard MPC, override unsafe actions but often fail to teach the RL agent why the override occurred, leading to a persistent mismatch between the agent's objectives and safety requirements. Conversely, constrained RL typically ensures safety only "in expectation," which is insufficient for systems where a single violation is unacceptable. This work proposes a framework that bridges these two paradigms.

Methodology

The proposed framework consists of two integrated components: a Safety Guide and a Safety Penalty mechanism.

The Safety Guide (MPC)

During training, every action proposed by the RL Base Policy ($\pi_\theta$) is processed by a Safety Guide. This guide solves a Chance-constrained Model Predictive Control (MPC) problem by looking ahead several steps to ensure the probability of violating safety constraints remains below a predefined threshold ($\epsilon$). The guide outputs a modified, safe action distribution ($\pi_\theta^{\text{safe}}$).

The Safety Penalty

To ensure the agent learns from the guide rather than just being overridden by it, the authors introduce a Safety Penalty. This penalty is defined as the distance (specifically the KL divergence) between the original base policy and the safe policy provided by the guide. By minimizing this penalty alongside the standard reward, the agent is incentivized to propose actions that are inherently safe.

Overview of the Safe RL framework integrating a Base Policy with an MPC-based Safety Guide and a Safety Penalty.

Experimental Evaluation

The framework was evaluated using a high-fidelity simulation of a Linearized 2D Quadrotor. The agent's task was to hover near the ground while maintaining a centered position. Safety constraints were strictly defined: the drone must maintain a minimum altitude ($y \geq 0.05$) and its tilt must not exceed 0.5 radians. Any violation resulted in immediate episode termination.

Key Results and Insights

  • Provable Safety: The method achieved zero violations over one million training steps. The authors demonstrate that the expected number of safety violations is bounded by the safety tolerance $\epsilon$ over the training duration.
  • Internalization of Safety: A key theoretical contribution (Theorem 3) proves that an optimal base policy trained with the safety penalty will eventually converge to the safe policy. This "training wheels" effect allows the MPC guide to be removed at test time without compromising safety.
  • Performance Retention: The agent reached performance levels comparable to unconstrained RL agents, indicating that the safety constraints did not significantly hinder the learning of the primary task.

Discussion and Limitations

While the framework provides strong safety guarantees, it currently relies on linear system dynamics and polyhedral safe sets to maintain convex optimization. Furthermore, the safety guide requires an accurate model of the environment. Future research will explore extending these guarantees to non-linear systems and integrating online model learning to handle environmental uncertainty.

Summary updated

BibTeX
@inproceedings{pfrommer2022safe,
  author = {Samuel Pfrommer and Tanmay Gautam and Alec Zhou and Somayeh Sojoudi},
  title = {{Safe Reinforcement Learning with Chance-constrained Model Predictive Control}},
  booktitle = {L4DC},
  year = {2022},
  url = {https://openreview.net/forum?id=i626lyqmp8},
}
Figure