Table of Contents

Class BinaryIndividual

Namespace
AiDotNet.Genetics
Assembly
AiDotNet.dll

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

genes ICollection<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

length int

The number of genes (bits) in the chromosome.

random Random

Random 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

min double

The minimum value of the range.

max double

The maximum value of the range.

Returns

double

A double value between min and max.

SetFitness(double)

Sets the fitness of this individual.

public void SetFitness(double fitness)

Parameters

fitness double

The fitness score to set.

SetGenes(ICollection<BinaryGene>)

Sets the genes of this individual.

public void SetGenes(ICollection<BinaryGene> genes)

Parameters

genes ICollection<BinaryGene>

The genes to set.