Individual representations

Genetic Engine currently supports 4 individual representations:

  • Tree-based representation, also known as Context-Free Grammars GP (CFG-GP)[1]

  • Grammatical Evolution (GE)[2]

  • Structured GE (SGE)[3]

  • Dynamic SGE (dSGE)[4]

The representation can be chosen by the user. There are many discussions on which representation performs better as a search algorithm (fitness progression will differ across algorithms). Genetic Engine uses the same method for tree generation in CFG-GP and genotype-to-phenotype mapping in GE, SGE and dSGE, making it individual-representation independent on the implementation side. Still, we aim to implement performance enhancements on trees, benefitting the performance of CFG-GP, both on the time performance side (such as detailed in [5]), as on the algorithm side.

Tree-based

class geneticengine.representations.tree.treebased.TreeBasedRepresentation(grammar, decider)

This class represents the tree representation of an individual.

In this approach, the genotype and the phenotype are exactly the same.

Parameters:

Grammatical Evolution

class geneticengine.representations.grammatical_evolution.ge.GrammaticalEvolutionRepresentation(grammar, decider, gene_length=256)
Parameters:

Structured Grammatical Evolution

class geneticengine.representations.grammatical_evolution.structured_ge.StructuredGrammaticalEvolutionRepresentation(grammar, decider, gene_length=256)

This version uses a list of lists of integers to represent individuals, based on non-terminal symbols.

Parameters:

Dynamic Structured Grammatical Evolution

class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.DynamicStructuredGrammaticalEvolutionRepresentation(grammar, max_depth)

This version uses a list of lists of integers to represent individuals, based on non-terminal symbols.

Parameters:
  • grammar (Grammar) – The grammar to use in the mapping

  • max_depth (int) – the maximum depth when performing the mapping (e.g., pi_grow, full, grow)

Stack-based Grammatical Evolution

class geneticengine.representations.stackgggp.StackBasedGGGPRepresentation(grammar, gene_length=1024, failures_limit=100)

This representation uses a list of integers to guide the generation of trees in the phenotype.

Parameters:

Custom Representations

To create a custom representation, you just need to subclass the following abstract class:

class geneticengine.representations.api.Representation

To support Genetic Programming, you also need to implement:

class geneticengine.representations.api.RepresentationWithMutation
class geneticengine.representations.api.RepresentationWithCrossover

References