geneticengine.representations.grammatical_evolution.ge
Module Contents
Classes
Abstract base class for generic types. |
- class geneticengine.representations.grammatical_evolution.ge.ListWrapper
Bases:
geneticengine.random.sources.RandomSource- dna: list[int]
- index: int = 0
- 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
- class geneticengine.representations.grammatical_evolution.ge.GrammaticalEvolutionRepresentation(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]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
- 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:
- mutate(random, internal, **kwargs)
- Parameters:
random (geneticengine.random.sources.RandomSource) –
internal (Genotype) –
- Return type: