org.apache.commons.math3.genetics
T
- type of the representation listpublic abstract class AbstractListChromosome<T> extends Chromosome
Modifier and Type | Field and Description |
---|---|
private java.util.List<T> |
representation
List representing the chromosome
|
Constructor and Description |
---|
AbstractListChromosome(java.util.List<T> representation)
Constructor.
|
AbstractListChromosome(T[] representation)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkValidity(java.util.List<T> chromosomeRepresentation)
Asserts that
representation can represent a valid chromosome. |
int |
getLength()
Returns the length of the chromosome.
|
protected java.util.List<T> |
getRepresentation()
Returns the (immutable) inner representation of the chromosome.
|
abstract AbstractListChromosome<T> |
newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)
Creates a new instance of the same class as
this is, with a given arrayRepresentation . |
java.lang.String |
toString() |
compareTo, findSameChromosome, getFitness, isSame, searchForFitnessUpdate
private final java.util.List<T> representation
public AbstractListChromosome(java.util.List<T> representation) throws InvalidRepresentationException
representation
- inner representation of the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomepublic AbstractListChromosome(T[] representation) throws InvalidRepresentationException
representation
- inner representation of the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomeprotected abstract void checkValidity(java.util.List<T> chromosomeRepresentation) throws InvalidRepresentationException
representation
can represent a valid chromosome.chromosomeRepresentation
- representation of the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomeprotected java.util.List<T> getRepresentation()
public int getLength()
public abstract AbstractListChromosome<T> newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)
this
is, with a given arrayRepresentation
.
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.
chromosomeRepresentation
- the inner array representation of the new chromosome.public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2003-2013 Apache Software Foundation