C# Class AForge.Genetic.BinaryChromosome

Binary chromosome, which supports length from 2 till 64.

The binary chromosome is the simplest type of chromosomes, which is represented by a set of bits. Maximum number of bits comprising the chromosome is 64.

Inheritance: ChromosomeBase
显示文件 Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Protected Properties

Property Type Description
length int
rand ThreadSafeRandom
val ulong

Public Methods

Method Description
BinaryChromosome ( int length ) : System

Initializes a new instance of the BinaryChromosome class.

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 range of bits between these chromosomes.

Generate ( ) : void

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

Mutate ( ) : void

Mutation operator.

The method performs chromosome's mutation, changing randomly one of its bits.

ToString ( ) : string

Get string representation of the chromosome.

Protected Methods

Method Description
BinaryChromosome ( BinaryChromosome source ) : System

Initializes a new instance of the BinaryChromosome class.

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

Method Details

BinaryChromosome() protected method

Initializes a new instance of the BinaryChromosome class.

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

protected BinaryChromosome ( BinaryChromosome source ) : System
source BinaryChromosome Source chromosome to copy.
return System

BinaryChromosome() public method

Initializes a new instance of the BinaryChromosome class.
public BinaryChromosome ( int length ) : System
length int Chromosome's length in bits, [2, ].
return System

Clone() public method

Clone the chromosome.

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

public Clone ( ) : IChromosome
return IChromosome

CreateNew() public method

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
return IChromosome

Crossover() public method

Crossover operator.

The method performs crossover between two chromosomes – interchanging range of bits between these chromosomes.

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

Generate() public method

Generate random chromosome value.

Regenerates chromosome's value using random number generator.

public Generate ( ) : void
return void

Mutate() public method

Mutation operator.

The method performs chromosome's mutation, changing randomly one of its bits.

public Mutate ( ) : void
return void

ToString() public method

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

Property Details

length protected_oe property

Chromosome's length in bits.
protected int length
return int

rand protected_oe static_oe property

Random number generator for chromosoms generation, crossover, mutation, etc.
protected static ThreadSafeRandom rand
return ThreadSafeRandom

val protected_oe property

Numerical chromosome's value.
protected ulong val
return ulong