Class BinaryIndividual
Represents an individual encoded with binary genes, suitable for classic GA problems.
public class BinaryIndividual : IEvolvable<BinaryGene, double>
- Inheritance
-
BinaryIndividual
- Implements
- Inherited Members
Constructors
BinaryIndividual(ICollection<BinaryGene>)
Creates a binary individual with the specified genes.
public BinaryIndividual(ICollection<BinaryGene> genes)
Parameters
genesICollection<BinaryGene>The genes to initialize with.
BinaryIndividual(int, Random)
Creates a new binary individual with the specified chromosome length.
public BinaryIndividual(int length, Random random)
Parameters
lengthintThe number of genes (bits) in the chromosome.
randomRandomRandom number generator for initialization.
Methods
Clone()
Creates a deep clone of this individual.
public IEvolvable<BinaryGene, double> Clone()
Returns
- IEvolvable<BinaryGene, double>
A clone of this individual.
GetFitness()
Gets the fitness of this individual.
public double GetFitness()
Returns
- double
The fitness score.
GetGenes()
Gets the genes of this individual.
public ICollection<BinaryGene> GetGenes()
Returns
- ICollection<BinaryGene>
The collection of genes.
GetValueAsInt()
Gets the binary value of this individual as an integer.
public int GetValueAsInt()
Returns
- int
The integer value represented by this binary string.
GetValueAsNormalizedDouble()
Gets the binary value of this individual as a double in the range [0,1].
public double GetValueAsNormalizedDouble()
Returns
- double
A double value between 0 and 1.
GetValueMapped(double, double)
Maps the binary string to a double value within the specified range.
public double GetValueMapped(double min, double max)
Parameters
Returns
- double
A double value between min and max.
SetFitness(double)
Sets the fitness of this individual.
public void SetFitness(double fitness)
Parameters
fitnessdoubleThe fitness score to set.
SetGenes(ICollection<BinaryGene>)
Sets the genes of this individual.
public void SetGenes(ICollection<BinaryGene> genes)
Parameters
genesICollection<BinaryGene>The genes to set.