| 1 | package net.bmahe.genetics4j.core; | |
| 2 | ||
| 3 | import org.immutables.value.Value; | |
| 4 | ||
| 5 | /** | |
| 6 | * Represents an individual in an evolutionary algorithm, consisting of a genotype and its associated fitness value. | |
| 7 | * | |
| 8 | * <p>This interface encapsulates the fundamental concept of an individual solution in evolutionary computation, | |
| 9 | * combining genetic representation (genotype) with its evaluated performance (fitness). | |
| 10 | * | |
| 11 | * @param <T> the type of the fitness value, must be comparable for selection and ranking purposes | |
| 12 | */ | |
| 13 | @Value.Immutable | |
| 14 | public interface Individual<T extends Comparable<T>> { | |
| 15 | ||
| 16 | /** | |
| 17 | * Returns the genotype of this individual. | |
| 18 | * | |
| 19 | * @return the genetic representation containing chromosomes that define this individual's traits | |
| 20 | */ | |
| 21 | @Value.Parameter | |
| 22 | Genotype genotype(); | |
| 23 | ||
| 24 | /** | |
| 25 | * Returns the fitness value of this individual. | |
| 26 | * | |
| 27 | * @return the evaluated performance or quality measure of this individual's genotype | |
| 28 | */ | |
| 29 | @Value.Parameter | |
| 30 | T fitness(); | |
| 31 | ||
| 32 | /** | |
| 33 | * Creates a new individual with the specified genotype and fitness. | |
| 34 | * | |
| 35 | * @param <U> the type of the fitness value | |
| 36 | * @param genotype the genetic representation of the individual | |
| 37 | * @param fitness the evaluated fitness value of the individual | |
| 38 | * @return a new Individual instance with the given genotype and fitness | |
| 39 | */ | |
| 40 | static <U extends Comparable<U>> Individual<U> of(final Genotype genotype, final U fitness) { | |
| 41 |
2
1. of : replaced return value with null for net/bmahe/genetics4j/core/Individual::of → KILLED 2. of : removed call to net/bmahe/genetics4j/core/ImmutableIndividual::of → KILLED |
return ImmutableIndividual.of(genotype, fitness); |
| 42 | } | |
| 43 | } | |
Mutations | ||
| 41 |
1.1 2.2 |