C# 클래스 Accord.Genetic.DoubleArrayChromosome

Double array chromosome.

Double array chromosome represents array of double values. Array length is in the range of [2, 65536].

See documentation to Mutate and Crossover methods for information regarding implemented mutation and crossover operators.

상속: ChromosomeBase
파일 보기 프로젝트 열기: accord-net/framework 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
chromosomeGenerator IRandomNumberGenerator
mutationAdditionGenerator IRandomNumberGenerator
mutationMultiplierGenerator IRandomNumberGenerator
val double[]

공개 메소드들

메소드 설명
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, selecting randomly the exact type of crossover to perform, which depends on CrossoverBalancer. Before crossover is done a random number is generated in [0, 1] range - if the random number is smaller than CrossoverBalancer, then the first crossover type is used, otherwise second type is used.

The first crossover type is based on interchanging range of genes (array elements) between these chromosomes and is known as one point crossover. A crossover point is selected randomly and chromosomes interchange genes, which start from the selected point.

The second crossover type is aimed to produce one child, which genes' values are between corresponding genes of parents, and another child, which genes' values are outside of the range formed by corresponding genes of parents. Let take, for example, two genes with 1.0 and 3.0 valueû (of course chromosomes have more genes, but for simplicity lets think about one). First of all we randomly choose a factor in the [0, 1] range, let's take 0.4. Then, for each pair of genes (we have one pair) we calculate difference value, which is 2.0 in our case. In the result we’ll have two children – one between and one outside of the range formed by parents genes' values. We may have 1.8 and 3.8 children, or we may have 0.2 and 2.2 children. As we can see we add/subtract (chosen randomly) difference * factor. So, this gives us exploration in between and in near outside. The randomly chosen factor is applied to all genes of the chromosomes participating in crossover.

DoubleArrayChromosome ( DoubleArrayChromosome source ) : System

Initializes a new instance of the DoubleArrayChromosome class.

This is a copy constructor, which creates the exact copy of specified chromosome.

DoubleArrayChromosome ( IRandomNumberGenerator chromosomeGenerator, IRandomNumberGenerator mutationMultiplierGenerator, IRandomNumberGenerator mutationAdditionGenerator, double values ) : System

Initializes a new instance of the DoubleArrayChromosome class.

The constructor initializes the new chromosome with specified values.

DoubleArrayChromosome ( IRandomNumberGenerator chromosomeGenerator, IRandomNumberGenerator mutationMultiplierGenerator, IRandomNumberGenerator mutationAdditionGenerator, int length ) : System

Initializes a new instance of the DoubleArrayChromosome class.

The constructor initializes the new chromosome randomly by calling Generate method.

Generate ( ) : void

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

Mutate ( ) : void

Mutation operator.

The method performs chromosome's mutation, adding random number to chromosome's gene or multiplying the gene by random number. These random numbers are generated with help of mutation multiplier and mutation addition generators.

The exact type of mutation applied to the particular gene is selected randomly each time and depends on MutationBalancer. Before mutation is done a random number is generated in [0, 1] range - if the random number is smaller than MutationBalancer, then multiplication mutation is done, otherwise addition mutation.

ToString ( ) : string

Get string representation of the chromosome.

메소드 상세

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 crossover between two chromosomes, selecting randomly the exact type of crossover to perform, which depends on CrossoverBalancer. Before crossover is done a random number is generated in [0, 1] range - if the random number is smaller than CrossoverBalancer, then the first crossover type is used, otherwise second type is used.

The first crossover type is based on interchanging range of genes (array elements) between these chromosomes and is known as one point crossover. A crossover point is selected randomly and chromosomes interchange genes, which start from the selected point.

The second crossover type is aimed to produce one child, which genes' values are between corresponding genes of parents, and another child, which genes' values are outside of the range formed by corresponding genes of parents. Let take, for example, two genes with 1.0 and 3.0 valueû (of course chromosomes have more genes, but for simplicity lets think about one). First of all we randomly choose a factor in the [0, 1] range, let's take 0.4. Then, for each pair of genes (we have one pair) we calculate difference value, which is 2.0 in our case. In the result we’ll have two children – one between and one outside of the range formed by parents genes' values. We may have 1.8 and 3.8 children, or we may have 0.2 and 2.2 children. As we can see we add/subtract (chosen randomly) difference * factor. So, this gives us exploration in between and in near outside. The randomly chosen factor is applied to all genes of the chromosomes participating in crossover.

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

DoubleArrayChromosome() 공개 메소드

Initializes a new instance of the DoubleArrayChromosome class.

This is a copy constructor, which creates the exact copy of specified chromosome.

public DoubleArrayChromosome ( DoubleArrayChromosome source ) : System
source DoubleArrayChromosome Source chromosome to copy.
리턴 System

DoubleArrayChromosome() 공개 메소드

Initializes a new instance of the DoubleArrayChromosome class.

The constructor initializes the new chromosome with specified values.

Invalid length of values array.
public DoubleArrayChromosome ( IRandomNumberGenerator chromosomeGenerator, IRandomNumberGenerator mutationMultiplierGenerator, IRandomNumberGenerator mutationAdditionGenerator, double values ) : System
chromosomeGenerator IRandomNumberGenerator Chromosome generator - random number generator, which is /// used to initialize chromosome's genes, which is done by calling method /// or in class constructor.
mutationMultiplierGenerator IRandomNumberGenerator Mutation multiplier generator - random number /// generator, which is used to generate random multiplier values, which are used to /// multiply chromosome's genes during mutation.
mutationAdditionGenerator IRandomNumberGenerator Mutation addition generator - random number /// generator, which is used to generate random addition values, which are used to /// add to chromosome's genes during mutation.
values double Values used to initialize the chromosome.
리턴 System

DoubleArrayChromosome() 공개 메소드

Initializes a new instance of the DoubleArrayChromosome class.

The constructor initializes the new chromosome randomly by calling Generate method.

public DoubleArrayChromosome ( IRandomNumberGenerator chromosomeGenerator, IRandomNumberGenerator mutationMultiplierGenerator, IRandomNumberGenerator mutationAdditionGenerator, int length ) : System
chromosomeGenerator IRandomNumberGenerator Chromosome generator - random number generator, which is /// used to initialize chromosome's genes, which is done by calling method /// or in class constructor.
mutationMultiplierGenerator IRandomNumberGenerator Mutation multiplier generator - random number /// generator, which is used to generate random multiplier values, which are used to /// multiply chromosome's genes during mutation.
mutationAdditionGenerator IRandomNumberGenerator Mutation addition generator - random number /// generator, which is used to generate random addition values, which are used to /// add to chromosome's genes during mutation.
length int Chromosome's length in array elements, [2, ].
리턴 System

Generate() 공개 메소드

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

public Generate ( ) : void
리턴 void

Mutate() 공개 메소드

Mutation operator.

The method performs chromosome's mutation, adding random number to chromosome's gene or multiplying the gene by random number. These random numbers are generated with help of mutation multiplier and mutation addition generators.

The exact type of mutation applied to the particular gene is selected randomly each time and depends on MutationBalancer. Before mutation is done a random number is generated in [0, 1] range - if the random number is smaller than MutationBalancer, then multiplication mutation is done, otherwise addition mutation.

public Mutate ( ) : void
리턴 void

ToString() 공개 메소드

Get string representation of the chromosome.
public ToString ( ) : string
리턴 string

프로퍼티 상세

chromosomeGenerator 보호되어 있는 프로퍼티

Chromosome generator.

This random number generator is used to initialize chromosome's genes, which is done by calling Generate method.

protected IRandomNumberGenerator chromosomeGenerator
리턴 IRandomNumberGenerator

mutationAdditionGenerator 보호되어 있는 프로퍼티

Mutation addition generator.

This random number generator is used to generate random addition values, which are used to add to chromosome's genes during mutation.

protected IRandomNumberGenerator mutationAdditionGenerator
리턴 IRandomNumberGenerator

mutationMultiplierGenerator 보호되어 있는 프로퍼티

Mutation multiplier generator.

This random number generator is used to generate random multiplier values, which are used to multiply chromosome's genes during mutation.

protected IRandomNumberGenerator mutationMultiplierGenerator
리턴 IRandomNumberGenerator

val 보호되어 있는 프로퍼티

Chromosome's value.
protected double[] val
리턴 double[]