geneticengine.representations.tree.initializations

Attributes

T

Classes

GlobalSynthesisContext

SynthesisDecider

Helper class that provides a standard way to create an ABC using

BaseDecider

Helper class that provides a standard way to create an ABC using

MaxDepthDecider

MaxDecider will generate random trees up to a maximum depth.

FullDecider

FullDecider will always preffer non-terminal productions within a

PositionIndependentGrowDecider

PositionIndependentGrowDecider will always randomly expand one path of

ProgressivelyTerminalDecider

Decides whether to restrict to non-recursive symbols based on the

Functions

wrap_result(v, global_context, context)

apply_constructor(ty, args)

number_of_nodes(v)

create_node(global_context, starting_symbol, context)

Module Contents

class geneticengine.representations.tree.initializations.GlobalSynthesisContext
random: geneticengine.random.sources.RandomSource
grammar: geneticengine.grammar.grammar.Grammar
decider: SynthesisDecider
geneticengine.representations.tree.initializations.T
class geneticengine.representations.tree.initializations.SynthesisDecider

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstractmethod random_int(min_int=-sys.maxsize, max_int=sys.maxsize)
Return type:

int

abstractmethod random_float()
Return type:

float

abstractmethod random_str()
Return type:

str

abstractmethod random_bool()
Return type:

bool

abstractmethod choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

abstractmethod choose_options(alternatives, ctx)
Parameters:
Return type:

T

class geneticengine.representations.tree.initializations.BaseDecider(random, grammar)

Bases: SynthesisDecider

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
random
grammar
random_int(min_int=-sys.maxsize - 1, max_int=sys.maxsize)
Return type:

int

random_float()
Return type:

float

random_str()
Return type:

str

random_bool()
Return type:

bool

choose_options(alternatives, ctx)
Parameters:
Return type:

T

class geneticengine.representations.tree.initializations.MaxDepthDecider(random, grammar, max_depth=10)

Bases: BaseDecider

MaxDecider will generate random trees up to a maximum depth.

Parameters:
max_depth = 10
choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

validate()
Return type:

None

class geneticengine.representations.tree.initializations.FullDecider(random, grammar, max_depth=10)

Bases: MaxDepthDecider

FullDecider will always preffer non-terminal productions within a maximum depth.

Parameters:
choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

class geneticengine.representations.tree.initializations.PositionIndependentGrowDecider(random, grammar, max_depth=10)

Bases: MaxDepthDecider

PositionIndependentGrowDecider will always randomly expand one path of the tree to get to the max depth, and others randomly.

Parameters:
expanding = True
choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

class geneticengine.representations.tree.initializations.ProgressivelyTerminalDecider(random, grammar)

Bases: BaseDecider

Decides whether to restrict to non-recursive symbols based on the current depth, probabilistically.

Parameters:
choose_production_alternatives(ty, alternatives, ctx)
Parameters:
Return type:

type

geneticengine.representations.tree.initializations.wrap_result(v, global_context, context)
Parameters:
Return type:

geneticengine.solutions.tree.TreeNode

geneticengine.representations.tree.initializations.apply_constructor(ty, args)
Parameters:
  • ty (Type)

  • args (list[Any])

geneticengine.representations.tree.initializations.number_of_nodes(v)
Parameters:

v (geneticengine.solutions.tree.TreeNode)

geneticengine.representations.tree.initializations.create_node(global_context, starting_symbol, context, dependent_values=None, parent_values=None, initial_values=None)
Parameters:
Return type:

Any