First Order Constrained Optimization in Policy Space

Yiming Zhang, Quan Vuong, Keith W. RossNeurIPS 2020

TL;DR

FOCOPS is a novel reinforcement learning algorithm designed to solve the "safety vs. performance" trade-off using a simple, two-step first-order optimization process. It consistently outperforms complex second-order methods like Constrained Policy Optimization (CPO) by maximizing rewards while strictly adhering to safety constraints, making it both more effective and easier to implement for real-world robotics.

The Challenge of Safe Reinforcement Learning

In standard Reinforcement Learning (RL), an agent learns by trial and error to maximize a reward. However, in real-world applications—such as training a robot to walk—simply "maximizing reward" is insufficient. Agents must also adhere to strict constraints: a robot shouldn't exceed a certain speed, overheat its motors, or collide with its environment.

These scenarios are modeled as Constrained Markov Decision Processes (CMDPs). The primary challenge is that existing "Safe RL" algorithms are often computationally prohibitive. The current state-of-the-art, CPO, relies on second-order mathematics, including Taylor approximations and inverting high-dimensional Fisher information matrices. This approach is computationally expensive, prone to numerical instability, and frequently results in "infeasible" updates that waste valuable training data. The authors of FOCOPS sought a simpler, "first-order" method to achieve safety without the heavy mathematical overhead.

The FOCOPS Approach

The authors propose FOCOPS, which simplifies the policy update by breaking it into two distinct steps:

  1. Finding the "Ideal" Update: Instead of updating the neural network parameters directly, FOCOPS first identifies the optimal update in the nonparametric policy space (the space of all possible probability distributions over actions). This sub-problem has a near-closed-form solution resembling a Boltzmann distribution: it assigns high probabilities to actions with high rewards, offset by a penalty for actions that violate constraints.
  2. Projecting Back to the Network: Because a "nonparametric" policy cannot be deployed on a real robot, this ideal update is "projected" back onto the neural network. This is achieved by minimizing the KL divergence between the current network and the ideal distribution found in Step 1.

Crucially, because this second step only requires calculating first-order derivatives (gradients), it is significantly simpler to implement and more stable than methods requiring second-order curvature information.

Experimental Setup

The researchers evaluated FOCOPS using the MuJoCo physics engine via the OpenAI Gym API, focusing on two main benchmarks:

  • Robots with Speed Limits: Six standard locomotive agents (Ant, HalfCheetah, Hopper, Humanoid, Swimmer, and Walker2d) were tasked with moving as fast as possible while staying under a specific velocity threshold (set to 50% of an unconstrained agent's maximum speed).
  • Circle Tasks: Two agents (Ant and Humanoid) had to run in a circle while staying within a safe "ring" area, testing the agent's ability to balance complex movement with spatial constraints.

Key Results

FOCOPS demonstrated significant improvements over existing baselines across multiple environments.

Superior Performance on Speed Limits

In the speed-limit tasks, FOCOPS achieved higher rewards than CPO and Lagrangian-PPO on 5 out of 6 environments while maintaining similar or better constraint satisfaction.

Learning curves for six standard MuJoCo environments showing FOCOPS achieving higher rewards while satisfying cost thresholds.

Circle Task Dominance

On the challenging Humanoid-Circle task, FOCOPS achieved a reward of 1106.1, significantly outperforming CPO (671.0) and TRPO-Lagrangian (697.5), all while keeping the cost within the required limit of 50.

Performance on the AntCircle and HumanoidCircle tasks, demonstrating FOCOPS's dominance in complex spatial constraints.

Additional Insights

  • Separation of Concerns: By separating the optimization (finding the best distribution) from the representation (fitting the neural network), FOCOPS bypasses the need for complex matrix inversions.
  • Simplicity is a Feature: FOCOPS proves that first-order methods can be more robust than theoretically superior second-order methods in constrained settings.
  • Intuitive Penalty: The Lagrange multiplier $\nu$ acts as a dynamic safety brake. If the agent violates a constraint, $\nu$ increases, making high-cost actions exponentially less likely.
  • Generalization & Stability: When tested on unseen random seeds, FOCOPS showed better generalization than its competitors. It also proved relatively insensitive to the choice of the Lagrange multiplier limit ($\nu_{max}$), simplifying hyperparameter tuning.

Limitations and Future Work

While FOCOPS is a significant step forward, the authors note a few areas for future improvement:

  • Sample Efficiency: Currently, FOCOPS is an on-policy algorithm, requiring new data for every update. Extending this to off-policy learning would greatly improve sample efficiency.
  • Complex Constraints: The paper primarily deals with expected cost constraints. Future work could explore "sample path constraints" to ensure safety at every single time step.
  • Human-in-the-Loop: Applying FOCOPS to constraints expressed through human preferences or natural language could provide more intuitive safety guardrails than raw numerical cost functions.

Summary updated

BibTeX
@inproceedings{zhang2020first,
  author = {Yiming Zhang and Quan Vuong and Keith W. Ross},
  title = {{First Order Constrained Optimization in Policy Space}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure