NeatChromosomeDeleteConnection.java

1
package net.bmahe.genetics4j.neat.mutation.chromosome;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Objects;
6
import java.util.random.RandomGenerator;
7
8
import org.apache.commons.lang3.Validate;
9
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.Logger;
11
12
import net.bmahe.genetics4j.core.chromosomes.Chromosome;
13
import net.bmahe.genetics4j.core.mutation.chromosome.ChromosomeMutationHandler;
14
import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
15
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
16
import net.bmahe.genetics4j.neat.Connection;
17
import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome;
18
import net.bmahe.genetics4j.neat.spec.NeatChromosomeSpec;
19
import net.bmahe.genetics4j.neat.spec.mutation.DeleteConnection;
20
21
public class NeatChromosomeDeleteConnection implements ChromosomeMutationHandler<NeatChromosome> {
22
23
	public static final Logger logger = LogManager.getLogger(NeatChromosomeDeleteConnection.class);
24
25
	private final RandomGenerator randomGenerator;
26
27
	public NeatChromosomeDeleteConnection(final RandomGenerator _randomGenerator) {
28
		Objects.requireNonNull(_randomGenerator);
29
30 1 1. <init> : Removed assignment to member variable randomGenerator → KILLED
		this.randomGenerator = _randomGenerator;
31
	}
32
33
	@Override
34
	public boolean canHandle(final MutationPolicy mutationPolicy, final ChromosomeSpec chromosome) {
35
		Objects.requireNonNull(mutationPolicy);
36
		Objects.requireNonNull(chromosome);
37
38 9 1. canHandle : negated conditional → KILLED
2. canHandle : replaced boolean return with true for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeDeleteConnection::canHandle → KILLED
3. canHandle : negated conditional → KILLED
4. canHandle : removed conditional - replaced equality check with false → KILLED
5. canHandle : removed conditional - replaced equality check with true → KILLED
6. canHandle : removed conditional - replaced equality check with false → KILLED
7. canHandle : Substituted 1 with 0 → KILLED
8. canHandle : Substituted 0 with 1 → KILLED
9. canHandle : removed conditional - replaced equality check with true → KILLED
		return mutationPolicy instanceof DeleteConnection && chromosome instanceof NeatChromosomeSpec;
39
	}
40
41
	@Override
42
	public NeatChromosome mutate(final MutationPolicy mutationPolicy, final Chromosome chromosome) {
43
		Objects.requireNonNull(mutationPolicy);
44
		Objects.requireNonNull(chromosome);
45
		Validate.isInstanceOf(DeleteConnection.class, mutationPolicy);
46
		Validate.isInstanceOf(NeatChromosome.class, chromosome);
47
48
		final var neatChromosome = (NeatChromosome) chromosome;
49 1 1. mutate : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → SURVIVED
		final var minValue = neatChromosome.getMinWeightValue();
50 1 1. mutate : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → SURVIVED
		final var maxValue = neatChromosome.getMaxWeightValue();
51
52 1 1. mutate : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → KILLED
		final var oldConnections = neatChromosome.getConnections();
53 1 1. mutate : removed call to java/util/ArrayList::<init> → KILLED
		final List<Connection> newConnections = new ArrayList<>(oldConnections);
54
55 4 1. mutate : removed conditional - replaced equality check with false → KILLED
2. mutate : removed conditional - replaced equality check with true → KILLED
3. mutate : removed call to java/util/List::isEmpty → KILLED
4. mutate : negated conditional → KILLED
		if (oldConnections.isEmpty() == false) {
56 3 1. mutate : removed call to java/util/List::size → SURVIVED
2. mutate : removed call to java/util/random/RandomGenerator::nextInt → KILLED
3. mutate : replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED
			final int connectionToDeleteIndex = randomGenerator.nextInt(oldConnections.size());
57 1 1. mutate : removed call to java/util/List::remove → KILLED
			newConnections.remove(connectionToDeleteIndex);
58
		}
59
60 3 1. mutate : replaced return value with null for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeDeleteConnection::mutate → KILLED
2. mutate : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::<init> → KILLED
3. mutate : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getNodeLayout → KILLED
		return new NeatChromosome(neatChromosome.getNodeLayout(), minValue, maxValue, newConnections);
61
	}
62
}

Mutations

30

1.1
Location : <init>
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateConnectionExist()]
Removed assignment to member variable randomGenerator → KILLED

38

1.1
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
negated conditional → KILLED

2.2
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
replaced boolean return with true for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeDeleteConnection::canHandle → KILLED

3.3
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
negated conditional → KILLED

4.4
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

5.5
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
removed conditional - replaced equality check with true → KILLED

6.6
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
removed conditional - replaced equality check with false → KILLED

7.7
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
Substituted 1 with 0 → KILLED

8.8
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
Substituted 0 with 1 → KILLED

9.9
Location : canHandle
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:canHandle()]
removed conditional - replaced equality check with true → KILLED

49

1.1
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → SURVIVED
Covering tests

50

1.1
Location : mutate
Killed by : none
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → SURVIVED
Covering tests

52

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → KILLED

53

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed call to java/util/ArrayList::<init> → KILLED

55

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateConnectionExist()]
removed conditional - replaced equality check with false → KILLED

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed conditional - replaced equality check with true → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed call to java/util/List::isEmpty → KILLED

4.4
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
negated conditional → KILLED

56

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateConnectionExist()]
removed call to java/util/random/RandomGenerator::nextInt → KILLED

2.2
Location : mutate
Killed by : none
removed call to java/util/List::size → SURVIVED
Covering tests

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateConnectionExist()]
replaced call to java/util/random/RandomGenerator::nextInt with argument → KILLED

57

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateConnectionExist()]
removed call to java/util/List::remove → KILLED

60

1.1
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
replaced return value with null for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeDeleteConnection::mutate → KILLED

2.2
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::<init> → KILLED

3.3
Location : mutate
Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeDeleteConnectionTest]/[method:mutateEmptyConnection()]
removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getNodeLayout → KILLED

Active mutators

Tests examined


Report generated by PIT 1.23.1 support