Code Building Genetic Programming

Edward R. Pantridge, Lee Spector

Abstract

Code Building Genetic Programming (CBGP) is a novel framework that evolves programs as type-safe directed acyclic graphs (DAGs) rather than linear instruction sequences. By leveraging host-language reflection and a process called "expression reification," CBGP automatically synthesizes human-readable code that utilizes complex, polymorphic data types and existing software libraries with minimal manual configuration. This approach bridges the gap between traditional genetic programming and real-world software development.

Introduction

Traditional Genetic Programming (GP) systems, such as PushGP or Grammar-Guided GP (G3P), often struggle with "real-world" software engineering tasks. These systems typically operate on a narrow set of primitive data types and require researchers to manually define every available instruction. They lack native support for object-oriented features like inheritance and polymorphism. CBGP addresses these limitations by automating library integration and handling the complexity of modern type systems through automated expression creation.

Methodology

CBGP introduces several mechanisms to enhance software awareness in GP:

  1. Program DAGs: Programs are represented as Directed Acyclic Graphs where nodes are expressions (functions, methods, or constants).
  2. Expression Reification: This process refines function specifications based on inputs. For instance, a generic Take function receiving a List[String] is updated to return a List[String], ensuring type safety across polymorphic operations.
  3. Automated Reflection: CBGP uses Python’s type hints to automatically discover available functions and types, allowing it to "inject" itself into existing codebases.
  4. Push-style Compilation: A linear genome (Plushy representation) is compiled into these type-safe DAGs.
Figure 1: Examples of Program DAGs in CBGP, illustrating type-safe connections and anonymous functions.

Experimental Evaluation

The authors evaluated CBGP on two benchmark sets:

  • Novel Benchmarks: Tasks requiring high-level features like DateTime handling (Days Between), higher-order functions (Filter Bounds), and filesystem interaction (Prefix Paths).
  • Standard Benchmarks: Seven problems from the General Program Synthesis Benchmark Suite to compare against PushGP and G3P.

Results and Discussion

CBGP achieved near-perfect success rates on the novel benchmarks (100% on Days Between and Filter Bounds). In standard benchmarks, it significantly outperformed PushGP on vector and math-heavy problems by leveraging built-in Python functions like sum() and len().

Figure 6: Comparison of solution rates between CBGP, PushGP, and G3P across various standard benchmarks.

The enforcement of strict type safety during compilation effectively prunes the search space, preventing the evolution of logically unsound structures. Furthermore, the resulting DAGs are easily translatable into standard, human-readable Python code, making the "black box" of GP more transparent to developers.

Conclusion

While CBGP excels at library-heavy tasks, it faces challenges with search space explosion when importing massive libraries and occasional code bloat. Future work aims to integrate richer specifications and canonicalization techniques to further refine the synthesized output.

Summary updated

BibTeX
@inproceedings{pantridge2020code,
  author = {Edward R. Pantridge and Lee Spector},
  title = {{Code Building Genetic Programming}},
  booktitle = {GECCO},
  year = {2020},
  doi = {10.1145/3377930.3390239},
}
Figure