Genetic programming (GP) evolves executable code rather than only fixed parameter sequences. Candidate programs are assembled from functions, inputs, constants, and control logic; fitness selects routines that better solve a task. This makes GP useful when the desired result is an inspectable equation, decision routine, or program rather than a preset model structure. section 1.1.1 section 4.6
A GP individual can be represented as an expression tree. Operators form internal nodes, while constants and arguments form leaves; evaluating the resulting expression produces an output that can be compared with a target to assign fitness. GP shares evolutionary principles and many operators with genetic algorithms, but changes the chromosome structure and evaluation target. section 4.1 section 4.1.1
Trace how a gene sequence becomes an expression tree, equation, and fitness value. section 4.1.1
A practical DEAP workflow is:
- Define a primitive set of allowed operators, constants, and input arguments. section 4.1.1
- Generate individuals and populations, then compile each evolved expression into a callable function. section 4.1.1
- Evaluate outputs against targets, using an error value as fitness for symbolic regression. section 4.1.1
- Visualize successful trees to inspect the derived equation or code routine. section 4.1.1 section 4.6
Symbolic regression and the genetic ant
For multivariable regression, GP can evolve an equation from four random inputs toward a target such as (x4 + x1) / x3 × x2. For the genetic ant, a primitive set combines conditionals and sequencing operators with movement terminals; compiled routines are rewarded by the food the ant consumes, then can be evolved across multiple environments. section 4.1.1 section 12.4
Primitive sets constrain what can evolve. An ant routine, for example, uses conditional and sequencing operators alongside actions such as move forward and turn; extending terminals, sensors, or environments creates new behaviors to search over. Testing across several environments pushes routines toward more general behavior. section 12.4 section 12.4.1
