org.apache.commons.math.genetics
Class Chromosome
java.lang.Object
org.apache.commons.math.genetics.Chromosome
- All Implemented Interfaces:
- Comparable<Chromosome>, Fitness
- Direct Known Subclasses:
- AbstractListChromosome
public abstract class Chromosome
- extends Object
- implements Comparable<Chromosome>, Fitness
Individual in a population. Chromosomes are compared based on their fitness.
The chromosomes are IMMUTABLE, and so their fitness is also immutable and
therefore it can be cached.
- Since:
- 2.0
Method Summary |
int |
compareTo(Chromosome another)
Compares two chromosomes based on their fitness. |
double |
getFitness()
Access the fitness of this chromosome. |
void |
searchForFitnessUpdate(Population population)
Searches the population for a chromosome representing the same solution,
and if it finds one, updates the fitness to its value. |
Methods inherited from interface org.apache.commons.math.genetics.Fitness |
fitness |
Chromosome
public Chromosome()
getFitness
public double getFitness()
- Access the fitness of this chromosome. The bigger the fitness, the better
the chromosome.
Computation of fitness is usually very time-consuming task, therefore the
fitness is cached.
- Returns:
- the fitness.
compareTo
public int compareTo(Chromosome another)
- Compares two chromosomes based on their fitness. The bigger the fitness,
the better the chromosome.
- Specified by:
compareTo
in interface Comparable<Chromosome>
- Parameters:
another
- another chromosome to compare
- Returns:
- -1 if
another
is better than this
- 1 if
another
is worse than this
- 0 if the two chromosomes have the same fitness
searchForFitnessUpdate
public void searchForFitnessUpdate(Population population)
- Searches the population for a chromosome representing the same solution,
and if it finds one, updates the fitness to its value.
- Parameters:
population
- Population to search
jHepWork 3.0 ©