public static class HelloWorldExample.StringChromosome extends AbstractListChromosome<Character>
Constructor and Description |
---|
StringChromosome(List<Character> repr) |
StringChromosome(String str) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkValidity(List<Character> repr)
Asserts that
representation can represent a valid chromosome. |
double |
fitness()
Compute the fitness.
|
List<Character> |
getStringRepresentation() |
HelloWorldExample.StringChromosome |
newFixedLengthChromosome(List<Character> repr)
Creates a new instance of the same class as
this is, with a given arrayRepresentation . |
String |
toString() |
getLength, getRepresentation
compareTo, findSameChromosome, getFitness, isSame, searchForFitnessUpdate
public StringChromosome(String str)
public double fitness()
Fitness
protected void checkValidity(List<Character> repr) throws MathIllegalArgumentException
AbstractListChromosome
representation
can represent a valid chromosome.checkValidity
in class AbstractListChromosome<Character>
repr
- representation of the chromosomeMathIllegalArgumentException
- iff the representation
can not represent a valid chromosomepublic HelloWorldExample.StringChromosome newFixedLengthChromosome(List<Character> repr)
AbstractListChromosome
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.
newFixedLengthChromosome
in class AbstractListChromosome<Character>
repr
- the inner array representation of the new chromosome.public String toString()
AbstractListChromosome
toString
in class AbstractListChromosome<Character>
Copyright © 2016 Hipparchus.org. All rights reserved.