Class CycleCrossover<T>

  • Type Parameters:
    T - generic type of the AbstractListChromosomes for crossover
    All Implemented Interfaces:
    CrossoverPolicy

    public class CycleCrossover<T>
    extends Object
    implements CrossoverPolicy
    Cycle Crossover [CX] builds offspring from ordered chromosomes by identifying cycles between two parent chromosomes. To form the children, the cycles are copied from the respective parents.

    To form a cycle the following procedure is applied:

    1. start with the first gene of parent 1
    2. look at the gene at the same position of parent 2
    3. go to the position with the same gene in parent 1
    4. add this gene index to the cycle
    5. repeat the steps 2-5 until we arrive at the starting gene of this cycle
    The indices that form a cycle are then used to form the children in alternating order, i.e. in cycle 1, the genes of parent 1 are copied to child 1, while in cycle 2 the genes of parent 1 are copied to child 2, and so forth ... Example (zero-start cycle):
     p1 = (8 4 7 3 6 2 5 1 9 0)    X   c1 = (8 1 2 3 4 5 6 7 9 0)
     p2 = (0 1 2 3 4 5 6 7 8 9)    X   c2 = (0 4 7 3 6 2 5 1 8 9)
    
     cycle 1: 8 0 9
     cycle 2: 4 1 7 2 5 6
     cycle 3: 3
     
    This policy works only on AbstractListChromosome, and therefore it is parameterized by T. Moreover, the chromosomes must have same lengths.
    Since:
    3.1
    See Also:
    Cycle Crossover Operator