| 1 | package net.bmahe.genetics4j.neat.mutation.chromosome; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | import java.util.Objects; | |
| 5 | import java.util.random.RandomGenerator; | |
| 6 | ||
| 7 | import net.bmahe.genetics4j.neat.Connection; | |
| 8 | import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; | |
| 9 | import net.bmahe.genetics4j.neat.spec.mutation.SwitchStateMutation; | |
| 10 | ||
| 11 | public class NeatChromosomeSwitchStateHandler | |
| 12 | extends AbstractNeatChromosomeConnectionMutationHandler<SwitchStateMutation> | |
| 13 | { | |
| 14 | public NeatChromosomeSwitchStateHandler(final RandomGenerator _randomGenerator) { | |
| 15 | super(SwitchStateMutation.class, _randomGenerator); | |
| 16 | } | |
| 17 | ||
| 18 | @Override | |
| 19 | protected List<Connection> mutateConnection(final SwitchStateMutation switchStateMutation, | |
| 20 | final NeatChromosome neatChromosome, final Connection oldConnection, final int i) { | |
| 21 | Objects.requireNonNull(switchStateMutation); | |
| 22 | Objects.requireNonNull(neatChromosome); | |
| 23 | Objects.requireNonNull(oldConnection); | |
| 24 | ||
| 25 |
3
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 3. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection::builder → KILLED |
final var connectionBuilder = Connection.builder().from(oldConnection); |
| 26 |
8
1. mutateConnection : replaced call to net/bmahe/genetics4j/neat/Connection$Builder::isEnabled with receiver → KILLED 2. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::isEnabled → KILLED 3. mutateConnection : removed conditional - replaced equality check with false → KILLED 4. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection::isEnabled → KILLED 5. mutateConnection : removed conditional - replaced equality check with true → KILLED 6. mutateConnection : Substituted 1 with 0 → KILLED 7. mutateConnection : negated conditional → KILLED 8. mutateConnection : Substituted 0 with 1 → KILLED |
connectionBuilder.isEnabled(!oldConnection.isEnabled()); |
| 27 |
3
1. mutateConnection : replaced return value with Collections.emptyList for net/bmahe/genetics4j/neat/mutation/chromosome/NeatChromosomeSwitchStateHandler::mutateConnection → KILLED 2. mutateConnection : removed call to net/bmahe/genetics4j/neat/Connection$Builder::build → KILLED 3. mutateConnection : removed call to java/util/List::of → KILLED |
return List.of(connectionBuilder.build()); |
| 28 | } | |
| 29 | } | |
Mutations | ||
| 25 |
1.1 2.2 3.3 |
|
| 26 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 27 |
1.1 2.2 3.3 |