pg.evolution.recombinators.KPoint

Accessible via pg.evolution.recombinators.KPoint.

class KPoint(k, seed=None)[source]

Bases: pg.evolution.recombinators.SegmentWise

K-point crossover.

K-point crossover is one of the basic crossovers in evolutionary algorithms. It cuts both parents’ DNA at K positions, which forms K + 1 segments. Then it takes the K + 1 segments from both parents in an interleaving manner. For example, a two-point crossover that takes places at cutting points 2 and 5 will result in 2 children as follows:

Parent 1:   [1,  2,  | 3,  4,  5,  | 6,  7]
Parent 2:   [10, 20, | 30, 40, 50, | 60, 70]
                     |             |
Child 1:    [1,  2,  | 30, 40, 50, | 6,  7]
Child 2:    [10, 20, | 3,  4,  5,  | 60, 70]

2 children as follows: When K=1, we get a single-point crossover. Similarily, when K=2, we get a two-point crossover.

When K equals or is greater than the length of DNA sequence, we get an alternating-position (APX) crossover.

Reference: https://mitpress.mit.edu/books/introduction-genetic-algorithms https://dl.acm.org/doi/abs/10.5555/93126.93134 https://www.intechopen.com/chapters/335

Methods:

cutting_indices(independent_decision_points, ...)

Returns the indices of cutting points for a list decision points.

cutting_indices(independent_decision_points, global_state, step)[source]

Returns the indices of cutting points for a list decision points.

Return type:

List[int]