Abstract
Deep reinforcement learning (deep RL) excels in various domains but lacks generalizability and interpretability. Programmatic RL methods reformulate RL tasks as synthesizing interpretable programs, yet they are often limited to short-horizon tasks. Conversely, state machine policies can generalize to long-horizon tasks but struggle to acquire diverse behaviors. This work proposes the Program Machine Policy (POMP), bridging programmatic RL and state machine policies. We introduce a method to retrieve a set of effective, diverse, and compatible programs as modes of a state machine and learn a transition function among them. POMP outperforms deep RL and programmatic RL baselines on long-horizon tasks and demonstrates inductive generalization to even longer horizons without fine-tuning.
Introduction
Deep Reinforcement Learning (DRL) has achieved mastery in complex domains but faces significant challenges in interpretability and long-horizon scalability. DRL policies are often "black boxes," making them difficult to trust in safety-critical applications. Furthermore, they struggle with tasks requiring thousands of steps or repetitive sub-routines.
Programmatic RL offers a solution by synthesizing policies as human-readable code. However, synthesizing a single large program for long-horizon tasks is computationally prohibitive. While state machine policies excel at handling repetition, they typically rely on simplistic, hard-coded actions. Program Machine Policy (POMP) addresses these limitations by using synthesized programs as modular "modes" within a state machine framework.
Methodology
The POMP framework consists of three primary stages: constructing a program embedding space, retrieving mode programs, and learning a transition function.
Domain-Specific Language (DSL)
The programs are synthesized based on a specific grammar. In the Karel domain, this includes perceptions (e.g., frontIsClear), actions (e.g., move, turnLeft), and control flow statements (e.g., while, repeat, if-else). This structured approach ensures that the resulting skills are human-readable and modular.
The POMP Framework
- Program Embedding Space: A Variational Autoencoder (VAE) maps discrete programs into a continuous latent space, enabling efficient search via optimization rather than brute-force code generation.
- Mode Program Retrieval: An advanced Cross-Entropy Method (CEM) is used to find a library of sub-routines. To ensure a robust set of skills, the authors introduce Diversity and Compatibility multipliers. Diversity ensures the programs represent distinct behaviors, while compatibility ensures they can effectively hand off the environment state to one another.
- Transition Function Learning: A high-level RL agent (trained via PPO) acts as a controller, observing the environment and deciding which mode program to execute next or when to terminate the episode.
Experiments and Results
The researchers evaluated POMP on the Karel domain, including a new KAREL-LONG benchmark designed for tasks requiring up to 3,000+ steps (e.g., INF-HARVESTER, FARMER).
Performance and Generalization
POMP significantly outperformed standard DRL and existing programmatic baselines like LEAPS and HPRL. A key strength is inductive generalization: because the policy is a state machine that can loop between programs, it can solve tasks 16x larger than those seen during training (up to 48,000 steps) with zero-shot success. While other methods' success rates plummeted as the horizon extended, POMP maintained high performance.
Sample Efficiency and Interpretability
POMP reached peak performance with orders of magnitude fewer environment interactions than hierarchical neural network baselines. Furthermore, the resulting policy is highly interpretable; the authors demonstrated that a symbolic state machine can be extracted from the trained controller, providing a transparent map of the agent's decision-making logic.
Conclusion
POMP successfully bridges the gap between programmatic RL and state machines, offering a scalable and interpretable approach to long-horizon tasks. While currently dependent on a pre-defined DSL and the quality of the VAE embedding, the framework demonstrates the power of combining modular code with high-level control logic. Future work aims to extend this to non-grid-world environments and explore automatic DSL evolution.
Summary updated