Table of Contents

Class TreeIndividual

Namespace
AiDotNet.Genetics
Assembly
AiDotNet.dll

Represents an individual in genetic programming with a tree structure.

public class TreeIndividual : IEvolvable<NodeGene, double>
Inheritance
TreeIndividual
Implements
Inherited Members

Constructors

TreeIndividual(NodeGene)

Creates a tree individual with the specified root node.

public TreeIndividual(NodeGene rootNode)

Parameters

rootNode NodeGene

The root node of the tree.

TreeIndividual(Random, List<string>, bool)

Creates a new tree individual with a random tree.

public TreeIndividual(Random random, List<string> terminals, bool fullMethod = false)

Parameters

random Random

Random number generator for initialization.

terminals List<string>

The terminal symbols available.

fullMethod bool

Whether to use the full or grow method.

Methods

Clone()

Creates a deep clone of this individual.

public IEvolvable<NodeGene, double> Clone()

Returns

IEvolvable<NodeGene, double>

A clone of this individual.

Evaluate(Dictionary<string, double>)

Evaluates the tree for a given input and returns the result.

public double Evaluate(Dictionary<string, double> variables)

Parameters

variables Dictionary<string, double>

Returns

double

GetDepth()

Gets the depth of the tree.

public int GetDepth()

Returns

int

GetExpression()

Gets a string representation of the tree.

public string GetExpression()

Returns

string

GetFitness()

Gets the fitness of this individual.

public double GetFitness()

Returns

double

The fitness score.

GetGenes()

Gets the genes of this individual.

public ICollection<NodeGene> GetGenes()

Returns

ICollection<NodeGene>

The collection of genes.

PermutationMutation()

Performs permutation mutation by randomizing the order of arguments.

public void PermutationMutation()

PointMutation()

Performs point mutation on the tree by changing a random terminal or function.

public void PointMutation()

ReplaceSubtree(NodeGene, NodeGene)

Replaces a subtree with another subtree.

public void ReplaceSubtree(NodeGene target, NodeGene replacement)

Parameters

target NodeGene
replacement NodeGene

SelectRandomNode()

Selects a random node from the tree.

public NodeGene SelectRandomNode()

Returns

NodeGene

SetFitness(double)

Sets the fitness of this individual.

public void SetFitness(double fitness)

Parameters

fitness double

The fitness score to set.

SetGenes(ICollection<NodeGene>)

Sets the genes of this individual.

public void SetGenes(ICollection<NodeGene> genes)

Parameters

genes ICollection<NodeGene>

The genes to set.

SubtreeMutation()

Performs subtree mutation by replacing a random subtree with a new one.

public void SubtreeMutation()