COptiDICE: Offline Constrained Reinforcement Learning via Stationary Distribution Correction Estimation

Jongmin Lee, Cosmin Paduraru, Daniel J Mankowitz, Nicolas Heess, Doina Precup, Kee-Eung Kim, Arthur Guez

In the quest to move Reinforcement Learning (RL) from simulation to the real world, we face two massive hurdles: we often cannot afford to let agents learn through trial-and-error in the actual environment (as it is too slow or dangerous), and we must ensure they obey strict safety constraints (like not crashing a car or breaking a robotic arm).

COptiDICE, an algorithm presented at ICLR 2022, offers a clever mathematical framework to tackle both problems simultaneously. It provides an offline constrained RL approach that learns optimal, safety-compliant policies from fixed datasets without any environment interaction.

The Challenge of Offline Constrained RL

Standard RL is "online"—the agent learns by doing. Offline RL (or Batch RL) changes the paradigm by forcing the agent to learn solely from a pre-collected dataset. However, offline RL suffers from "distribution shift": the agent might incorrectly assume an action is highly rewarding simply because it hasn't seen the negative consequences in the limited data.

When you add constraints (e.g., "maximize speed but never exceed a temperature of 80°C"), the problem becomes significantly harder. In an offline setting, we have to estimate the cost of a new policy using only old data. If our estimate is even slightly too optimistic, we might deploy a policy that looks safe on paper but violates constraints in reality. Furthermore, traditional constrained RL algorithms are notoriously unstable because they have to simultaneously balance three different optimization loops: the actor, the critic, and the safety (Lagrange) multiplier.

The COptiDICE Approach

The authors introduce COptiDICE (Constrained Policy Optimization via stationary DIstribution Correction Estimation) to bypass these instabilities. Here is how it works:

  1. Stationary Distribution Correction ($w$): Instead of trying to learn a complex $Q$-function to estimate future rewards, COptiDICE directly estimates the ratio between how often the optimal policy would visit a state-action pair versus how often it appears in the dataset. This ratio is the stationary distribution correction.
  2. Single Objective Optimization: By formulating the problem in the space of stationary distributions, the authors collapse the unstable "triple" optimization (actor-critic-Lagrange) into a single, mathematically well-behaved convex minimization problem.
  3. Cost-Conservativeness: To handle estimation errors, COptiDICE does not just try to meet the cost constraint; it tries to satisfy an upper bound of the cost. It looks for the "worst-case" scenario within a small neighborhood of the data (using KL-divergence) and ensures the policy is safe even under those pessimistic assumptions.
  4. Policy Extraction: Once the optimal distribution $w$ is found, the final policy is extracted using importance-weighted behavioral cloning, making it applicable to continuous control tasks.

Key Results and Insights

The researchers evaluated COptiDICE on Tabular CMDPs (to verify mathematical properties) and the Real-World RL (RWRL) Suite (to test continuous control tasks like Cartpole and Walker). They tested various dataset compositions, including "mostly safe" and "mostly unsafe" data.

Performance of COptiDICE vs. baselines in cost-satisfying and cost-violating scenarios.
  • Superior Safety and Robustness: As shown in the experimental results above, COptiDICE successfully navigates both cost-satisfying and cost-violating data-collection scenarios. In tabular experiments where the data-collection policy was unsafe, COptiDICE was often the only algorithm capable of finding a policy that actually satisfied the cost constraints (staying below the cost threshold $\hat{c}$).
  • Performance vs. Safety: On the RWRL suite, COptiDICE consistently outperformed baselines like Behavior Cloning (BC) and constrained versions of CRR. It achieved higher rewards while maintaining a much lower rate of constraint violation.
  • Pessimism is a Virtue: In offline RL, we are usually pessimistic about rewards. COptiDICE demonstrates that we must also be pessimistic about costs to ensure real-world safety.
  • Efficiency: By reusing the distribution correction $w$ to estimate the cost upper bound, COptiDICE is much more computationally efficient than previous "robust" evaluation methods that required nested optimization loops.

Limitations and Future Work

While powerful, COptiDICE has a few limitations. The practical implementation uses a "log-sum-exp" trick for mini-batches, introducing a small mathematical bias traded for computational efficiency. Additionally, the algorithm introduces a hyperparameter ($\epsilon$) that controls how conservative the cost estimation is; choosing the right $\epsilon$ is crucial to avoid overly timid policies. Finally, like all offline RL, COptiDICE assumes the dataset has at least some coverage of the state-action space—if the data is extremely narrow, no algorithm can safely generalize.

Summary updated

BibTeX
@inproceedings{lee2022coptidice,
  author = {Jongmin Lee and Cosmin Paduraru and Daniel J Mankowitz and Nicolas Heess and Doina Precup and Kee-Eung Kim and Arthur Guez},
  title = {{COptiDICE: Offline Constrained Reinforcement Learning via Stationary Distribution Correction Estimation}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=FLA55mBee6Q},
}
Figure