pg.evolution.recombinators.Numeric

Accessible via pg.evolution.recombinators.Numeric.

class Numeric(where=All())[source]

Bases: pg.evolution.recombinators.PointWise

Base class for numerical recombinators.

A numeric recombinator operates on pg.geno.Float decision points, by recombining parents’ values into child values.

Decisions of pg.geno.Choices will be copied over from N parents to N children on an one-to-one basis. If there is no choice decision points in the search space and where clause does not filer any float points out, there will be a single child produced.

Example:

parents = [pg.DNA([0, 1, 0.1, 0.2]), pg.DNA([2, 3, 0.5, 0.4])]
# `children` will be [pg.DNA(0, 1, 0.3, 0.3), pg.geno(2, 3, 0.3, 0.3)].
children = pg.evolution.recombinators.Average()(parents)

parents = [pg.DNA([0.1, 0.2]), pg.DNA([0.5, 0.4])]
# `children` will be [pg.DNA(0.3, 0.3)].
children = pg.evolution.recombinators.Average()(parents)

Methods:

applicable_decision_points(dna_spec)

Returns applicable decision points for this recombinator.

applicable_decision_points(dna_spec)[source]

Returns applicable decision points for this recombinator.

The default behavior is to return all decision points in the search space, with multi-choice subchoices folded into a single decision point. Subclasses can override this method to select applicable points according to their semantics.

Return type:

List[pg.geno.DecisionPoint]

Parameters:
  • dna_spec – The root DNASpec.

  • global_state – An optional keyword argument as the global state. Subclass can omit.

  • step – An optional keyword argument as current step. Subclass can omit.

Returns:

A list of targeted decision points for point-wise recombination, which

will be further filtered by the where statement later.