A Near-Optimal Algorithm for Safe Reinforcement Learning Under Instantaneous Hard Constraints

Ming Shi, Yingbin Liang, Ness B. Shroff

In many applications of Reinforcement Learning (RL), safety is traditionally defined as keeping the average cost below a certain threshold. However, in high-stakes domains like autonomous driving, robotics, or power grid management, a single failure can be catastrophic. You cannot simply "average out" a car crash.

To address this, researchers have introduced LSVI-NEW, the first near-optimal RL algorithm designed to enforce instantaneous hard constraints in environments with unsafe states and actions. LSVI-NEW ensures safety at every single time step while achieving a regret bound that nearly matches unconstrained state-of-the-art algorithms.

The Challenge of Instantaneous Hard Constraints

Most existing "safe" RL algorithms focus on cumulative constraints, allowing the agent to occasionally visit unsafe states as long as the total expected cost remains acceptable. Instantaneous hard constraints, by contrast, demand zero violations across every step of every episode.

This strict requirement introduces a temporal coupling challenge: an action might appear safe right now, but it could lead the agent into an inescapable "dead end" where every future transition results in an unsafe state. Previous research often bypassed this by ignoring unsafe states entirely or assuming deterministic transitions. This paper tackles the much harder problem of episodic Markov Decision Processes (MDPs) with unsafe states, unsafe actions, and stochastic transitions under a linear mixture model.

Methodology: Introducing LSVI-NEW

The authors propose LSVI-NEW (Least-Square Value Iteration by lookiNg ahEad and peeking backWard). The algorithm balances the "pessimism" required for strict safety with the "optimism" needed for efficient learning through two core mechanisms:

  1. Safe Subgraph Construction (Looking Ahead): The algorithm estimates safe state and action sets in a backward manner. It only permits actions that are safe in the present and guaranteed to lead to states that remain safe in the future.
  2. The Pessimism-Optimism Dilemma: Restricting the agent to safe subgraphs risks making it too timid to explore. To counteract this, the authors designed three novel bonus terms:
  3. Current Transition Bonus: Encourages exploring transitions with high uncertainty.
  4. Future Subgraph Bonus: Encourages moving toward future states that have high uncertainty in their safety or reward potential.
  5. Past Subgraph Bonus (Peeking Backward): Because current safety depends on how the agent reached its current state, this term encourages exploring past paths that might reveal better safe subgraphs.

Experimental Setup and Key Results

The algorithm was evaluated using synthetic environments (to verify theoretical regret and safety) and a stochastic $10 \times 10$ 2D robot path-planning grid, where a robot must navigate to a goal while avoiding obstacles like rocks and cliffs.

  • Zero Violations: Across all experiments, LSVI-NEW achieved zero constraint violations. In contrast, standard RL and even some safe RL baselines (like UCRL or SLUCB-QVI) failed frequently.
  • Near-Optimal Regret: The algorithm achieves a regret bound of $\tilde{O}(\frac{dH^3\sqrt{dK}}{\Delta_c})$. This nearly matches the performance of algorithms that only handle unsafe actions (ignoring unsafe states), proving that rigorous state-safety does not require a massive sacrifice in learning efficiency. The $\Delta_c$ parameter highlights that the problem's difficulty is fundamentally tied to how close safe actions are to the safety threshold.
  • Superior to Conservative Baselines: While highly conservative algorithms (like sMDP) can maintain safety, they often get stuck in low-reward areas. LSVI-NEW consistently achieved higher rewards by safely and actively exploring the environment.

Limitations and Future Directions

While LSVI-NEW represents a significant step forward, it comes with a few limitations. First, it requires a "known seed safe subgraph"—a small initial set of actions known to be safe—to begin exploration, which can be difficult to obtain in completely unknown environments. Second, it assumes knowledge of potential next-state sets, which may be challenging to satisfy in high-dimensional or continuous spaces.

Currently, the framework focuses on a single safety constraint. Extending this approach to handle $N$ instantaneous constraints is a promising direction for future research, which the authors suggest would likely introduce a manageable $\log N$ factor into the regret bound.

Summary updated

BibTeX
@inproceedings{shi2023near,
  author = {Ming Shi and Yingbin Liang and Ness B. Shroff},
  title = {{A Near-Optimal Algorithm for Safe Reinforcement Learning Under Instantaneous Hard Constraints}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=3HMO9iSBdy},
}
Figure