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, max_operation_depth=None)
This class represents the tree representation of an individual.
In this approach, the genotype and the phenotype are exactly the same.
- Parameters:
grammar (geneticengine.grammar.grammar.Grammar)
decider (geneticengine.representations.tree.initializations.SynthesisDecider)
max_operation_depth (int | None)
Grammatical Evolution
- class geneticengine.representations.grammatical_evolution.ge.GrammaticalEvolutionRepresentation(grammar, decider, gene_length=256, mutation=None, extend_genotype=False)
- Parameters:
grammar (Grammar) – The grammar to use in the mapping
decider (SynthesisDecider) – Controls phenotype tree construction depth
gene_length (int) – Initial genome length for new individuals
mutation (geneticengine.representations.linear_mutation.LinearGenomeMutation[int] | None) – Mutation strategy for the integer codon list. Defaults to
PointMutation. PassUMADfor addition/deletion mutation.extend_genotype (bool)
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:
grammar (Grammar) – The grammar to use in the mapping
max_depth (int) – the maximum depth when performing the mapping
decider (geneticengine.representations.tree.initializations.SynthesisDecider)
gene_length (int)
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, mutation=None)
This representation uses a list of integers to guide the generation of trees in the phenotype.
Mapping stops once the start-symbol stack is non-empty and the genome has been read at least once; the last start-symbol value is returned.
- Parameters:
grammar (geneticengine.grammar.grammar.Grammar) – Grammar used for stack-based mapping
gene_length (int) – Initial genome length for new individuals
failures_limit (int) – Max mapping failures before giving up
mutation (geneticengine.representations.linear_mutation.LinearGenomeMutation[int] | None) – Mutation strategy for the integer gene list. Defaults to
PointMutation. PassUMADfor addition/deletion mutation.
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