geneticengine.representations.grammatical_evolution.dynamic_structured_ge

Attributes

T

MAX_GENE_VALUE

Classes

Genotype

DynamicSGEDecider

DynamicStructuredGrammaticalEvolutionRepresentation

This version uses a list of lists of integers to represent individuals,

Module Contents

geneticengine.representations.grammatical_evolution.dynamic_structured_ge.T
geneticengine.representations.grammatical_evolution.dynamic_structured_ge.MAX_GENE_VALUE = 1024
class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.Genotype
random: geneticengine.random.sources.RandomSource
dna: dict[type, list[int]]
get(ty, n)
Parameters:
  • ty (type)

  • n (int)

class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.DynamicSGEDecider(genotype, grammar, max_depth=10, max_string_length=128)

Bases: geneticengine.representations.tree.initializations.SynthesisDecider

Parameters:
genotype
grammar
max_depth = 10
positions: dict[type, int]
max_string_length = 128
read(ty)
random_int(min_int=-sys.maxsize, max_int=sys.maxsize)
Return type:

int

random_float()
Return type:

float

random_chr()
Return type:

int

random_str()
Return type:

str

random_bool()
Return type:

bool

choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

choose_options(alternatives, ctx)
Parameters:
Return type:

T

validate()
Return type:

None

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

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

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)

grammar
max_depth
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

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

Genotype

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

tuple[Genotype, Genotype]