geneticengine.representations.tree.treebased
Module Contents
Classes
This class represents the tree representation of an individual. |
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Given the two input trees [p1] and [p2], the grammar and the random |
Attributes
- geneticengine.representations.tree.treebased.T
- geneticengine.representations.tree.treebased.random_node(r, g, max_depth, starting_symbol=None, method=grow_method)
- Parameters:
max_depth (int)
starting_symbol (type[Any] | None)
method (geneticengine.representations.tree.initializations.InitializationMethodType)
- geneticengine.representations.tree.treebased.random_individual(r, g, max_depth=5, method=grow_method)
- Parameters:
max_depth (int)
method (geneticengine.representations.tree.initializations.InitializationMethodType)
- Return type:
- geneticengine.representations.tree.treebased.mutate_inner(r, g, i, max_depth, ty, force_mutate, depth_aware_mut)
- Parameters:
max_depth (int)
ty (type)
force_mutate (bool)
depth_aware_mut (bool)
- Return type:
- geneticengine.representations.tree.treebased.mutate_specific_type_inner(r, g, i, max_depth, ty, specific_type, n, depth_aware_mut)
- Parameters:
max_depth (int)
ty (type)
specific_type (type)
n (int)
depth_aware_mut (bool)
- Return type:
- geneticengine.representations.tree.treebased.mutate_specific_type(r, g, i, max_depth, target_type, specific_type, depth_aware_mut)
- Parameters:
max_depth (int)
target_type (type)
specific_type (type)
depth_aware_mut (bool)
- Return type:
- geneticengine.representations.tree.treebased.tree_mutate(r, g, i, max_depth, target_type, depth_aware_mut=False)
- Parameters:
max_depth (int)
target_type (type)
depth_aware_mut (bool)
- Return type:
Any
- geneticengine.representations.tree.treebased.find_in_tree(g, ty, o, max_depth)
- Parameters:
ty (type)
max_depth (int)
- geneticengine.representations.tree.treebased.find_in_tree_exact(g, ty, o, max_depth)
- Parameters:
ty (type)
max_depth (int)
- geneticengine.representations.tree.treebased.crossover_inner(r, g, i, o, max_depth, ty, force_crossover, depth_aware_co)
- Parameters:
max_depth (int)
ty (type)
force_crossover (bool)
depth_aware_co (bool)
- Return type:
Any
- geneticengine.representations.tree.treebased.crossover_specific_type_inner(r, g, i, o, max_depth, ty, specific_type, n, depth_aware_co)
- Parameters:
max_depth (int)
ty (type)
specific_type (type)
n (int)
depth_aware_co (bool)
- Return type:
- geneticengine.representations.tree.treebased.crossover_specific_type(r, g, i, o, max_depth, target_type, specific_type, depth_aware_co)
- Parameters:
max_depth (int)
target_type (type)
specific_type (type)
depth_aware_co (bool)
- Return type:
- geneticengine.representations.tree.treebased.tree_crossover(r, g, p1, p2, max_depth, specific_type=None, depth_aware_co=False)
Given the two input trees [p1] and [p2], the grammar and the random source, this function returns two trees that are created by crossing over.
[p1] and [p2].
The first tree returned has [p1] as the base, and the second tree has [p2] as a base.
- Parameters:
max_depth (int)
specific_type (type | None)
depth_aware_co (bool)
- Return type:
tuple[geneticengine.solutions.tree.TreeNode, geneticengine.solutions.tree.TreeNode]
- class geneticengine.representations.tree.treebased.TreeBasedRepresentation(grammar, max_depth, initialization_method=pi_grow_method)
Bases:
geneticengine.representations.api.Representation
[geneticengine.solutions.tree.TreeNode
,geneticengine.solutions.tree.TreeNode
],geneticengine.representations.api.RepresentationWithMutation
[geneticengine.solutions.tree.TreeNode
],geneticengine.representations.api.RepresentationWithCrossover
[geneticengine.solutions.tree.TreeNode
]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)
max_depth (int)
initialization_method (geneticengine.representations.tree.initializations.InitializationMethodType)
- create_genotype(random, **kwargs)
- Parameters:
- Return type:
- genotype_to_phenotype(genotype)
- Parameters:
genotype (geneticengine.solutions.tree.TreeNode)
- Return type:
- mutate(random, internal, **kwargs)
- Parameters:
internal (geneticengine.solutions.tree.TreeNode)
- Return type:
- crossover(random, parent1, parent2, **kwargs)
- Parameters:
parent1 (geneticengine.solutions.tree.TreeNode)
parent2 (geneticengine.solutions.tree.TreeNode)
- Return type:
tuple[geneticengine.solutions.tree.TreeNode, geneticengine.solutions.tree.TreeNode]