Generation

class Generation(molecule_records, mutation_records, crossover_records)[source]

Bases: object

An abstract base class for EA generations.

Notes

You might notice that the public methods of this abstract base class are implemented. This is just a default implementation, which you can ignore or override when implementing subclasses.

Methods

get_crossover_records()

Yield the crossover records in the generation.

get_molecule_records()

Yield the molecule records in the generation.

get_mutation_records()

Yield the mutation records in the generation.

__init__(molecule_records, mutation_records, crossover_records)[source]

Initialize a Generation instance.

Parameters
  • molecule_records (tuple of MoleculeRecord) – The records of molecules in the generation.

  • mutation_records (tuple of MutationRecord) – The records of mutations done during the generation.

  • crossover_records (tuple of CrossoverRecord) – The records of crossover operations done during the generation.

get_crossover_records()[source]

Yield the crossover records in the generation.

Yields

CrossoverRecord – A crossover record.

get_molecule_records()[source]

Yield the molecule records in the generation.

Yields

MoleculeRecord – A molecule record.

get_mutation_records()[source]

Yield the mutation records in the generation.

Yields

MutationRecord – A mutation record.