Package org.jppf.ga
Class AbstractChromosome
java.lang.Object
org.jppf.ga.AbstractChromosome
- All Implemented Interfaces:
Serializable,Comparable<Chromosome>,Chromosome
Common abstract super class for chromosme implementations.
- Author:
- Laurent Cohen
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(Chromosome other) doubleGet the fitness of this chromosome.Gene[]getGenes()Get the genes of this chromosome.intgetSize()Get the number of genes.booleanisValid()voidsetFitness(double fitness) Set the fitness of this chromosome.voidSet the genes of this chromosome.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jppf.ga.Chromosome
computeFitness, crossover, mutate
-
Field Details
-
fitness
protected double fitnessThe fitness of this chromosme. -
genes
The genes of this chromosome. -
size
protected int sizeThe size (number of genes) of this chromosome. -
random
A random number generator.
-
-
Constructor Details
-
AbstractChromosome
public AbstractChromosome()
-
-
Method Details
-
getFitness
public double getFitness()Description copied from interface:ChromosomeGet the fitness of this chromosome.- Specified by:
getFitnessin interfaceChromosome- Returns:
- the fitness as a double value.
-
setFitness
public void setFitness(double fitness) Description copied from interface:ChromosomeSet the fitness of this chromosome.- Specified by:
setFitnessin interfaceChromosome- Parameters:
fitness- the fitness as a double value.
-
getGenes
Description copied from interface:ChromosomeGet the genes of this chromosome.- Specified by:
getGenesin interfaceChromosome- Returns:
- an array of
Geneinstances.
-
setGenes
Set the genes of this chromosome.- Parameters:
genes- the array of genes to set.
-
getSize
public int getSize()Description copied from interface:ChromosomeGet the number of genes.- Specified by:
getSizein interfaceChromosome- Returns:
- the number of genes as an int.
-
compareTo
- Specified by:
compareToin interfaceComparable<Chromosome>
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceChromosome- Returns:
- whether this chromosome is valid.
-