pg.evolution.Intersection

Accessible via pg.evolution.Intersection.

class Intersection(ops)[source]

Bases: pg.evolution.Operation

Intersecting operations’s outputs based on the same input.

An intersect operation pass the input to all its child operations, and intersect their output as the result. The items in the output will follow the order of their presences in the input with duplicated items removed.

Example:

pg.evolution.Intersection([
  pg.evolution.selectors.Last(10)
  pg.evolution.selectors.Top(1),
])

which is equivalent to:

pg.evolution.selectors.Last(10) & pg.evolution.selectors.Top(1)

The code above returns top 1 DNA only when it’s among the last 10 items of the input.

Methods:

call(inputs, global_state[, step])

Subclasses should override this method.

call(inputs, global_state, step=0)[source]

Subclasses should override this method.

The global_state and step are optional for the subclasses’ call signature.

Return type:

List[Any]

Parameters:
  • inputs – A list of values as inputs.

  • 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.

Returns:

A list of values as output of current operation.