State Regularized Policy Optimization on Data with Dynamics Shift

Zhenghai Xue, Qingpeng Cai, Shuchang Liu, Dong Zheng, Peng Jiang, Kun Gai, Bo An

Introduction

Reinforcement Learning (RL) agents often struggle when the underlying physics or rules of their environment change—a problem known as dynamics shift. This paper introduces State Regularized Policy Optimization (SRPO), which leverages a simple but powerful observation: while the optimal actions change across different environments, the optimal states usually remain the same. By regularizing policies to match an estimated "optimal state distribution," SRPO allows agents to efficiently reuse data across varying environments, significantly boosting performance in both online and offline RL.

The Challenge of Dynamics Shift

In real-world RL applications, environments are rarely static. A robot arm might pick up objects of varying weights, or a recommendation engine might face shifting user preferences. When RL algorithms are trained on data collected from these varying environments, they often get confused and perform poorly.

Current solutions typically train "context encoders" to identify the current environment's parameters and condition the policy on them. However, these methods are highly sample-inefficient because they essentially silo the data: a policy tailored for Environment A learns very little from data collected in Environment B. Other approaches use Importance Sampling (IS) to reweight data, but IS suffers from notorious variance issues and requires prior knowledge of the target environment. Finally, standard offline RL techniques like behavior regularization (forcing the agent to mimic the actions in the dataset) fail completely here, because the optimal action in one environment might be disastrous in another.

Methods: Regularizing States, Not Actions

The authors propose a paradigm shift: instead of regularizing behaviors (actions), we should regularize states.

Think of an inverted pendulum. If you increase gravity, the force (action) required to keep it upright changes drastically. However, the optimal state (standing perfectly upright) is identical regardless of gravity.

State vs. Action Density under Dynamics Shift

To exploit this, the authors introduce SRPO:

  1. State Regularization: They formulate a Constrained Policy Optimization (CPO) problem that forces the learning policy's stationary state distribution to be close to the optimal state distribution of the mixed-dynamics data.
  2. Reward Augmentation: Solving this constraint mathematically translates to adding a density ratio to the standard RL reward function. The agent gets a bonus for visiting states that are highly represented in the optimal distribution.
  3. Sample-Based Surrogate: Since we don't explicitly know the "optimal state distribution" (especially in offline datasets), the authors use a clever GAN-inspired trick. They train a discriminator to distinguish between "high-value" states (a proxy for optimal) and average states. The output of this discriminator serves as a surrogate for the density ratio.

SRPO is designed as a lightweight add-on module that can be plugged into existing context-based RL algorithms (like CaDM for online RL and MAPLE for offline RL).

Key Insights: Homomorphous MDPs

  • Actions are fragile, states are robust: The core insight is recognizing that in environments with similar structures but different dynamics, optimal policies induce similar stationary state distributions. This allows data from all environments to be pooled to learn what a "good state" looks like, drastically improving sample efficiency.
  • Homomorphous MDPs: The authors formalize this intuition by defining "homomorphous MDPs"—environments where the same states are reachable, even if the transition probabilities differ. They mathematically prove that if an agent matches the optimal state distribution of one homomorphous MDP, its performance is lower-bounded in all others.
  • State vs. Behavior Regularization: Ablation studies clearly show that regularizing based on state-action pairs (behavior) causes a massive performance drop under dynamics shift, proving that decoupling the state from the action is the secret to generalizing across physics changes.

Experimental Results

The authors evaluated SRPO on standard continuous control benchmarks, modifying them to introduce dynamics shifts. For online RL, they used MuJoCo simulator environments where gravity is dynamically altered. For offline RL, they used D4RL datasets, altering the medium density and body mass of the simulated robots.

Performance in Ant Environment across varying numbers of dynamics
  • Online RL: When plugged into the CaDM baseline, CaDM+SRPO achieved the best overall performance. Notably, while standard CaDM's performance dropped when the number of different dynamics increased from 3 to 5 (due to data fragmentation), CaDM+SRPO's performance improved, proving it successfully reuses data across shifts.
  • Offline RL: MAPLE+SRPO achieved the best performance in 8 out of 12 D4RL tasks. It achieved an average normalized score of 0.61, representing a solid 15% improvement over the base MAPLE algorithm (0.53) and nearly double the performance of standard CQL (0.33).
  • Discriminator Accuracy: The GAN-style discriminator successfully learned to assign higher outputs to high-value states without needing explicit distribution modeling, validating the surrogate approach.

Limitations and Future Work

The theoretical guarantees of SRPO rely heavily on the assumption that the environments are "homomorphous" (i.e., they share the same state reachability). If a dynamics shift introduces a completely new obstacle that makes previously optimal states unreachable, the theory (and likely the algorithm) may struggle. Future work could explore whether similar theoretical guarantees about stationary state distributions can be derived without relying on the strict homomorphous MDP assumption, potentially broadening the algorithm's applicability to even more extreme environment shifts.

Summary updated

BibTeX
@inproceedings{xue2023state,
  author = {Zhenghai Xue and Qingpeng Cai and Shuchang Liu and Dong Zheng and Peng Jiang and Kun Gai and Bo An},
  title = {{State Regularized Policy Optimization on Data with Dynamics Shift}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=I8t9RKDnz2},
}
Figure