geneticengine.representations.tree.treebased
Attributes
Classes
This class represents the tree representation of an individual. |
Functions
|
|
|
|
|
|
|
Generates all nodes that can be mutable in a program. |
|
|
|
Given the two input trees [p1] and [p2], the grammar and the random |
Module Contents
- geneticengine.representations.tree.treebased.T
- geneticengine.representations.tree.treebased.random_node(random, grammar, starting_symbol, decider)
- Parameters:
grammar (geneticengine.grammar.grammar.Grammar)
starting_symbol (type[Any])
decider (geneticengine.representations.tree.initializations.SynthesisDecider)
- geneticengine.representations.tree.treebased.random_tree(random, grammar, decider)
- Parameters:
- Return type:
- geneticengine.representations.tree.treebased.get_weighted_nodes(e)
- Parameters:
e (Any)
- Return type:
int
- geneticengine.representations.tree.treebased.find_in_tree(ty, o)
- Parameters:
ty (type)
- geneticengine.representations.tree.treebased.mutate(global_context, i, ty, dependent_values=None, source_material=None)
Generates all nodes that can be mutable in a program.
- Parameters:
global_context (geneticengine.representations.tree.initializations.GlobalSynthesisContext)
ty (type)
dependent_values (dict[str, Any] | None)
source_material (list[geneticengine.solutions.tree.TreeNode] | None)
- Return type:
- geneticengine.representations.tree.treebased.tree_mutate(r, g, i, target_type, decider)
- Parameters:
- Return type:
Any
- geneticengine.representations.tree.treebased.tree_crossover(r, g, p1, p2, decider)
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:
- Return type:
tuple[geneticengine.solutions.tree.TreeNode, geneticengine.solutions.tree.TreeNode]
- class geneticengine.representations.tree.treebased.TreeBasedRepresentation(grammar, decider)
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
- decider
- create_genotype(random, **kwargs)
- Parameters:
- Return type:
- genotype_to_phenotype(genotype)
- Parameters:
genotype (geneticengine.solutions.tree.TreeNode)
- Return type:
- mutate(random, genotype, **kwargs)
- Parameters:
genotype (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]