Policy Optimization Algorithms in a Unified Framework

Shuang Wu · DOI

Abstract

Policy optimization algorithms are crucial in many fields but challenging to grasp and implement, often due to complex calculations related to Markov decision processes and varying use of discount and average reward setups. This paper presents a unified framework that applies generalized ergodicity theory and perturbation analysis to clarify and enhance the application of these algorithms. Generalized ergodicity theory sheds light on the steady-state behavior of stochastic processes, aiding understanding of both discounted and average rewards. Perturbation analysis provides in-depth insights into the fundamental principles of policy optimization algorithms. We use this framework to identify common implementation errors and demonstrate the correct approaches. Through a case study on Linear Quadratic Regulator problems, we illustrate how slight variations in algorithm design affect implementation outcomes. We aim to make policy optimization algorithms more accessible and reduce their misuse in practice.

Introduction

Policy optimization (PO) is a cornerstone of modern reinforcement learning (RL), powering advancements from game-playing AI to complex robotic control. However, these algorithms are notoriously difficult to implement correctly. The primary challenge lies in the mathematical treatment of the discount factor ($\gamma$). While RL objectives are theoretically defined over time (trajectories), practical implementations often calculate gradients over space (state-action distributions).

This mismatch frequently leads to "bias bugs" where practitioners inadvertently use the steady-state distribution of a process to calculate gradients for a discounted objective. This creates a hybrid gradient that does not accurately represent the objective function, resulting in biased updates and suboptimal performance. This paper introduces a unified theoretical framework to bridge this gap.

A Unified Theoretical Framework

The framework is built upon two primary mathematical pillars: Generalized Ergodicity Theory and Perturbation Analysis.

Traditionally, ergodicity relates time averages to space averages in long-run scenarios. By extending this to include discounted rewards, we create a unified "averaging measure" ($\nu_\bullet^\pi$). This allows any time-based Markov Decision Process (MDP) formulation to be converted into a single, simplified space-based equation. Perturbation analysis is then used to analyze how small changes in a policy affect overall performance, unifying the derivations of Policy Iteration, Policy Gradient, Natural Policy Gradient, TRPO, and PPO.

The unified roadmap for policy optimization, bridging time-based formulations with space-based approximations like PPO and TRPO.

By using a placeholder ($\bullet$) for the reward setup, the framework allows a single derivation to apply to discounted, total, and average reward scenarios simultaneously. This simplifies the vast "zoo" of RL algorithms into a single, coherent family.

Key Insights and the "Bias Bug"

A significant contribution of this framework is the explicit identification of common implementation errors. Many "standard" RL implementations are technically incorrect because they neglect the discount factor when aggregating samples along a path. They essentially calculate a gradient for one objective but apply it to another.

Furthermore, the framework provides new perspectives on popular algorithms:

  • PPO for Deterministic Policies: While PPO-Clip is standard for stochastic policies, this framework enables a version suitable for deterministic policies, where the policy ratio ($\pi'/\pi$) is typically undefined.
  • PPO vs. TRPO: The analysis suggests PPO-Clip may be more effective than TRPO because it optimizes the approximated performance difference more directly within a local region, whereas TRPO’s quadratic approximations can sometimes reduce update effectiveness.

Key Results and Practical Reference

To validate the theory, the paper employs a Linear Quadratic Regulator (LQR) problem. This fundamental model in optimal control allows for exact calculations, making it an ideal laboratory to compare correct versus incorrect implementations. In these tests, "incorrect" implementations (those ignoring the discount factor in the distribution) converged significantly slower. In average reward setups, incorrect implementations failed to converge entirely, while framework-derived algorithms succeeded.

Mathematical expressions for stochastic and deterministic policy gradients and curvatures across discounted and average reward settings.

The tables provided in the research serve as a vital reference for the correct mathematical expressions for gradients and curvatures in both space and time domains, ensuring practitioners can avoid common pitfalls.

Conclusion

This unified framework demystifies the complexities of policy optimization by providing a rigorous roadmap for derivation and implementation. While currently demonstrated on linear systems like LQR, the underlying theory holds for non-linear systems. Future work will focus on benchmarking these "correct-by-design" algorithms in complex deep RL environments and specialized engineering applications like chemical process control.

Summary updated

BibTeX
@misc{wu2025policy,
  author = {Shuang Wu},
  title = {{Policy Optimization Algorithms in a Unified Framework}},
  year = {2025},
  eprint = {2504.03328},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.03328},
}
Figure