C# 클래스 AForge.Genetic.GEPChromosome

The chromosome represents a Gene Expression, which is used for different tasks of Genetic Expression Programming (GEP).

This type of chromosome represents combination of ideas taken from Genetic Algorithms (GA), where chromosomes are linear structures of fixed length, and Genetic Programming (GP), where chromosomes are expression trees. The GEP chromosome is also a fixed length linear structure, but with some additional features which make it possible to generate valid expression tree from any GEP chromosome.

The theory of Gene Expression Programming is well described in the next paper: Ferreira, C., 2001. Gene Expression Programming: A New Adaptive Algorithm for Solving Problems. Complex Systems, Vol. 13, issue 2: 87-129. A copy of the paper may be obtained on the gene expression programming web site.

상속: ChromosomeBase
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
genes IGPGene[]
headLength int
length int
rand ThreadSafeRandom

공개 메소드들

메소드 설명
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 one-point or two-point crossover selecting them randomly with equal probability.

GEPChromosome ( IGPGene ancestor, int headLength ) : System

Initializes a new instance of the GEPChromosome class.

This constructor creates a randomly generated GEP chromosome, 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.

Mutate ( ) : void

Mutation operator.

The method performs chromosome's mutation by calling on of the methods randomly: MutateGene, TransposeIS, TransposeRoot.

RecombinationOnePoint ( GEPChromosome pair ) : void

One-point recombination (crossover).

RecombinationTwoPoint ( GEPChromosome pair ) : void

Two point recombination (crossover).

ToString ( ) : string

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

ToStringNative ( ) : string

Get string representation of the chromosome.

The method is used for debugging mostly.

보호된 메소드들

메소드 설명
GEPChromosome ( GEPChromosome source ) : System

Initializes a new instance of the GEPChromosome class.

GetTree ( ) : GPTreeNode

Get tree representation of the chromosome.

The method builds expression's tree for the native linear representation of the GEP chromosome.

MutateGene ( ) : void

Usual gene mutation.

The method performs usual gene mutation by randomly changing randomly selected gene.

Recombine ( IGPGene src1, IGPGene src2, int point, int length ) : void

Swap parts of two chromosomes.

The method performs interchanging of genes between two chromosomes starting from the point position.

TransposeIS ( ) : void

Transposition of IS elements (insertion sequence).

The method performs transposition of IS elements by copying randomly selected region of genes into chromosome's head (into randomly selected position). First gene of the chromosome's head is not affected - can not be selected as target point.

TransposeRoot ( ) : void

Root transposition.

The method performs root transposition of the GEP chromosome - inserting new root of the chromosome and shifting existing one. The method first of all randomly selects a function gene in chromosome's head - starting point of the sequence to put into chromosome's head. Then it randomly selects the length of the sequence making sure that the entire sequence is located within head. Once the starting point and the length of the sequence are known, it is copied into chromosome's head shifting existing elements in the head.

메소드 상세

Clone() 공개 메소드

Clone the chromosome.

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

public Clone ( ) : IChromosome
리턴 IChromosome

CreateNew() 공개 메소드

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
리턴 IChromosome

Crossover() 공개 메소드

Crossover operator.

The method performs one-point or two-point crossover selecting them randomly with equal probability.

public Crossover ( IChromosome pair ) : void
pair IChromosome Pair chromosome to crossover with.
리턴 void

GEPChromosome() 보호된 메소드

Initializes a new instance of the GEPChromosome class.
protected GEPChromosome ( GEPChromosome source ) : System
source GEPChromosome Source GEP chromosome to clone from.
리턴 System

GEPChromosome() 공개 메소드

Initializes a new instance of the GEPChromosome class.

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

public GEPChromosome ( IGPGene ancestor, int headLength ) : System
ancestor IGPGene A gene, which is used as generator for the genetic tree.
headLength int Length of GEP chromosome's head (see ).
리턴 System

Generate() 공개 메소드

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

public Generate ( ) : void
리턴 void

GetTree() 보호된 메소드

Get tree representation of the chromosome.

The method builds expression's tree for the native linear representation of the GEP chromosome.

protected GetTree ( ) : GPTreeNode
리턴 GPTreeNode

Mutate() 공개 메소드

Mutation operator.

The method performs chromosome's mutation by calling on of the methods randomly: MutateGene, TransposeIS, TransposeRoot.

public Mutate ( ) : void
리턴 void

MutateGene() 보호된 메소드

Usual gene mutation.

The method performs usual gene mutation by randomly changing randomly selected gene.

protected MutateGene ( ) : void
리턴 void

RecombinationOnePoint() 공개 메소드

One-point recombination (crossover).
public RecombinationOnePoint ( GEPChromosome pair ) : void
pair GEPChromosome Pair chromosome to crossover with.
리턴 void

RecombinationTwoPoint() 공개 메소드

Two point recombination (crossover).
public RecombinationTwoPoint ( GEPChromosome pair ) : void
pair GEPChromosome Pair chromosome to crossover with.
리턴 void

Recombine() 보호된 정적인 메소드

Swap parts of two chromosomes.

The method performs interchanging of genes between two chromosomes starting from the point position.

protected static Recombine ( IGPGene src1, IGPGene src2, int point, int length ) : void
src1 IGPGene First chromosome participating in genes' interchange.
src2 IGPGene Second chromosome participating in genes' interchange.
point int Index of the first gene in the interchange sequence.
length int Length of the interchange sequence - number of genes /// to interchange.
리턴 void

ToString() 공개 메소드

Get string representation of the chromosome by providing its expression in reverse polish notation (postfix notation).
public ToString ( ) : string
리턴 string

ToStringNative() 공개 메소드

Get string representation of the chromosome.

The method is used for debugging mostly.

public ToStringNative ( ) : string
리턴 string

TransposeIS() 보호된 메소드

Transposition of IS elements (insertion sequence).

The method performs transposition of IS elements by copying randomly selected region of genes into chromosome's head (into randomly selected position). First gene of the chromosome's head is not affected - can not be selected as target point.

protected TransposeIS ( ) : void
리턴 void

TransposeRoot() 보호된 메소드

Root transposition.

The method performs root transposition of the GEP chromosome - inserting new root of the chromosome and shifting existing one. The method first of all randomly selects a function gene in chromosome's head - starting point of the sequence to put into chromosome's head. Then it randomly selects the length of the sequence making sure that the entire sequence is located within head. Once the starting point and the length of the sequence are known, it is copied into chromosome's head shifting existing elements in the head.

protected TransposeRoot ( ) : void
리턴 void

프로퍼티 상세

genes 보호되어 있는 프로퍼티

Array of chromosome's genes.
protected IGPGene[] genes
리턴 IGPGene[]

headLength 보호되어 있는 프로퍼티

Length of GEP chromosome's head.

GEP chromosome's head is a part of chromosome, which may contain both functions' and arguments' nodes. The rest of chromosome (tail) may contain only arguments' nodes.

protected int headLength
리턴 int

length 보호되어 있는 프로퍼티

GEP chromosome's length.

The variable keeps chromosome's length, but not expression length represented by the chromosome.

protected int length
리턴 int

rand 보호되어 있는 정적으로 프로퍼티

Random generator used for chromosoms' generation.
protected static ThreadSafeRandom rand
리턴 ThreadSafeRandom