pg.evolution.Concatenation

Accessible via pg.evolution.Concatenation.

class Concatenation(ops)[source]

Bases: pg.evolution.Operation

Concatenating the operations’ outputs based on the same input.

A concatenate operation passes the input to all its child operations, and concatenate their outputs. Different from Union, the duplicated items will be kept.

Example:

pg.evolution.Concatenation([
  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 concatenated with the first 10 DNAs. The result may contain duplicated items.

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.