geneticengine.representations.grammatical_evolution.dynamic_structured_ge

Module Contents

Classes

Genotype

DynamicStructuredListWrapper

DynamicStructuredGrammaticalEvolutionRepresentation

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

Functions

filter_choices(possible_choices, g, depth, starting_symbol)

assert_depth_error(max_depth, g, starting_symbol)

random_individual(r, g, starting_symbol[, ...])

create_tree(g, ind, depth[, initialization_mode])

Attributes

INFRASTRUCTURE_KEY

LEFTOVER_KEY

MAX_RAND_LIST_SIZE

geneticengine.representations.grammatical_evolution.dynamic_structured_ge.INFRASTRUCTURE_KEY = '$infrastructure'
geneticengine.representations.grammatical_evolution.dynamic_structured_ge.LEFTOVER_KEY = '$leftovers'
geneticengine.representations.grammatical_evolution.dynamic_structured_ge.MAX_RAND_LIST_SIZE = 10
class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.Genotype
dna: dict[str, list[int]]
register_production(prod_index, starting_symbol)
Parameters:

prod_index (int)

geneticengine.representations.grammatical_evolution.dynamic_structured_ge.filter_choices(possible_choices, g, depth, starting_symbol)
Parameters:
geneticengine.representations.grammatical_evolution.dynamic_structured_ge.assert_depth_error(max_depth, g, starting_symbol)
geneticengine.representations.grammatical_evolution.dynamic_structured_ge.random_individual(r, g, starting_symbol, current_genotype=None, max_depth=5)
Parameters:
Return type:

Genotype

class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.DynamicStructuredListWrapper(ind)

Bases: geneticengine.random.sources.RandomSource

Parameters:

ind (Genotype)

ind: Genotype
indexes: dict[str, int]
register_index(prod)
randint(min, max, prod='')
Parameters:
  • min (int)

  • max (int)

  • prod (str)

Return type:

int

random_float(min, max, prod='')
Parameters:
  • min (float)

  • max (float)

  • prod (str)

Return type:

float

geneticengine.representations.grammatical_evolution.dynamic_structured_ge.create_tree(g, ind, depth, initialization_mode=pi_grow_method)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

class geneticengine.representations.grammatical_evolution.dynamic_structured_ge.DynamicStructuredGrammaticalEvolutionRepresentation(grammar, max_depth, gene_length=256, initialization_mode=pi_grow_method)

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

  • initialization_mode (InitializationMethodType) – method to create individuals in the mapping (e.g., pi_grow, full, grow)

  • gene_length (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

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

Genotype

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

tuple[Genotype, Genotype]