| 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.neat.Connection; | |
| 9 | import net.bmahe.genetics4j.neat.chromosomes.NeatChromosome; | |
| 10 | import net.bmahe.genetics4j.neat.spec.mutation.SwitchStateMutation; | |
| 11 | ||
| 12 | public class NeatChromosomeSwitchStateHandler | |
| 13 | extends AbstractNeatChromosomeConnectionMutationHandler<SwitchStateMutation> | |
| 14 | { | |
| 15 | public NeatChromosomeSwitchStateHandler(final RandomGenerator _randomGenerator) { | |
| 16 | super(SwitchStateMutation.class, _randomGenerator); | |
| 17 | } | |
| 18 | ||
| 19 | @Override | |
| 20 | protected List<Connection> mutateConnection(final SwitchStateMutation switchStateMutation, | |
| 21 | final NeatChromosome neatChromosome, final Connection oldConnection, final int i) { | |
| 22 | Validate.notNull(switchStateMutation); | |
| 23 | Validate.notNull(neatChromosome); | |
| 24 | Validate.notNull(oldConnection); | |
| 25 | ||
| 26 |
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); |
| 27 |
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()); |
| 28 |
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()); |
| 29 | } | |
| 30 | } | |
Mutations | ||
| 26 |
1.1 2.2 3.3 |
|
| 27 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 28 |
1.1 2.2 3.3 |