Package org.apache.commons.math.genetics
Class AbstractListChromosome<T>
- java.lang.Object
-
- org.apache.commons.math.genetics.Chromosome
-
- org.apache.commons.math.genetics.AbstractListChromosome<T>
-
- Type Parameters:
T
- type of the representation list
- All Implemented Interfaces:
java.lang.Comparable<Chromosome>
,Fitness
- Direct Known Subclasses:
BinaryChromosome
,RandomKey
public abstract class AbstractListChromosome<T> extends Chromosome
Chromosome represented by an immutable list of a fixed length.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractListChromosome(java.util.List<T> representation)
Constructor.AbstractListChromosome(T[] representation)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getLength()
Returns the length of the chromosome.abstract AbstractListChromosome<T>
newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)
Creates a new instance of the same class asthis
is, with a givenarrayRepresentation
.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.math.genetics.Chromosome
compareTo, getFitness, searchForFitnessUpdate
-
-
-
-
Constructor Detail
-
AbstractListChromosome
public AbstractListChromosome(java.util.List<T> representation)
Constructor.- Parameters:
representation
- inner representation of the chromosome
-
AbstractListChromosome
public AbstractListChromosome(T[] representation)
Constructor.- Parameters:
representation
- inner representation of the chromosome
-
-
Method Detail
-
getLength
public int getLength()
Returns the length of the chromosome.- Returns:
- the length of the chromosome
-
newFixedLengthChromosome
public abstract AbstractListChromosome<T> newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)
Creates a new instance of the same class asthis
is, with a givenarrayRepresentation
. This is needed in crossover and mutation operators, where we need a new instance of the same class, but with different array representation. Usually, this method just calls a constructor of the class.- Parameters:
chromosomeRepresentation
- the inner array representation of the new chromosome.- Returns:
- new instance extended from FixedLengthChromosome with the given arrayRepresentation
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-