Module io.jenetics.ext
Package io.jenetics.ext
Class SingleNodeCrossover<G extends TreeGene<?,G>,C extends Comparable<? super C>>
java.lang.Object
io.jenetics.AbstractAlterer<G,C>
io.jenetics.Recombinator<G,C>
io.jenetics.ext.TreeCrossover<G,C>
io.jenetics.ext.SingleNodeCrossover<G,C>
- All Implemented Interfaces:
Alterer<G,
C>
public class SingleNodeCrossover<G extends TreeGene<?,G>,C extends Comparable<? super C>>
extends TreeCrossover<G,C>
Swaps two, randomly chosen, nodes (subtrees) from two given trees.
Tree A Tree B
0 a
├── 1 ├── b
│ ├── 4 │ ├── e
│ └── 5 │ └── f
├── 2 ├── c
│ └── 6 │ └── g
└── 3 └── d
├── 7 ├── h
│ ├── 10 │ ├── k
│ └── 11 │ └── l
├── 8 ├── i
└── 9 └── j
Swap node "3" of A with node "c" of B
0 a
├── 1 ├── b
│ ├── 4 │ ├── e
│ └── 5 │ └── f
├── 2 ├── 3
│ └── 6 │ ├── 7
└── c │ │ ├── 10
└── g │ │ └── 11
│ ├── 8
│ └── 9
└── d
├── h
│ ├── k
│ └── l
├── i
└── j
- Since:
- 3.9
- Version:
- 5.0
-
Field Summary
Fields inherited from class io.jenetics.AbstractAlterer
_probability
Fields inherited from interface io.jenetics.Alterer
DEFAULT_ALTER_PROBABILITY
-
Constructor Summary
-
Method Summary
Methods inherited from class io.jenetics.ext.TreeCrossover
recombine
Methods inherited from class io.jenetics.Recombinator
alter, order
Methods inherited from class io.jenetics.AbstractAlterer
probability
-
Constructor Details
-
SingleNodeCrossover
-
SingleNodeCrossover
public SingleNodeCrossover()
-
-
Method Details
-
crossover
Description copied from class:TreeCrossover
Template method which performs the crossover. The arguments given are mutable non-null trees.- Specified by:
crossover
in classTreeCrossover<G extends TreeGene<?,
G>, C extends Comparable<? super C>> - Type Parameters:
A
- the existential allele type- Parameters:
that
- the first (chromosome) treeother
- he second (chromosome) tree- Returns:
- the number of altered genes
-
toString
-