geneticengine.representations.grammatical_evolution.ge

Classes

Genotype

ListWrapper

GrammaticalEvolutionRepresentation

ExtensibleGrammaticalEvolutionRepresentation

GE variant that appends random codons when mapping exhausts the genome.

Module Contents

class geneticengine.representations.grammatical_evolution.ge.Genotype
dna: list[int]
class geneticengine.representations.grammatical_evolution.ge.ListWrapper

Bases: geneticengine.random.sources.RandomSource

dna: list[int]
index: int = 0
random: geneticengine.random.sources.RandomSource | None = None
extend: bool = False
consumed: int = 0
_next_gene()
Return type:

int

randint(min, max)
Parameters:
  • min (int)

  • max (int)

Return type:

int

random_float(min, max)
Parameters:
  • min (float)

  • max (float)

Return type:

float

class geneticengine.representations.grammatical_evolution.ge.GrammaticalEvolutionRepresentation(grammar, decider, gene_length=256, mutation=None, extend_genotype=False)

Bases: geneticengine.representations.api.Representation[Genotype, geneticengine.solutions.tree.TreeNode], geneticengine.representations.api.RepresentationWithMutation[Genotype], geneticengine.representations.api.RepresentationWithCrossover[Genotype]

Parameters:
grammar
decider
gene_length = 256
mutation: geneticengine.representations.linear_mutation.LinearGenomeMutation[int]
extend_genotype = False
_expressed_length(genotype)

Return the number of codons used to map genotype.

Parameters:

genotype (Genotype)

Return type:

int

create_genotype(random, **kwargs)
Parameters:

random (geneticengine.random.sources.RandomSource)

Return type:

Genotype

genotype_to_phenotype(genotype)
Parameters:

genotype (Genotype)

Return type:

geneticengine.solutions.tree.TreeNode

_random_gene(random)
Parameters:

random (geneticengine.random.sources.RandomSource)

Return type:

int

mutate(random, genotype, effective=False, **kwargs)
Parameters:
Return type:

Genotype

crossover(random, parent1, parent2, effective=False, **kwargs)
Parameters:
Return type:

tuple[Genotype, Genotype]

class geneticengine.representations.grammatical_evolution.ge.ExtensibleGrammaticalEvolutionRepresentation(grammar, decider, gene_length=256)

Bases: GrammaticalEvolutionRepresentation

GE variant that appends random codons when mapping exhausts the genome.

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 – Mutation strategy for the integer codon list. Defaults to PointMutation. Pass UMAD for addition/deletion mutation.