State-wise Constrained Policy Optimization

Weiye Zhao, Rui Chen, Yifan Sun, Tianhao Wei, Changliu Liu · DOI

TL;DR

SCPO is the first general-purpose policy search algorithm designed to handle state-wise constraints—ensuring safety at every single time step rather than just on average. By introducing the Maximum Markov Decision Process (MMDP) framework, the authors provide theoretical guarantees for safety and performance, allowing robots to navigate complex, high-dimensional environments without catastrophic failures.

The Challenge of State-wise Safety

Most "Safe Reinforcement Learning" (Safe RL) relies on the Constrained Markov Decision Process (CMDP) framework. In a CMDP, the goal is to maximize rewards while keeping the cumulative cost (the sum of costs over an entire episode) below a certain threshold.

However, in the real world, "average safety" is often insufficient. If a self-driving car avoids ten small bumps but has one high-speed collision, the cumulative cost might look acceptable, but the outcome is catastrophic. Many tasks require state-wise constraints, where safety must be maintained at every instantaneous moment (e.g., staying within a lane or avoiding a collision now).

The challenge is that enforcing a constraint at every time step is computationally expensive—it effectively turns one constraint into hundreds or thousands, making standard optimization algorithms crawl.

Methodology: From Maximum to Summation

The authors bridge this gap with two major innovations:

  1. Maximum Markov Decision Process (MMDP): Instead of looking at the sum of costs, they focus on the expected maximum cost along a trajectory. To make this mathematically tractable, they introduce a "tag" ($M$) that tracks the highest cost encountered so far in an episode. They then define "cost increments" ($D$), which represent how much the current cost exceeds the previous maximum.
The MMDP framework decomposes the maximum cost into a sum of positive increments $D_i$.

As illustrated in Figure 1, this clever trick allows them to treat the "maximum" problem as a "summation" problem, which fits perfectly into standard RL machinery like advantage functions and value networks.

  1. SCPO Algorithm: Building on the foundations of Trust Region Policy Optimization (TRPO) and Constrained Policy Optimization (CPO), the authors derive a new policy update rule. They prove a theoretical bound on the difference in maximum cost between two policies, allowing them to perform safe policy updates that guarantee (in expectation) that the agent won't violate state-wise constraints.
  2. Sub-sampling Trick: Because the maximum cost only increases occasionally, the data used to train the "safety critic" is heavily skewed toward zero. The authors use a sub-sampling technique to balance the training data, which they show is critical for the algorithm's success in high-dimensional tasks.

Experimental Setup

The authors evaluated SCPO on an Upgraded Safety Gym. While the original Safety Gym is a standard benchmark, this paper adds high-dimensional systems including a bipedal Walker, a quadrupedal Ant, and a Humanoid. It also introduces 3D Environments involving a Drone and a 3-joint Robot Arm navigating in 3D space, with complex constraints like "Hazard" areas and "Pillar" obstacles across 14 different test suites.

Key Results and Performance

SCPO demonstrates superior safety and performance retention across complex tasks. Traditional CMDP methods often struggle to balance safety and reward, frequently oscillating between being too cautious or too risky. SCPO’s focus on the worst-case violation within a trajectory leads to much more stable convergence toward safe behavior.

Performance metrics for Ant-Hazard-8 and Walker-Hazard-8 environments.

As shown in Figure 5, in high-dimensional tasks like Ant-Hazard-8 and Walker-Hazard-8, SCPO achieved near-zero cost rates, significantly outperforming baselines like CPO, TRPO-Lagrangian, and PCPO, which often failed to converge to safe policies. Despite these strict safety requirements, SCPO maintained reward performance comparable to or better than other safe RL methods. Furthermore, SCPO exhibits nearly identical GPU occupancy and time consumption compared to standard CPO, proving it is a practical, scalable solution for complex robotics.

Limitations and Future Work

The primary limitation acknowledged by the authors is that SCPO guarantees safety in expectation. While this is a massive step forward, "safety in expectation" still allows for the statistical possibility of a violation during deployment.

Future work aims to move toward absolute state-wise constraint satisfaction—bounding the maximal possible cost rather than just the expected maximum. Additionally, the authors suggest that while SCPO is end-to-end, real-world deployments should still use an explicit safety monitor as a final fail-safe.

Summary updated

BibTeX
@misc{zhao2023state,
  author = {Weiye Zhao and Rui Chen and Yifan Sun and Tianhao Wei and Changliu Liu},
  title = {{State-wise Constrained Policy Optimization}},
  year = {2023},
  eprint = {2306.12594},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.12594},
}
Figure