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:
- Program DAGs: Programs are represented as Directed Acyclic Graphs where nodes are expressions (functions, methods, or constants).
- Expression Reification: This process refines function specifications based on inputs. For instance, a generic
Takefunction receiving aList[String]is updated to return aList[String], ensuring type safety across polymorphic operations. - Automated Reflection: CBGP uses Python’s type hints to automatically discover available functions and types, allowing it to "inject" itself into existing codebases.
- Push-style Compilation: A linear genome (Plushy representation) is compiled into these type-safe DAGs.
Experimental Evaluation
The authors evaluated CBGP on two benchmark sets:
- Novel Benchmarks: Tasks requiring high-level features like
DateTimehandling (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().
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