What is genetic programming?

Genetic programming (GP) is a problem-solving technique inspired by the biological evolution process that revolves around the evolution of computer programs as possible solutions. Genetic programming is generally applied to the problems of optimization and search or to find solutions to complex problems.

Genetic programming comprises the following steps: initialization, evaluation, selection, crossover, mutation, replacement, and termination.

Genetic programming flowchart
Genetic programming flowchart

Let’s see what each of these phases does:

  1. Initialization: This involves a set of randomly generated programs for the given problem in the form of syntax trees.

  2. Evaluation: Every program is evaluated over predefined criteria, i.e., fitness function,Assesses the proximity of a given solution to the optimal solution for the intended problem and gets a fitness score.

  3. Selection: Based on the evaluation results, top-performing programs are selected for further phases.

  4. Crossover: In GP, a crossover is done by swapping subtrees or substructures of the parent programs.

  5. Mutation: Random changes to program structures are made in this phase, which may include adding, modifying, and deleting nodes or terminals, etc.

  6. Replacement: This phase decides which programs from the parents and children will move to the proceeding phases.

  7. Termination: Phases 2–6 are repeated until a stopping criterion is met, producing the best-performing program as the optimal solution to the given problem.

GP is generally used for, but not limited to, function approximations, classification, and optimization problems, as well as in Bioinformatics, Robotics, NLP, etc. However, GP’s performance and scalability are limited by space complexity, time complexity, premature convergence, and overfitting.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved