pg.evolution.Union

Accessible via pg.evolution.Union.

class Union(ops)[source]

Bases: pg.evolution.Operation

Unioning operations’ outputs based on the same input.

A union operation passes the input to all its child operations, and union their output. The items in the output will follow the order of their presence in the input with duplicated items removed.

Example:

pg.evolution.Union([
  pg.evolution.selectors.Random(10)
  pg.evolution.selectors.Top(1),
])

which is equivalent to:

pg.evolution.selectors.Random(10) | pg.evolution.selectors.Top(1)

The code above returns the top 1 DNA and a random DNA. If both are the same DNA, only one occurence will be returned.

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.