| 1 |  | package net.bmahe.genetics4j.core.replacement; | 
| 2 |  | 
 | 
| 3 |  | import java.util.Comparator; | 
| 4 |  | import java.util.List; | 
| 5 |  | import java.util.Objects; | 
| 6 |  | import java.util.stream.IntStream; | 
| 7 |  | 
 | 
| 8 |  | import org.apache.commons.lang3.Validate; | 
| 9 |  | 
 | 
| 10 |  | import net.bmahe.genetics4j.core.Genotype; | 
| 11 |  | import net.bmahe.genetics4j.core.Population; | 
| 12 |  | import net.bmahe.genetics4j.core.selection.Selector; | 
| 13 |  | import net.bmahe.genetics4j.core.spec.AbstractEAConfiguration; | 
| 14 |  | import net.bmahe.genetics4j.core.spec.replacement.DeleteNLast; | 
| 15 |  | 
 | 
| 16 |  | public class DeleteNLastImpl<T extends Comparable<T>> implements ReplacementStrategyImplementor<T> { | 
| 17 |  | 
 | 
| 18 |  | 	private final DeleteNLast deleteNLastSpec; | 
| 19 |  | 	private final Selector<T> offspringSelector; | 
| 20 |  | 
 | 
| 21 |  | 	public DeleteNLastImpl(final DeleteNLast _deleteNLastSpec, final Selector<T> _offspringSelector) { | 
| 22 |  | 		Objects.requireNonNull(_deleteNLastSpec); | 
| 23 |  | 		Objects.requireNonNull(_offspringSelector); | 
| 24 |  | 
 | 
| 25 | 1
1. <init> : Removed assignment to member variable deleteNLastSpec → KILLED 
 | 		this.deleteNLastSpec = _deleteNLastSpec; | 
| 26 | 1
1. <init> : Removed assignment to member variable offspringSelector → KILLED 
 | 		this.offspringSelector = _offspringSelector; | 
| 27 |  | 	} | 
| 28 |  | 
 | 
| 29 |  | 	@Override | 
| 30 |  | 	public Population<T> select(final AbstractEAConfiguration<T> eaConfiguration, final long generation, | 
| 31 |  | 			final int numIndividuals, final List<Genotype> population, final List<T> populationScores, | 
| 32 |  | 			final List<Genotype> offsprings, final List<T> offspringScores) { | 
| 33 |  | 		Objects.requireNonNull(eaConfiguration); | 
| 34 |  | 		Validate.isTrue(generation >= 0); | 
| 35 |  | 		Validate.isTrue(numIndividuals > 0); | 
| 36 |  | 		Objects.requireNonNull(population); | 
| 37 |  | 		Objects.requireNonNull(populationScores); | 
| 38 |  | 		Validate.isTrue(population.size() == populationScores.size()); | 
| 39 |  | 		Objects.requireNonNull(offsprings); | 
| 40 |  | 		Objects.requireNonNull(offspringScores); | 
| 41 |  | 		Validate.isTrue(offsprings.size() == offspringScores.size()); | 
| 42 |  | 
 | 
| 43 | 1
1. select : removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::fitnessComparator → KILLED 
 | 		final Comparator<T> populationComparator = eaConfiguration.fitnessComparator(); | 
| 44 |  | 
 | 
| 45 | 1
1. select : removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED 
 | 		final Population<T> selected = new Population<>(); | 
| 46 |  | 
 | 
| 47 | 2
1. select : removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::weakRatio → KILLED 2. select : Replaced double multiplication with division → KILLED
 
 | 		final int weakestN = (int) (numIndividuals * deleteNLastSpec.weakRatio()); | 
| 48 |  | 
 | 
| 49 | 3
1. select : removed call to java/util/stream/IntStream::range → KILLED 2. select : removed call to java/util/List::size → KILLED
 3. select : Substituted 0 with 1 → KILLED
 
 | 		IntStream.range(0, populationScores.size()) | 
| 50 | 1
1. select : removed call to java/util/stream/IntStream::boxed → KILLED 
 | 				.boxed() | 
| 51 | 8
1. lambda$select$0 : removed call to java/lang/Integer::intValue → SURVIVED 2. lambda$select$0 : replaced int return with 0 for net/bmahe/genetics4j/core/replacement/DeleteNLastImpl::lambda$select$0 → KILLED
 3. lambda$select$0 : removed call to java/util/List::get → KILLED
 4. select : replaced call to java/util/stream/Stream::sorted with receiver → KILLED
 5. lambda$select$0 : removed call to java/lang/Integer::intValue → KILLED
 6. lambda$select$0 : removed call to java/util/List::get → KILLED
 7. select : removed call to java/util/stream/Stream::sorted → KILLED
 8. lambda$select$0 : removed call to java/util/Comparator::compare → KILLED
 
 | 				.sorted((a, b) -> populationComparator.compare(populationScores.get(a), populationScores.get(b))) | 
| 52 | 2
1. select : removed call to java/util/stream/Stream::skip → KILLED 2. select : replaced call to java/util/stream/Stream::skip with receiver → KILLED
 
 | 				.skip(weakestN) | 
| 53 | 1
1. select : removed call to java/util/stream/Stream::forEach → KILLED 
 | 				.forEach(index -> { | 
| 54 | 5
1. lambda$select$1 : removed call to java/lang/Integer::intValue → SURVIVED 2. lambda$select$1 : removed call to net/bmahe/genetics4j/core/Population::add → KILLED
 3. lambda$select$1 : removed call to java/util/List::get → KILLED
 4. lambda$select$1 : removed call to java/lang/Integer::intValue → KILLED
 5. lambda$select$1 : removed call to java/util/List::get → KILLED
 
 | 					selected.add(population.get(index), populationScores.get(index)); | 
| 55 |  | 				}); | 
| 56 |  | 
 | 
| 57 |  | 		final Population<T> selectedOffspring = offspringSelector | 
| 58 | 1
1. select : removed call to net/bmahe/genetics4j/core/selection/Selector::select → KILLED 
 | 				.select(eaConfiguration, generation, weakestN, offsprings, offspringScores); | 
| 59 | 1
1. select : removed call to net/bmahe/genetics4j/core/Population::addAll → KILLED 
 | 		selected.addAll(selectedOffspring); | 
| 60 |  | 
 | 
| 61 | 1
1. select : replaced return value with null for net/bmahe/genetics4j/core/replacement/DeleteNLastImpl::select → KILLED 
 | 		return selected; | 
| 62 |  | 	} | 
| 63 |  | } | 
|  |  | Mutations | 
| 25 |  | 1.1Location : <init>
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] Removed assignment to member variable deleteNLastSpec → KILLED
 | 
| 26 |  | 1.1Location : <init>
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] Removed assignment to member variable offspringSelector → KILLED
 | 
| 43 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/spec/AbstractEAConfiguration::fitnessComparator → KILLED
 | 
| 45 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/Population::<init> → KILLED
 | 
| 47 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/spec/replacement/DeleteNLast::weakRatio → KILLED
 2.2Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] Replaced double multiplication with division → KILLED
 | 
| 49 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/stream/IntStream::range → KILLED
 2.2Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/List::size → KILLED
 3.3Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] Substituted 0 with 1 → KILLED
 | 
| 50 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/stream/IntStream::boxed → KILLED
 | 
| 51 |  | 1.1Location : lambda$select$0
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] replaced int return with 0 for net/bmahe/genetics4j/core/replacement/DeleteNLastImpl::lambda$select$0 → KILLED
 2.2Location : lambda$select$0
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/List::get → KILLED
 3.3Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] replaced call to java/util/stream/Stream::sorted with receiver → KILLED
 4.4Location : lambda$select$0
 Killed by : none removed call to java/lang/Integer::intValue → SURVIVED
Covering tests
 Covered by tests:
 
net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]5.5Location : lambda$select$0
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/lang/Integer::intValue → KILLED
 6.6Location : lambda$select$0
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/List::get → KILLED
 7.7Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/stream/Stream::sorted → KILLED
 8.8Location : lambda$select$0
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/Comparator::compare → KILLED
 | 
| 52 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/stream/Stream::skip → KILLED
 2.2Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] replaced call to java/util/stream/Stream::skip with receiver → KILLED
 | 
| 53 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/stream/Stream::forEach → KILLED
 | 
| 54 |  | 1.1Location : lambda$select$1
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/Population::add → KILLED
 2.2Location : lambda$select$1
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/List::get → KILLED
 3.3Location : lambda$select$1
 Killed by : none removed call to java/lang/Integer::intValue → SURVIVED
Covering tests
 Covered by tests:
 
net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()]4.4Location : lambda$select$1
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/lang/Integer::intValue → KILLED
 5.5Location : lambda$select$1
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to java/util/List::get → KILLED
 | 
| 58 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/selection/Selector::select → KILLED
 | 
| 59 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] removed call to net/bmahe/genetics4j/core/Population::addAll → KILLED
 | 
| 61 |  | 1.1Location : select
 Killed by : net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.core.replacement.DeleteNLastImplTest]/[method:select()] replaced return value with null for net/bmahe/genetics4j/core/replacement/DeleteNLastImpl::select → KILLED
 |