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 |
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)
representation
- list of {0,1} values representing the chromosomepublic BinaryChromosome(java.lang.Integer[] representation)
representation
- array of {0,1} values representing the 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)
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-2013 Apache Software Foundation