Abstract
Standard meta-reinforcement learning (Meta-RL) algorithms typically assume environmental dynamics remain stationary within a single episode. This assumption fails in real-world applications where sudden shifts—such as mechanical failures or weather changes—can occur. We introduce Environment Sensitive Contextual Policy (ESCP), an approach that enables agents to adapt to sudden environmental changes up to 10x faster than prior state-of-the-art methods. ESCP achieves this through a context encoder that prioritizes recent history through a truncated window and stabilizes latent representations via variance minimization and relational matrix determinant maximization. Evaluations on Grid-World and MuJoCo locomotion tasks demonstrate superior performance and robustness to out-of-distribution disturbances.
Introduction
In standard Reinforcement Learning (RL), the assumption of "intra-episode stationarity" implies that the laws of physics, such as gravity or friction, remain constant throughout a task. In reality, robots and autonomous systems frequently encounter sudden disturbances: a drone hitting a gust of wind or a vehicle transitioning onto a slippery surface. While context-based Meta-RL was designed to handle varying environments, existing methods often suffer from "adaptation lag." Their reliance on long-term history clutters memory with outdated data, leading to performance crashes when the environment shifts abruptly.
Methods: The ESCP Framework
ESCP follows the context-based Meta-RL paradigm, decoupling a context encoder from a contextual policy. To overcome the lag inherent in traditional methods, ESCP introduces three key innovations:
- Variance Minimization: The context encoder is optimized to produce stable encodings rapidly, forcing the model to settle on a reliable environment description quickly.
- Relational Matrix Determinant Maximization: To ensure the latent space is informative, ESCP uses techniques from Determinantal Point Processes to make latent encodings of different environments as diverse and separable as possible.
- History-Truncated RNN: Unlike standard models that process an entire episode's history, ESCP's context encoder only considers the most recent $H$ steps. This "forgetting" mechanism prevents interference from old environmental dynamics, allowing the agent to pivot immediately when conditions change.
The underlying policy is trained using Soft Actor-Critic (SAC), augmented with these rapidly updating context vectors to ensure high-performance control under shifting conditions.
Experimental Evaluation
The researchers evaluated ESCP against several baselines, including PEARL, OSI, and SAC-RNN, across two primary benchmarks:
- Grid-World: An 11x11 grid with unobservable "wind" that changes every 100 steps.
- MuJoCo Locomotion: Standard robotic tasks (e.g., Hopper, HalfCheetah, Walker2d, Ant, Humanoid) modified with sudden mid-episode changes to gravity or joint damping.
Key Results
ESCP demonstrated a significant advantage in adaptation speed. In the Grid-World task, ESCP reduced its "action difference" (the error relative to an optimal policy) to near zero within just 10 steps of an environmental change. In contrast, baselines like PEARL or OSI required over 100 steps to recover.
In the HalfCheetah task with changing gravity, ESCP achieved a final average return of 7237, outperforming SAC-RNN (5997) and nearly doubling the performance of PEARL (4605). Furthermore, ESCP proved robust to out-of-distribution (OOD) scenarios, maintaining high performance even when gravity changes exceeded those seen during training.
Conclusion
ESCP addresses a critical gap in Meta-RL by prioritizing rapid context identification. By intentionally truncating history and structuring the latent space for diversity, the model effectively "forgets" irrelevant past dynamics to focus on the present. While currently tested on low-dimensional contexts like gravity and friction, future work will explore scaling ESCP to high-dimensional sensory inputs and automatically tuning the optimal memory window $H$ for diverse tasks.
Summary updated