pg.evolution.selectors.Sample

Accessible via pg.evolution.selectors.Sample.

class Sample(n=None, weights=MISSING_VALUE, seed=None)[source]

Bases: pg.evolution.Selector

Sample N items from a weighting function.

Methods:

select(inputs, global_state, step)

Select a list of outputs from the inputs.

select(inputs, global_state, step)[source]

Select a list of outputs from the inputs.

A selector has two use cases: :rtype: List[Any]

  • Used as parents selector, which selects individuals from the population as parents for recombination. It will be called before the recombination step within the pg.evolution.Evolution method.

  • Used as a population updater, which selects individuals from previous population as a new population. It will be called everytime the population is updated, triggered by the pg.evolution.Evolution method.

Parameters:
  • inputs – a list of objects as input.

  • global_state – An AttributeDict object as the global state container, which is readable/writable during the operation.

  • step – Number of examples historically proposed, which can be used for determining a cross over schedule.