pg.evolution.recombinators.Segmented¶
Accessible via pg.evolution.recombinators.Segmented
.
- class Segmented(cutting_points)[source]¶
Bases:
pg.evolution.recombinators.SegmentWise
Segmented crossover.
Instead of using a predefined cutting strategy, the segmented recombinator allows the user to customize how the cutting points should be chosen, which can be used to implement fixed cutting point strategies (e.g nodes + edges) as well as decision points’ based cutting point strategies.
Example:
# A fixed single-point crossover at the mid of the chrosome: pg.evolution.Segmented(lambda xs: [len(xs) / 2]) # A dynamic multi-point crossover based on hints. pg.evolution.Segmented(lambda xs: [x.hints == 'block_end' for x in xs])
Methods:
cutting_indices
(independent_decision_points, ...)Returns the indices of cutting points for a list decision points.