Simplifying Constraint Inference with Inverse Reinforcement Learning

Adriana Hugessen, Harley Wiltzer, Glen Berseth

TL;DR

Inverse Constrained Reinforcement Learning (ICRL) extracts safety rules from expert demonstrations, but current methods rely on a notoriously unstable and complex tri-level optimization process. This paper proves that under broad conditions, ICRL is mathematically equivalent to standard Inverse Reinforcement Learning (IRL). By applying a few practical tweaks to standard IRL, the authors achieve better or equal performance on constraint inference benchmarks while drastically simplifying the implementation and tuning process.

The Challenge of Safe Reinforcement Learning

Training Reinforcement Learning (RL) agents in the real world is risky because agents learn by trial and error, inevitably leading to unsafe behaviors during training. One workaround is Imitation Learning (IL), where an agent copies a "safe" human expert. However, IL agents generally cannot outperform the expert and struggle to transfer their skills to new tasks.

Ideally, we want to look at expert data, extract only the implicit safety constraints the expert is following, and then use standard RL to maximize a task reward while obeying those learned constraints. This is the goal of Inverse Constrained RL (ICRL).

The problem? Current ICRL methods are incredibly complex. They use a nested "tri-level" optimization loop: they guess a constraint, solve a Constrained Markov Decision Process (CMDP) using a Lagrange multiplier, and then update the policy. This creates a jagged optimization landscape that is highly sensitive to hyperparameters and prone to sub-optimal performance. The authors ask: do we really need this complex CMDP inner loop, or can simpler methods do the job?

Methods: Reducing ICRL to Standard IRL

The authors provide a theoretical proof showing that if the class of constraint functions is a "convex cone" (meaning it is closed under scalar multiplication), the complex tri-level ICRL problem collapses into a simpler bi-level optimization problem. In other words, ICRL is mathematically equivalent to standard Inverse Reinforcement Learning (IRL).

Because a neural network can learn to scale its own outputs, it doesn't need an explicit Lagrange multiplier to enforce constraints. To make standard IRL work practically for constraint inference, the authors propose IRL-Plus, which modifies standard Maximum Entropy IRL (using Soft Actor-Critic) with three practical techniques:

  1. L2 Regularization: Instead of hard-clipping the neural network's output to keep learned costs positive (which causes vanishing gradients), they use a Leaky ReLU activation and apply an L2 penalty to the learned cost of expert trajectories.
  2. Separate Critics: They use separate critic networks for the task reward (which is fixed) and the constraint function (which is constantly updating). This disentangles the learning signals.
  3. Policy Resetting: To prevent the agent from getting permanently stuck in early, unconstrained behaviors (a phenomenon known as primacy bias), they periodically reset the final layer of the constraint critic network.

Key Insights

  • The Lagrange multiplier is redundant: The core realization is that the only difference between solving a constrained MDP and an unconstrained MDP with a penalty is the Lagrange multiplier. If you are learning the penalty function from scratch using a neural network, the network can implicitly learn the multiplier's scaling factor itself.
  • Simplicity unlocks progress: By stripping away the CMDP inner loop, constraint inference becomes much easier to implement and tune. It also means the sub-field of constraint inference can now directly borrow from the massive body of existing literature on standard IRL.
  • Soft penalties beat hard constraints: In practice, forcing a neural network to output strictly positive constraint values via hard clipping ruins the gradient flow. Softly encouraging positivity via L2 regularization is the secret sauce that makes standard IRL competitive for this task.

Experimental Results

The authors evaluated their method on five continuous-control MuJoCo environments (Ant, Half Cheetah, Walker 2D, Swimmer, Inverted Pendulum), modified to include specific safety constraints.

Superior Performance

Aggregated across the five MuJoCo environments, the simplified IRL-Plus method outperformed the canonical ICRL baseline (MECL) with statistical significance. It achieved higher feasible rewards (rewards earned before a safety violation occurs) and a lower violation rate. Among the proposed modifications, swapping hard-clipping for L2 regularization provided the single largest performance boost.

Aggregate performance showing IRL-Plus outperforming baselines on feasible rewards

Robustness to Sub-optimal Data

The authors also evaluated the method on sub-optimal datasets for the Half Cheetah environment, where 20%, 50%, or 80% of the expert trajectories actually contained safety violations. IRL-Plus remained highly competitive with the complex MECL baseline and vastly outperformed prior basic IRL baselines, which failed to achieve any feasible rewards.

Performance on sub-optimal datasets with 20%, 50%, and 80% unsafe trajectories

Limitations and Future Work

While highly effective, the IRL approach still exhibits substantial variance across different random seeds on a per-environment basis and struggles to cleanly beat baselines in the notoriously challenging Inverted Pendulum environment.

Because the authors successfully reduced constraint inference to standard IRL, they suggest that future work should apply offline IRL techniques to this problem. This would allow researchers to infer safety constraints entirely from static, real-world datasets without ever needing the agent to interact with (and potentially break) the real environment during training.

Summary updated

BibTeX
@inproceedings{hugessen2024simplifying,
  author = {Adriana Hugessen and Harley Wiltzer and Glen Berseth},
  title = {{Simplifying Constraint Inference with Inverse Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=T5Cerv7PT2},
}
Figure