|
1
|
|
package net.bmahe.genetics4j.neat.mutation.chromosome; |
|
2
|
|
|
|
3
|
|
import java.util.List; |
|
4
|
|
import java.util.function.Supplier; |
|
5
|
|
import java.util.random.RandomGenerator; |
|
6
|
|
|
|
7
|
|
import org.apache.commons.lang3.Validate; |
|
8
|
|
|
|
9
|
|
import net.bmahe.genetics4j.core.spec.mutation.CreepMutation; |
|
10
|
|
import net.bmahe.genetics4j.core.spec.statistics.distributions.Distribution; |
|
11
|
|
import net.bmahe.genetics4j.core.util.DistributionUtils; |
|
12
|
|
import net.bmahe.genetics4j.neat.Connection; |
|
13
|
|
import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; |
|
14
|
|
|
|
15
|
|
public class NeatChromosomeCreepMutationHandler extends AbstractNeatChromosomeConnectionMutationHandler<CreepMutation> { |
|
16
|
|
|
|
17
|
|
public NeatChromosomeCreepMutationHandler(final RandomGenerator _randomGenerator) { |
|
18
|
|
super(CreepMutation.class, _randomGenerator); |
|
19
|
|
} |
|
20
|
|
|
|
21
|
|
@Override |
|
22
|
|
protected List<Connection> mutateConnection(final CreepMutation creepMutation, final NeatChromosome neatChromosome, |
|
23
|
|
final Connection oldConnection, final int i) { |
|
24
|
|
Validate.notNull(creepMutation); |
|
25
|
|
Validate.notNull(neatChromosome); |
|
26
|
|
Validate.notNull(oldConnection); |
|
27
|
|
|
|
28
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection::builder → KILLED
|
final var connectionBuilder = Connection.builder() |
|
29
|
2
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::from → KILLED
2. mutateConnection : replaced call to net/bmahe/genetics4j/neat/Connection$Builder::from with receiver → KILLED
|
.from(oldConnection); |
|
30
|
|
|
|
31
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → KILLED
|
final var minValue = neatChromosome.getMinWeightValue(); |
|
32
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → KILLED
|
final var maxValue = neatChromosome.getMaxWeightValue(); |
|
33
|
|
|
|
34
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeCreepMutationHandler::getRandomGenerator → KILLED
|
final var randomGenerator = getRandomGenerator(); |
|
35
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/core/spec/mutation/CreepMutation::distribution → KILLED
|
final Distribution distribution = creepMutation.distribution(); |
|
36
|
|
|
|
37
|
|
final Supplier<Float> distributionValueSupplier = DistributionUtils |
|
38
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED
|
.distributionFloatValueSupplier(randomGenerator, minValue, maxValue, distribution); |
|
39
|
|
|
|
40
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → KILLED
|
float newWeight = neatChromosome.getConnections() |
|
41
|
1
1. mutateConnection : removed call to java/util/List::get → KILLED
|
.get(i) |
|
42
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection::weight → KILLED
|
.weight(); |
|
43
|
3
1. mutateConnection : removed call to java/util/function/Supplier::get → KILLED
2. mutateConnection : removed call to java/lang/Float::floatValue → KILLED
3. mutateConnection : Replaced float addition with subtraction → KILLED
|
newWeight += distributionValueSupplier.get(); |
|
44
|
4
1. mutateConnection : changed conditional boundary → SURVIVED
2. mutateConnection : removed conditional - replaced comparison check with false → KILLED
3. mutateConnection : negated conditional → KILLED
4. mutateConnection : removed conditional - replaced comparison check with true → KILLED
|
if (newWeight > maxValue) { |
|
45
|
|
newWeight = maxValue; |
|
46
|
4
1. mutateConnection : changed conditional boundary → SURVIVED
2. mutateConnection : removed conditional - replaced comparison check with true → KILLED
3. mutateConnection : removed conditional - replaced comparison check with false → KILLED
4. mutateConnection : negated conditional → KILLED
|
} else if (newWeight < minValue) { |
|
47
|
|
newWeight = minValue; |
|
48
|
|
} |
|
49
|
2
1. mutateConnection : replaced call to net/bmahe/genetics4j/neat/Connection$Builder::weight with receiver → KILLED
2. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::weight → KILLED
|
connectionBuilder.weight(newWeight); |
|
50
|
|
|
|
51
|
3
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::build → KILLED
2. mutateConnection : removed call to java/util/List::of → KILLED
3. mutateConnection : replaced return value with Collections.emptyList for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeCreepMutationHandler::mutateConnection → KILLED
|
return List.of(connectionBuilder.build()); |
|
52
|
|
} |
|
53
|
|
} |
| | Mutations |
| 28 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection::builder → KILLED
|
| 29 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::from → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] replaced call to net/bmahe/genetics4j/neat/Connection$Builder::from with receiver → KILLED
|
| 31 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → KILLED
|
| 32 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → KILLED
|
| 34 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeCreepMutationHandler::getRandomGenerator → KILLED
|
| 35 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/core/spec/mutation/CreepMutation::distribution → KILLED
|
| 38 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/core/util/DistributionUtils::distributionFloatValueSupplier → KILLED
|
| 40 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getConnections → KILLED
|
| 41 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to java/util/List::get → KILLED
|
| 42 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection::weight → KILLED
|
| 43 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to java/util/function/Supplier::get → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to java/lang/Float::floatValue → KILLED
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] Replaced float addition with subtraction → KILLED
|
| 44 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed conditional - replaced comparison check with false → KILLED
2.2 Location : mutateConnection Killed by : none changed conditional boundary → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()]
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] negated conditional → KILLED
4.4 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed conditional - replaced comparison check with true → KILLED
|
| 46 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed conditional - replaced comparison check with true → KILLED
2.2 Location : mutateConnection Killed by : none changed conditional boundary → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()]
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed conditional - replaced comparison check with false → KILLED
4.4 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] negated conditional → KILLED
|
| 49 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] replaced call to net/bmahe/genetics4j/neat/Connection$Builder::weight with receiver → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::weight → KILLED
|
| 51 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::build → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] removed call to java/util/List::of → KILLED
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeCreepMutationHandlerTest]/[method:mutateConnection()] replaced return value with Collections.emptyList for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeCreepMutationHandler::mutateConnection → KILLED
|