C# Class AForge.Genetic.GPCustomTree

Reimplementation of GPCustomTree from Aforge for simple series monophonic note sequences
Inheritance: ChromosomeBase
Afficher le fichier Open project: stefan-j/GeneticMIDI Class Usage Examples

Méthodes publiques

Свойство Type Description
generator INoteGenerator

Protected Properties

Свойство Type Description
rand AForge.ThreadSafeRandom
root GPCustomTreeNode

Méthodes publiques

Méthode Description
Clone ( ) : IChromosome

Clone the chromosome.

The method clones the chromosome returning the exact copy of it.

CreateNew ( ) : IChromosome

Create new random chromosome with same parameters (factory method).

The method creates new chromosome of the same type, but randomly initialized. The method is useful as factory method for those classes, which work with chromosome's interface, but not with particular chromosome type.

Crossover ( IChromosome pair ) : void

Crossover operator.

The method performs crossover between two chromosomes – interchanging randomly selected sub trees.

GPCustomTree ( NoteGene ancestor ) : System

Initializes a new instance of the GPTreeChromosome class.

This constructor creates a randomly generated genetic tree, which has all genes of the same type and properties as the specified ancestor.

Generate ( ) : void

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

Generate ( IEnumerable notes ) : void
GenerateNotes ( ) : List
Mutate ( ) : void

Mutation operator.

The method performs chromosome's mutation by regenerating tree's randomly selected node.

ToString ( ) : string

Get string representation of the chromosome by providing its expression in reverse polish notation (postfix notation).

The method returns string representation of the tree's root node (see GPTreeNode.ToString).

Méthodes protégées

Méthode Description
GPCustomTree ( GPCustomTree source ) : System

Initializes a new instance of the GPTreeChromosome class.

This constructor creates new genetic tree as a copy of the specified source tree.

Generate ( GPCustomTreeNode node, int level ) : void

Generate chromosome's subtree of specified level.

Private Methods

Méthode Description
RandomSwap ( GPCustomTreeNode source ) : GPCustomTreeNode

Crossover helper routine - selects random node of chromosomes tree and swaps it with specified node.

Trim ( GPCustomTreeNode node, int level ) : void

Trim tree node, so its depth does not exceed specified level.

Method Details

Clone() public méthode

Clone the chromosome.

The method clones the chromosome returning the exact copy of it.

public Clone ( ) : IChromosome
Résultat IChromosome

CreateNew() public méthode

Create new random chromosome with same parameters (factory method).

The method creates new chromosome of the same type, but randomly initialized. The method is useful as factory method for those classes, which work with chromosome's interface, but not with particular chromosome type.

public CreateNew ( ) : IChromosome
Résultat IChromosome

Crossover() public méthode

Crossover operator.

The method performs crossover between two chromosomes – interchanging randomly selected sub trees.

public Crossover ( IChromosome pair ) : void
pair IChromosome Pair chromosome to crossover with.
Résultat void

GPCustomTree() protected méthode

Initializes a new instance of the GPTreeChromosome class.

This constructor creates new genetic tree as a copy of the specified source tree.

protected GPCustomTree ( GPCustomTree source ) : System
source GPCustomTree Source genetic tree to clone from.
Résultat System

GPCustomTree() public méthode

Initializes a new instance of the GPTreeChromosome class.

This constructor creates a randomly generated genetic tree, which has all genes of the same type and properties as the specified ancestor.

public GPCustomTree ( NoteGene ancestor ) : System
ancestor NoteGene A gene, which is used as generator for the genetic tree.
Résultat System

Generate() public méthode

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

public Generate ( ) : void
Résultat void

Generate() protected méthode

Generate chromosome's subtree of specified level.
protected Generate ( GPCustomTreeNode node, int level ) : void
node GPCustomTreeNode Sub tree's node to generate.
level int Sub tree's level to generate.
Résultat void

Generate() public méthode

public Generate ( IEnumerable notes ) : void
notes IEnumerable
Résultat void

GenerateNotes() public méthode

public GenerateNotes ( ) : List
Résultat List

Mutate() public méthode

Mutation operator.

The method performs chromosome's mutation by regenerating tree's randomly selected node.

public Mutate ( ) : void
Résultat void

ToString() public méthode

Get string representation of the chromosome by providing its expression in reverse polish notation (postfix notation).

The method returns string representation of the tree's root node (see GPTreeNode.ToString).

public ToString ( ) : string
Résultat string

Property Details

generator public_oe static_oe property

public static INoteGenerator generator
Résultat INoteGenerator

rand protected_oe static_oe property

Random generator used for chromosoms' generation.
protected static ThreadSafeRandom,AForge rand
Résultat AForge.ThreadSafeRandom

root protected_oe property

protected GPCustomTreeNode,AForge.Genetic root
Résultat GPCustomTreeNode