| 1 | package net.bmahe.genetics4j.core.spec.selection; | |
| 2 | ||
| 3 | import java.util.Comparator; | |
| 4 | ||
| 5 | import org.immutables.value.Value; | |
| 6 | ||
| 7 | import net.bmahe.genetics4j.core.Individual; | |
| 8 | ||
| 9 | @Value.Immutable | |
| 10 | public abstract class Tournament<T extends Comparable<T>> implements SelectionPolicy { | |
| 11 | ||
| 12 | @Value.Parameter | |
| 13 | public abstract int numCandidates(); | |
| 14 | ||
| 15 | @Value.Default | |
| 16 | public Comparator<Individual<T>> comparator() { | |
| 17 |
2
1. comparator : replaced return value with null for net/bmahe/genetics4j/core/spec/selection/Tournament::comparator → KILLED 2. comparator : removed call to java/util/Comparator::comparing → KILLED |
return Comparator.comparing(Individual::fitness); |
| 18 | } | |
| 19 | ||
| 20 | /* | |
| 21 | * TODO: Enabling this makes immutables create non-compilable code | |
| 22 | * | |
| 23 | * @Value.Check protected void check() { Validate.isTrue(numCandidates() > 0); } | |
| 24 | */ | |
| 25 | ||
| 26 | public static class Builder<T extends Comparable<T>> extends ImmutableTournament.Builder<T> { | |
| 27 | } | |
| 28 | ||
| 29 | public static <U extends Comparable<U>> Tournament<U> of(final int numCandidates) { | |
| 30 |
2
1. of : replaced return value with null for net/bmahe/genetics4j/core/spec/selection/Tournament::of → KILLED 2. of : removed call to net/bmahe/genetics4j/core/spec/selection/ImmutableTournament::of → KILLED |
return ImmutableTournament.of(numCandidates); |
| 31 | } | |
| 32 | ||
| 33 | public static <U extends Comparable<U>> Tournament<U> of(final int numCandidates, | |
| 34 | final Comparator<Individual<U>> comparator) { | |
| 35 |
7
1. of : replaced return value with null for net/bmahe/genetics4j/core/spec/selection/Tournament::of → KILLED 2. of : replaced call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::numCandidates with receiver → KILLED 3. of : replaced call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::comparator with receiver → KILLED 4. of : removed call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::numCandidates → KILLED 5. of : removed call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::build → KILLED 6. of : removed call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::comparator → KILLED 7. of : removed call to net/bmahe/genetics4j/core/spec/selection/Tournament$Builder::<init> → KILLED |
return new Builder<U>().numCandidates(numCandidates).comparator(comparator).build(); |
| 36 | } | |
| 37 | ||
| 38 | } | |
Mutations | ||
| 17 |
1.1 2.2 |
|
| 30 |
1.1 2.2 |
|
| 35 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |