opytimizer.spaces.tree

Tree-based search space.

class opytimizer.spaces.tree.TreeSpace

A TreeSpace class for trees, agents, variables and methods related to a tree-based search space.

__init__()

Initialization method.

Parameters:
  • n_agents – Number of agents (trees).
  • n_variables – Number of decision variables.
  • lower_bound – Minimum possible values.
  • upper_bound – Maximum possible values.
  • n_terminals – Number of terminal nodes.
  • min_depth – Minimum depth of the trees.
  • max_depth – Maximum depth of the trees.
  • functions – Function nodes.
  • mapping – String-based identifiers for mapping variables’ names.
n_terminals

Number of terminal nodes.

min_depth

Minimum depth of the trees.

max_depth

Maximum depth of the trees.

functions

Function nodes.

terminals

Terminals nodes.

trees

Trees (derived from the Node class).

best_tree

Best tree.

_create_terminals() → None

Creates a list of terminals.

_create_trees() → None

Creates a list of trees based on the GROW algorithm.

_initialize_agents() → None

Initializes agents with their positions and defines a best agent.

grow(min_depth: Optional[int] = 1, max_depth: Optional[int] = 3) → opytimizer.core.node.Node

Creates a random tree based on the GROW algorithm.

References

S. Luke. Two Fast Tree-Creation Algorithms for Genetic Programming. IEEE Transactions on Evolutionary Computation (2000).

Parameters:
  • min_depth – Minimum depth of the tree.
  • max_depth – Maximum depth of the tree.
Returns:

Random tree based on the GROW algorithm.

Return type:

(Node)