public class Population extends Object
Constructor and Description |
---|
Population(int size) |
Modifier and Type | Method and Description |
---|---|
void |
calculateFitnessForAll(Function<Chromosome,Double> fitnessFunction)
Calculates fintness for all chromosomes with custom fitness function.
|
double |
calculateFitnessForChromosome(int idx,
Function<Chromosome,Double> fitnessFunction)
Calculates fitness for chromosome found by index with custom fitness function.
|
double |
getAverageFitness()
Returns the average fitness of population or Double.NaN if not all fitnesses are calculated for all chromosomes.
|
Chromosome |
getChromosome(int idx)
Returns an individual chromosome.
|
Chromosome |
getChromosome(Integer idx)
Returns the chromosome by given index.
|
double |
getTotalFitness()
Returns the total fitness value of population or Double.NaN if not all fitnesses are calculated for all chromosomes.
|
Chromosome[] |
selectBestKChromosome(int k)
Selects the top K chromosomes by fitness value from the smallest to the largest.
|
void |
setChromosome(int idx,
Chromosome chromosome)
Sets the chromsome for given index.
|
void |
setFitness(Integer idx,
Double fitness)
Sets the fitness value for chromosome with the given index.
|
int |
size()
Returns the size of population.
|
public Chromosome getChromosome(int idx)
idx
- Index of chromosome.public double calculateFitnessForChromosome(int idx, Function<Chromosome,Double> fitnessFunction)
idx
- Index.fitnessFunction
- Fitness function.public void calculateFitnessForAll(Function<Chromosome,Double> fitnessFunction)
fitnessFunction
- Fitness function.public void setChromosome(int idx, Chromosome chromosome)
idx
- Index.chromosome
- Chromosome.public Chromosome getChromosome(Integer idx)
idx
- Index.public Chromosome[] selectBestKChromosome(int k)
k
- The amount of top chromosome with highest value of the fitness.
Returns null if not all fitnesses are calculated for all chromosomes.public double getTotalFitness()
public double getAverageFitness()
public int size()
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024