Genetic Programming and Program Synthesis
Evolving Programs
What Is Genetic Programming?
Genetic programming evolves programs or symbolic expressions rather than fixed-length parameter vectors. Solutions are often represented as trees whose internal nodes are functions and whose leaves are variables or constants.
Tree Representation
A program tree can represent arithmetic expressions, logic rules, control flow fragments, or other compositional structures. Tree-based crossover and mutation allow programs to grow or change shape.
Genetic Programming Pseudocode
-
1
Step 1: Generate random program trees.
-
2
Step 2: Evaluate each tree on training cases.
-
3
Step 3: Select parent trees based on fitness.
-
4
Step 4: Apply subtree crossover and mutation.
-
5
Step 5: Optionally limit tree size or depth.
-
6
Step 6: Repeat until a stopping condition is met.
Program Evolution Operators
Subtree crossover
- Swaps whole branches between trees
- Can create large structural changes
- May produce invalid programs if not controlled
Subtree mutation
- Replaces a branch with a new randomly generated subtree
- Introduces novel code fragments
- Supports exploration
In genetic programming, what is often used to represent a candidate program?
Trees are the standard representation for many GP systems.
Correct answer: A tree
What is subtree crossover?
It recombines program structure rather than just values.
Correct answer: An operator that swaps branches between two program trees.
Why is bloat control important in genetic programming?
Bloat can make programs inefficient and overcomplicated.
Correct answer: To prevent programs from becoming too large
Symbolic Search
Genetic programming is a flexible tool for discovering formulas, rules, and interpretable structures.
Simple Example
A GP system might search for an expression approximating by evolving combinations of operators like , , , and constants.
Name one technique used to limit GP tree growth.
These methods reduce excessive complexity.
Correct answer: Depth limits, parsimony pressure, or size constraints.