pg.evolution.Difference#

Accessible via pg.evolution.Difference.

class Difference(ops)[source]#

Bases: pg.evolution.Operation

Compute the difference of operation outputs based on the same input.

A difference operation passes the input to all its child selectors, and substract the output from the rest operations from the output from the first operation. The items in the output will follow the order of their presences in the input.

Example:

pg.evolution.Difference([
  pg.evolution.selectors.Top(10),
  pg.evolution.selectors.First(10)
])

which is equivalent to:

pg.evolution.selectors.Top(10) - pg.evolution.selectors.First(10)

The code above returns top 10 DNA only when they are not among the first 10 elements 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.