Genetic Programming


Implementation of Koza-type (tree-based) Genetic Programming

The constructor takes following keyword arguments:

  • populationSize: The size of the population
  • terminals: A dictionary of terminals with their their corresponding dimensionality
    • This dictionary contains (Terminal, Int) pairs
    • The terminals can be any symbols (variables), constat values, or 0-arity functions.
  • functions: A collection of functions with their corresponding arity.
    • This dictionary contains (Function, Int) pairs
  • initialization: A strategy for population initialization (default: :grow)
    • Possible values: :grow and :full
  • mindepth: Minimal depth of the expression (default: 0)
  • maxdepth: Maximal depth of the expression (default: 3)
  • mutation: A mutation function (default: crosstree)
  • crossover: A crossover function (default: subtree)
  • simplify: An expression simplification function (default: :nothing)
  • optimizer: An evolutionary optimizer used for evolving the expressions (default: GA)
    • Use mutation and crossover parameters to specify GP-related mutation operation.
    • Use selection parameter to specify the offspring selection procedure


The Genetic Programming is a technique of evolving programs, starting from a population of unfit (usually random) programs, fit for a particular task by applying operations analogous to natural genetic processes to the population of programs. It is essentially a heuristic search technique, i.e. searching for an optimal or at least suitable program among the space of all programs[1].

Auxiliary Functions


  • 1John R. Koza, "Genetic Programming: On the Programming of Computers by Means of Natural Selection", MIT Press, 1992.