A genetic programming library written in C#

Source repository:

Genetica is a .NET open-source genetic programming (GP) library written entirely in C#. Currently, Genetica.NET supports the evolution of programs representing mathematical expressions in a syntactic tree form. Mathematical programs combine primitives taken from a set of terminals, representing input scalar values, and several mathematical functions.

[bibshow file=my-publications.bib show_links=1 format=custom-ieee template=custom-bibshow highlight=”P. Sequeira”]


In general terms, GP allows a population of candidate programs to change over time by means of operators inspired from natural evolution such as selection, mutation and crossover. The evolutionary process is guided by a fitness function that assesses how fit a program is (usually its output) in regard to some external objective function.

Works that used this code: [bibcite key=sequeira2018cogsci]


  • Creation of programs as mathematical expressions
    • Terminals: constant and variables
    • Functions: arithmetic functions, sine, cosine, min, max, log, exponentiation and ‘if’ conditional operator
  • Genetic operators
    • Selection: tournament, roulette wheel (even and uneven selectors), stochastic
    • Crossover: uniform, one-point, sub-tree, context-preserving, stochastic
    • Mutation: point, sub-tree, hoist, shrink, swap, simplify, fitness simplify, stochastic
    • Generation: full-depth, grow, stochastic
  • Population class implementing a standard steady-state GP evolutionary procedure
  • Rank (linear and non-linear) fitness functions
  • Measure the similarity between two programs
    • Similarity measures: value (according to the range of variables), primitive, leaf, sub-program, sub-combination, prefix and normal notation expression edit, tree edit, common region, average
  • Conversion of programs to/from strings in normal and prefix notation
  • Program simplification to remove redundancies and evolutionary noise
  • Visual instruments (trees) to analyze the structure of sets of programs (e.g., a population):
    • Information, symbol, ordered symbol, sub-program

Related Publications