geneticengine.representations.tree.treebased

Module Contents

Classes

TreeBasedRepresentation

This class represents the tree representation of an individual.

Functions

random_node(r, g, max_depth[, starting_symbol, method])

random_individual(r, g[, max_depth, method])

mutate_inner(r, g, i, max_depth, ty, force_mutate, ...)

mutate_specific_type_inner(r, g, i, max_depth, ty, ...)

mutate_specific_type(r, g, i, max_depth, target_type, ...)

tree_mutate(r, g, i, max_depth, target_type[, ...])

find_in_tree(g, ty, o, max_depth)

find_in_tree_exact(g, ty, o, max_depth)

crossover_inner(r, g, i, o, max_depth, ty, ...)

crossover_specific_type_inner(r, g, i, o, max_depth, ...)

crossover_specific_type(r, g, i, o, max_depth, ...)

tree_crossover(r, g, p1, p2, max_depth[, ...])

Given the two input trees [p1] and [p2], the grammar and the random

Attributes

T

geneticengine.representations.tree.treebased.T
geneticengine.representations.tree.treebased.random_node(r, g, max_depth, starting_symbol=None, method=grow_method)
Parameters:
geneticengine.representations.tree.treebased.random_individual(r, g, max_depth=5, method=grow_method)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.treebased.mutate_inner(r, g, i, max_depth, ty, force_mutate, depth_aware_mut)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.treebased.mutate_specific_type_inner(r, g, i, max_depth, ty, specific_type, n, depth_aware_mut)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.treebased.mutate_specific_type(r, g, i, max_depth, target_type, specific_type, depth_aware_mut)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.treebased.tree_mutate(r, g, i, max_depth, target_type, depth_aware_mut=False)
Parameters:
Return type:

Any

geneticengine.representations.tree.treebased.find_in_tree(g, ty, o, max_depth)
Parameters:
geneticengine.representations.tree.treebased.find_in_tree_exact(g, ty, o, max_depth)
Parameters:
geneticengine.representations.tree.treebased.crossover_inner(r, g, i, o, max_depth, ty, force_crossover, depth_aware_co)
Parameters:
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:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.treebased.crossover_specific_type(r, g, i, o, max_depth, target_type, specific_type, depth_aware_co)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

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:
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:
create_genotype(random, **kwargs)
Parameters:

random (geneticengine.random.sources.RandomSource)

Return type:

geneticengine.solutions.tree.TreeNode

genotype_to_phenotype(genotype)
Parameters:

genotype (geneticengine.solutions.tree.TreeNode)

Return type:

geneticengine.solutions.tree.TreeNode

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

geneticengine.solutions.tree.TreeNode

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

tuple[geneticengine.solutions.tree.TreeNode, geneticengine.solutions.tree.TreeNode]