Package net.bmahe.genetics4j.core
Interface Fitness<T extends Comparable<T>>
- Type Parameters:
T
- the type of the fitness value, must be comparable for selection operations
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for evaluating the fitness of a genotype in an evolutionary algorithm.
The fitness function is a crucial component of evolutionary algorithms as it determines the quality or performance of individual solutions. It maps a genotype to a fitness value that can be used for selection, ranking, and determining evolutionary progress.
Implementations should be:
- Deterministic: The same genotype should always produce the same fitness value
- Thread-safe: May be called concurrently from multiple threads
- Fast: Called frequently during evolution, performance matters
Common fitness function patterns:
- Minimization: Lower values indicate better solutions (errors, costs)
- Maximization: Higher values indicate better solutions (profits, accuracy)
- Multi-objective: Use FitnessVector from the MOO module for multiple objectives
- See Also:
-
Method Summary
-
Method Details
-
compute
Computes the fitness value for the specified genotype.This method should evaluate how well the genotype solves the problem and return a comparable fitness value. The interpretation of "better" depends on whether the optimization is for minimization or maximization.
- Parameters:
genotype
- the genotype to evaluate- Returns:
- the fitness value representing the quality of the genotype
- Throws:
RuntimeException
- if evaluation fails due to invalid genotype or computation error
-