Top Description Constructors Methods
org.apache.commons.math3.genetics

public abstract Class BinaryChromosome

extends AbstractListChromosome<Integer>
Class Inheritance
Imports
java.util.ArrayList, .List, org.apache.commons.math3.exception.util.LocalizedFormats

Chromosome represented by a vector of 0s and 1s.
Since
2.0

Constructor Summary

AccessConstructor and Description
public
BinaryChromosome(List<Integer>
list of {0,1} values representing the chromosome
representation
)

Constructor.

public
BinaryChromosome(Integer[]
array of {0,1} values representing the chromosome
representation
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
checkValidity(List<Integer>
representation of the chromosome
chromosomeRepresentation
)

Implements abstract org.apache.commons.math3.genetics.AbstractListChromosome.checkValidity.

Asserts that representation can represent a valid chromosome.

protected boolean
isSame(Chromosome
chromosome to compare
another
)

Overrides org.apache.commons.math3.genetics.Chromosome.isSame.

Returns true iff another has the same representation and therefore the same fitness.

public static List<Integer>

Returns:

a random binary array of length length
randomBinaryRepresentation
(int
length of the array
length
)

Returns a representation of a random binary array of length length.

Inherited from org.apache.commons.math3.genetics.AbstractListChromosome:
getLengthgetRepresentationnewFixedLengthChromosometoString

Constructor Detail

BinaryChromosomeback to summary
public BinaryChromosome(List<Integer> representation) throws InvalidRepresentationException

Constructor.

Parameters
representation:List<Integer>

list of {0,1} values representing the chromosome

Exceptions
InvalidRepresentationException:
iff the representation can not represent a valid chromosome
BinaryChromosomeback to summary
public BinaryChromosome(Integer[] representation) throws InvalidRepresentationException

Constructor.

Parameters
representation:Integer[]

array of {0,1} values representing the chromosome

Exceptions
InvalidRepresentationException:
iff the representation can not represent a valid chromosome

Method Detail

checkValidityback to summary
protected void checkValidity(List<Integer> chromosomeRepresentation) throws InvalidRepresentationException

Implements abstract org.apache.commons.math3.genetics.AbstractListChromosome.checkValidity.

Doc from org.apache.commons.math3.genetics.AbstractListChromosome.checkValidity.

Asserts that representation can represent a valid chromosome.

Parameters
chromosomeRepresentation:List<Integer>

representation of the chromosome

Annotations
@Override
Exceptions
InvalidRepresentationException:
iff the representation can not represent a valid chromosome
isSameback to summary
protected boolean isSame(Chromosome another)

Overrides org.apache.commons.math3.genetics.Chromosome.isSame.

Doc from org.apache.commons.math3.genetics.Chromosome.isSame.

Returns true iff another has the same representation and therefore the same fitness. By default, it returns false -- override it in your implementation if you need it.

Parameters
another:Chromosome

chromosome to compare

Returns:boolean

true if another is equivalent to this chromosome

Annotations
@Override
randomBinaryRepresentationback to summary
public static List<Integer> randomBinaryRepresentation(int length)

Returns a representation of a random binary array of length length.

Parameters
length:int

length of the array

Returns:List<Integer>

a random binary array of length length