kgp.tree / Tree

Tree

class Tree

Represents a program as a tree of nodes.

Internally, we keep a simple list of nodes that is the "program".

Constructors

<init> Tree(nodes: MutableList<Node>, treeGenerator: TreeGenerator)

Represents a program as a tree of nodes.

Properties

fitness var fitness: Double

The fitness of this tree as based on some data set.

nodes var nodes: MutableList<Node>

A collection of nodes that make up this tree.

treeGenerator val treeGenerator: TreeGenerator

The tree generator used to create this tree (or its parent tree)

Functions

copy fun copy(): Tree

Creates a copy of this tree. All nodes are copied too.

crossover fun crossover(other: Tree): Unit

Performs the crossover operation on this tree and the tree given.

execute fun execute(case: List<Double>): Double

Executes the trees program on a set of inputs.

hoistMutation fun hoistMutation(): Unit

Performs the hoist mutation operation on this tree.

pointMutation fun pointMutation(replacementRate: Double): Unit

Performs the point mutation operation on this tree.

subtreeMutation fun subtreeMutation(): Unit

Performs the subtree mutation operation on this tree.

toString fun toString(): String

Prints the tree as an S-expression.