1
|
|
package net.bmahe.genetics4j.neat.mutation.chromosome; |
2
|
|
|
3
|
|
import java.util.List; |
4
|
|
import java.util.random.RandomGenerator; |
5
|
|
|
6
|
|
import org.apache.commons.lang3.Validate; |
7
|
|
|
8
|
|
import net.bmahe.genetics4j.core.spec.mutation.RandomMutation; |
9
|
|
import net.bmahe.genetics4j.neat.Connection; |
10
|
|
import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; |
11
|
|
|
12
|
|
public class NeatChromosomeRandomMutationHandler |
13
|
|
extends AbstractNeatChromosomeConnectionMutationHandler<RandomMutation> |
14
|
|
{ |
15
|
|
|
16
|
|
public NeatChromosomeRandomMutationHandler(final RandomGenerator _randomGenerator) { |
17
|
|
super(RandomMutation.class, _randomGenerator); |
18
|
|
} |
19
|
|
|
20
|
|
@Override |
21
|
|
protected List<Connection> mutateConnection(final RandomMutation randomMutation, final NeatChromosome neatChromosome, |
22
|
|
final Connection oldConnection, final int i) { |
23
|
|
Validate.notNull(randomMutation); |
24
|
|
Validate.notNull(neatChromosome); |
25
|
|
Validate.notNull(oldConnection); |
26
|
|
|
27
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection::builder → KILLED
|
final var connectionBuilder = Connection.builder() |
28
|
2
1. mutateConnection : replaced call to net/bmahe/genetics4j/neat/Connection$Builder::from with receiver → KILLED
2. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::from → KILLED
|
.from(oldConnection); |
29
|
|
|
30
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → KILLED
|
final var minValue = neatChromosome.getMinWeightValue(); |
31
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → SURVIVED
|
final var maxValue = neatChromosome.getMaxWeightValue(); |
32
|
|
|
33
|
1
1. mutateConnection : removed call to net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeRandomMutationHandler::getRandomGenerator → KILLED
|
final var randomGenerator = getRandomGenerator(); |
34
|
|
|
35
|
|
// TODO use distribution |
36
|
4
1. mutateConnection : Replaced float subtraction with addition → SURVIVED
2. mutateConnection : removed call to java/util/random/RandomGenerator::nextFloat → KILLED
3. mutateConnection : Replaced float addition with subtraction → KILLED
4. mutateConnection : replaced call to java/util/random/RandomGenerator::nextFloat with argument → KILLED
|
float newWeight = randomGenerator.nextFloat(maxValue - minValue) + minValue; |
37
|
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); |
38
|
3
1. mutateConnection : replaced return value with Collections.emptyList for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeRandomMutationHandler::mutateConnection → KILLED
2. mutateConnection : removed call to java/util/List::of → KILLED
3. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::build → KILLED
|
return List.of(connectionBuilder.build()); |
39
|
|
} |
40
|
|
} |
| | Mutations |
27 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection::builder → KILLED
|
28 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] replaced call to net/bmahe/genetics4j/neat/Connection$Builder::from with receiver → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::from → KILLED
|
30 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMinWeightValue → KILLED
|
31 |
|
1.1 Location : mutateConnection Killed by : none removed call to net/bmahe/genetics4j/neat/chromosomes/NeatChromosome::getMaxWeightValue → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()]
|
33 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeRandomMutationHandler::getRandomGenerator → KILLED
|
36 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to java/util/random/RandomGenerator::nextFloat → KILLED
2.2 Location : mutateConnection Killed by : none Replaced float subtraction with addition → SURVIVED
Covering tests
Covered by tests:
- net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()]
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] Replaced float addition with subtraction → KILLED
4.4 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] replaced call to java/util/random/RandomGenerator::nextFloat with argument → KILLED
|
37 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[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.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::weight → KILLED
|
38 |
|
1.1 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] replaced return value with Collections.emptyList for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeRandomMutationHandler::mutateConnection → KILLED
2.2 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to java/util/List::of → KILLED
3.3 Location : mutateConnection Killed by : net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest.[engine:junit-jupiter]/[class:net.bmahe.genetics4j.neat.mutation.chromosome.NeatChromosomeRandomMutationHandlerTest]/[method:mutateConnection()] removed call to net/bmahe/genetics4j/neat/Connection$Builder::build → KILLED
|