public abstract class BinaryChromosome extends AbstractListChromosome<java.lang.Integer>
Constructor and Description |
---|
BinaryChromosome(java.lang.Integer[] representation)
Constructor.
|
BinaryChromosome(java.util.List<java.lang.Integer> representation)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkValidity(java.util.List<java.lang.Integer> chromosomeRepresentation)
Asserts that
representation can represent a valid chromosome. |
protected boolean |
isSame(Chromosome another)
Returns
true iff another has the same representation and therefore the same fitness. |
static java.util.List<java.lang.Integer> |
randomBinaryRepresentation(int length)
Returns a representation of a random binary array of length
length . |
getLength, getRepresentation, newFixedLengthChromosome, toString
compareTo, findSameChromosome, getFitness, searchForFitnessUpdate
public BinaryChromosome(java.util.List<java.lang.Integer> representation) throws InvalidRepresentationException
representation
- list of {0,1} values representing the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomepublic BinaryChromosome(java.lang.Integer[] representation) throws InvalidRepresentationException
representation
- array of {0,1} values representing the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomeprotected void checkValidity(java.util.List<java.lang.Integer> chromosomeRepresentation) throws InvalidRepresentationException
representation
can represent a valid chromosome.checkValidity
in class AbstractListChromosome<java.lang.Integer>
chromosomeRepresentation
- representation of the chromosomeInvalidRepresentationException
- iff the representation
can not represent a valid chromosomepublic static java.util.List<java.lang.Integer> randomBinaryRepresentation(int length)
length
.length
- length of the arraylength
protected boolean isSame(Chromosome another)
Chromosome
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.isSame
in class Chromosome
another
- chromosome to compareanother
is equivalent to this chromosomeCopyright (c) 2003-2014 Apache Software Foundation