Abstract
Generalized Planning (GP) aims to discover single algorithmic solutions, such as programs with loops and branches, capable of solving entire classes of planning problems regardless of instance size or specific object configurations. While heuristic search is the standard for classical planning, its application to GP has been historically limited by the complexity of reasoning over infinite domains and program structures. This paper introduces the BFGP algorithm, a native heuristic search approach that leverages a Random-Access Machine (RAM) model to navigate the massive search space of potential programs. By combining structural and performance-based heuristics, the approach successfully generates generalized solutions for complex tasks, including nested-loop algorithms like sorting.
Introduction: The Challenge of Generalized Planning
In classical AI planning, the objective is typically to find a sequence of actions that transitions a system from a specific initial state to a specific goal state. However, these solutions are often brittle; a plan to move three blocks does not necessarily apply to a problem with four. Generalized Planning (GP) seeks a more robust solution: a single "program" that works for any instance of a problem domain.
As shown in Figure 2, a GP solution must account for varying instance sizes (e.g., $P_1$ with six elements and $P_2$ with five) and different initial configurations. Traditional methods for solving GP often involve translating the problem into complex logic constraints or classical planning tasks. This research proposes a more direct route: treating the program construction itself as a heuristic search problem.
Methodology: RAM-Based Abstraction and the BFGP Algorithm
To make the search space tractable and size-invariant, the authors extend the planning model with a Random-Access Machine (RAM). This model utilizes "pointers" (indices to state variables) and "FLAGS" (Boolean indicators for zero or carry results). By referring to "the element at pointer $z_1$" rather than a specific object, the resulting programs become independent of the number of objects in any given instance.
The BFGP (Best-First Generalized Planning) algorithm builds these programs line by line. A candidate program consists of standard planning actions, GOTO instructions for loops and branching (conditioned on RAM FLAGS), and a termination end instruction. To optimize the search, the algorithm employs PC-Max Successor Generation, which only attempts to program the maximum program line reached during the execution of the current candidate, preventing the exploration of unreachable code paths.
Heuristic Guidance
The search is guided by two distinct types of heuristics:
- Structural Heuristics: These evaluate the program's form, such as $f_1$, which counts the number of
GOTOinstructions or undefined lines to encourage simpler code structures. - Performance Heuristics: These execute the candidate program on sample instances to measure progress. A critical innovation is $h_5$, which calculates the squared Euclidean distance between current state variables and the goal state.
The authors found a powerful synergy between these types: performance heuristics ensure the program is functional, while structural heuristics help break ties and guide the search toward more generalizable "shapes" of code.
Empirical Results and Heuristic Performance
The BFGP algorithm was evaluated across eight diverse domains, ranging from simple navigation (Corridor) to complex algorithmic tasks like reversing lists and computing Fibonacci sequences.
As detailed in Figure 3, the choice of heuristic significantly impacts performance. While some configurations resulted in timeouts (TO), the combination of goal-distance metrics ($h_5$) and structural simplicity ($f_1$) proved highly robust. Notably, the algorithm successfully solved the Sorting domain—a historically difficult task for automated planners due to the requirement for nested loops. Furthermore, programs discovered using small training instances (5-6 elements) were validated on much larger instances (up to 20 elements) with 100% accuracy, confirming the effectiveness of the pointer-based abstraction.
Conclusion and Future Work
This work demonstrates that native heuristic search is a viable and powerful approach for Generalized Planning. By representing plans as RAM-based programs, the BFGP algorithm can discover algorithmic solutions that generalize across problem sizes. Future research will focus on improving infinite loop detection—a computationally expensive necessity in program search—and refining heuristics to handle even more complex, non-numerical goal conditions.
Summary updated