Computing Plans with Control Flow and Procedures Using a Classical Planner

Sergio Jiménez Celorrio, Anders Jonsson

Abstract

This paper presents a novel compilation technique that enables classical planners to synthesize generalized plans represented as computer programs. By incorporating control flow structures like goto statements and procedures, the approach allows off-the-shelf planners to discover compact, reusable strategies that solve multiple problem instances simultaneously. Experimental results across various domains demonstrate that this method achieves high generalization and compression compared to standard linear planning.

Introduction

In classical AI planning, a "plan" is typically a linear sequence of actions designed to reach a goal from a specific starting state. While effective for isolated tasks, these plans are inherently brittle; minor changes to the environment or problem scale often render the sequence invalid. The challenge of Generalized Planning is to create a single strategy that works across any instance of a domain—for example, a strategy to move all objects regardless of their initial count.

While humans use structured programming (loops, conditionals, and subroutines) to solve such general problems, classical planners traditionally struggle to represent or discover these structures. This research bridges the gap between automatic program synthesis and classical planning by treating the programming process itself as a planning problem.

Methodology

The authors propose a compilation that translates a programming task into a standard planning language (PDDL) compatible with existing planners. The core of this approach involves defining a fixed number of "program lines" which the planner must populate with instructions.

Instruction Semantics and Control Flow

To enable complex logic, the compilation includes standard domain actions alongside control flow instructions. As shown in Figure 1, instructions like inc and add modify state variables, while goto instructions allow the planner to jump between program lines based on specific conditions.

Instruction definitions for the planning compilation, including state-modifying actions and conditional control flow.

The "Program vs. Repeat" Mechanism

To incentivize the creation of reusable programs rather than long linear sequences, the authors introduce a cost-based mechanism:

  1. Programming actions: Assigning an instruction to an empty line is assigned a high cost.
  2. Repeat actions: Executing an instruction that has already been programmed on a line is assigned a low cost.

This cost structure forces the planner to prefer loops and procedures over creating new lines of code. Furthermore, to ensure generalization, the planner must execute the generated program against multiple "unit tests" (different initial states and goals) within a single planning episode. If a program fails any test, the planner must backtrack and revise the code.

Experimental Evaluation and Results

The system was evaluated using a variety of domains, including mathematical logic (Summatory), list manipulation (Find, Reverse), and classical planning adaptations (Gripper, Unstack). The authors utilized the off-the-shelf Fast Downward (LAMA-2011) planner to solve the compiled problems.

Performance and Generalization

The results indicate significant improvements in both compression and generalization. In the Diagonal domain, the planner consistently discovered a 3-line program that solved instances of any size, whereas standard linear plans grew proportionally with the grid dimensions.

IPC Quality Scores across various domains, comparing the baseline linear planning against different configurations of program lines and procedures.

As seen in Figure 3, the system achieved high quality scores across complex, repetitive tasks. It successfully generated programs that passed up to 10 different unit tests simultaneously. For instance, in the Gripper domain, it synthesized a general strategy that functioned correctly regardless of the number of objects to be moved.

Conclusion and Future Work

This research demonstrates that classical planners can be effectively repurposed as program synthesizers. By framing code generation as a cost-driven planning task, the authors enable the discovery of generalized solutions that are far more robust than linear action sequences.

Current limitations include a search space that expands rapidly with the number of allowed program lines and the lack of support for nested procedure calls. Future work may explore the use of Functional STRIPS to better handle numerical reasoning and complex data structures, potentially further reducing the manual tuning required for program parameters.

Summary updated

BibTeX
@inproceedings{celorrio2015computing,
  author = {Sergio Jiménez Celorrio and Anders Jonsson},
  title = {{Computing Plans with Control Flow and Procedures Using a Classical Planner}},
  booktitle = {SOCS},
  year = {2015},
  doi = {10.1609/socs.v6i1.18360},
}
Figure