Package org.jppf.ga
Interface Chromosome
- All Superinterfaces:
Comparable<Chromosome>,Serializable
- All Known Implementing Classes:
AbstractChromosome
Interface for a chromosome.
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptiondoubleCompute the fitness of this chromosome.crossover(Chromosome mate, int position) Perform the crossover of this chromosome with one of its mates.doubleGet the fitness of this chromosome.Gene[]getGenes()Get the genes of this chromosome.intgetSize()Get the number of genes.booleanisValid()mutate()Perform the mutation of this chromosome.voidsetFitness(double fitness) Set the fitness of this chromosome.Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getSize
int getSize()Get the number of genes.- Returns:
- the number of genes as an int.
-
getGenes
Gene[] getGenes()Get the genes of this chromosome.- Returns:
- an array of
Geneinstances.
-
getFitness
double getFitness()Get the fitness of this chromosome.- Returns:
- the fitness as a double value.
-
setFitness
void setFitness(double fitness) Set the fitness of this chromosome.- Parameters:
fitness- the fitness as a double value.
-
computeFitness
double computeFitness()Compute the fitness of this chromosome.- Returns:
- the fitness as a double value.
-
mutate
Chromosome mutate()Perform the mutation of this chromosome.- Returns:
- the mutated chromosome.
-
crossover
Perform the crossover of this chromosome with one of its mates.- Parameters:
mate- the chromosome to crossover with.position- determines where the crossover should occur in the gene sequence.- Returns:
- an array of 2 descendants.
-
isValid
boolean isValid()- Returns:
- whether this chromosome is valid.
-