Interface Chromosome<T>
- All Superinterfaces:
Comparable<Chromosome<T>>
- All Known Implementing Classes:
RealChromosome
Represents a single candidate solution in the genetic algorithm.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptiondefault intcompareTo(Chromosome<T> other) List<Chromosome<T>> crossover(Chromosome<T> other) Creates a new chromosome by crossing over with another.doubleCalculates the fitness of this chromosome.getGenes()Gets the sequence of genes.mutate(double probability) Mutates this chromosome.
-
Method Details
-
getGenes
-
getFitness
double getFitness()Calculates the fitness of this chromosome. Higher fitness is better.- Returns:
- the fitness score
-
crossover
Creates a new chromosome by crossing over with another.- Parameters:
other- the partner chromosome- Returns:
- a pair of new chromosomes (offspring)
-
mutate
Mutates this chromosome.- Parameters:
probability- chance of mutation per gene- Returns:
- a new mutated chromosome
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-