Package libai.genetics.chromosomes
Class Chromosome
- java.lang.Object
-
- libai.genetics.chromosomes.Chromosome
-
- Direct Known Subclasses:
BinaryChromosome,IntegerChromosome
public abstract class Chromosome extends java.lang.ObjectThe chromosome abstraction. Keeps the fitness and the chance to be selected by the roulette. Also has the methods to mutate and cross with another chromosome in an specific point.
-
-
Constructor Summary
Constructors Constructor Description Chromosome()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Chromosome[]cross(Chromosome b, int position)Split the genes bypositionand swap lower portion of this with the lower portion ofband return the new individualdoublegetChance()abstract ChromosomegetCopy()Copy constructordoublegetFitness()doublegetFitnessReal()abstract ChromosomegetInstance(int length, java.util.Random random)Generic constructorabstract Chromosomemutate(double pm)Change one gene of the chromosomevoidsetChance(double chance)voidsetFitness(double fitness)voidsetFitnessReal(double fitnessReal)
-
-
-
Method Detail
-
cross
public abstract Chromosome[] cross(Chromosome b, int position)
Split the genes bypositionand swap lower portion of this with the lower portion ofband return the new individual- Parameters:
b-bposition-position- Returns:
- new individual
-
mutate
public abstract Chromosome mutate(double pm)
Change one gene of the chromosome- Parameters:
pm-pm- Returns:
- mutated
Chromosome
-
getCopy
public abstract Chromosome getCopy()
Copy constructor- Returns:
- copy of this Chromosome
-
getInstance
public abstract Chromosome getInstance(int length, java.util.Random random)
Generic constructor- Parameters:
length-length- Returns:
Chromosomeinstance
-
getFitness
public double getFitness()
- Returns:
- the fitness
-
setFitness
public void setFitness(double fitness)
- Parameters:
fitness- The new fitness
-
getChance
public double getChance()
- Returns:
- the chance to be selected
-
setChance
public void setChance(double chance)
- Parameters:
chance- The new chance.
-
getFitnessReal
public double getFitnessReal()
- Returns:
- the fitnessReal
-
setFitnessReal
public void setFitnessReal(double fitnessReal)
- Parameters:
fitnessReal- The new fitnessReal.
-
-