Abstract: In the absence of assigned tasks, a learning agent typically seeks to explore its environment efficiently. However, the pursuit of exploration will bring more safety risks. An under-explored aspect of reinforcement learning is how to achieve safe efficient exploration when the task is unknown. In this paper, we propose a practical Constrained Entropy Maximization (CEM) algorithm to solve task-agnostic safe exploration problems, which naturally require a finite horizon and undiscounted constraints on safety costs. The CEM algorithm aims to learn a policy that maximizes state entropy under the premise of safety. To avoid approximating the state density in complex domains, CEM leverages a k-nearest neighbor entropy estimator to evaluate the efficiency of exploration. In terms of safety, CEM minimizes the safety costs, and adaptively trades off safety and exploration based on the current constraint satisfaction. The empirical analysis shows that CEM enables the acquisition of a safe exploration policy in complex environments, resulting in improved performance in both safety and sample efficiency for target tasks.
Introduction
In the world of Reinforcement Learning (RL), agents usually learn by trial and error. To find the best path, they have to explore, but in the real world, "error" can mean a broken robot or a crashed car. Most current exploration methods either ignore safety or require a specific task (and reward signal) to balance against the risks.
A new paper from researchers at Delft University of Technology, presented at AAAI-23, introduces CEM (Constrained Entropy Maximization). This algorithm allows agents to explore complex environments as thoroughly as possible while strictly adhering to safety limits—all without knowing what their ultimate task will be.
The Problem: Exploration vs. Safety
Reinforcement learning faces a fundamental tension between the need to visit new states and the need to avoid hazardous ones. This paper addresses three critical gaps in current research:
- The Exploration Gap: To be useful, an agent should explore its environment before it even has a specific task (task-agnostic exploration). This creates a "prior" knowledge base.
- The Safety Gap: Most safe RL methods rely on a reward signal to weigh against safety costs. Without a task, it is difficult to define how much risk is acceptable.
- The Discounting Problem: Standard RL math uses "discounted" costs to keep calculations stable. However, real-world safety—like a battery's capacity—is usually "undiscounted" and finite. Ignoring future costs can lead to catastrophic system failure.
Methodology
The authors propose Constrained Entropy Maximization (CEM), built on several technical pillars:
- State Entropy as the Objective: Instead of using heuristic "curiosity" bonuses, CEM explicitly tries to maximize the entropy of the state distribution, encouraging the agent to visit the environment as uniformly as possible.
- k-Nearest Neighbor (k-NN) Estimator: Estimating state density in high-dimensional spaces is difficult. CEM uses a k-NN entropy estimator, which judges how "new" an area is based on the distance between sampled states.
- The Lagrangian Trade-off: The algorithm uses a dynamic safety weight (Lagrangian multiplier $\omega$). If safety limits are violated, $\omega$ increases, forcing the agent to prioritize safety over exploration.
- The Mathematical Bridge: The authors prove that policy gradients can be calculated using discounted costs for numerical stability, while the safety weight is updated based on undiscounted real-world costs. This ensures physical limits are respected while keeping neural network training efficient.
Experimental Setup
The researchers evaluated CEM across five environments with varying complexity, ranging from simple 2D navigation to high-dimensional continuous control.
- BasicNav: A 2D navigation task with a central hazard.
- Modified Classic Control: MountainCar and CartPole, modified to include "danger zones" (e.g., excessive tilt or position limits).
- Safety Gym: High-dimensional tasks including PointGoal (36D) and CarButton (56D), where a robot navigates around vases, hazards, and moving obstacles.
Key Results and Insights
CEM was compared against MEPOL (a state-of-the-art exploration learner that ignores safety) and several SAC (Soft Actor-Critic) variants.
- Superior Exploration: In complex environments like PointGoal, CEM achieved significantly higher state entropy than safe baselines, which were often too conservative to move far from the starting point.
- Constraint Satisfaction: While MEPOL explored extensively, it frequently violated safety thresholds. CEM was the only algorithm that consistently maximized exploration while staying under the allowed safety cost "red line."
- Transfer Learning Success: When agents were assigned specific tasks, those "guided" by a CEM-pre-trained policy learned faster and with far fewer safety violations than agents starting from scratch or those guided by unsafe teachers.
Conclusion
CEM demonstrates that safety and exploration are not mutually exclusive, even in the absence of a specific task. By treating safety as a formal constraint rather than a negative reward, CEM enables agents to learn a "safe guide" policy. This policy acts as a boundary for future learning, ensuring that as robots become more capable, they also remain safe.
Future work may extend this to pixel-based environments or explore maximizing mutual information between tasks and states to make exploration even more purposeful.
Summary updated