Molecule Record

class MoleculeRecord(topology_graph)[source]

Bases: object

An abstract base class for molecular records used by the EA.

Notes

You might notice that the public methods of this abstract base class are implemented. This is a default implementation provided purely for convenience. Subclasses can freely ignore or override this implementation.

Methods

clone()

Return a clone.

get_fitness_value([normalized])

Get the fitness value of the molecule in the record.

get_molecule()

Get the molecule held by the record.

get_topology_graph()

Get the topology graph of the molecule.

with_fitness_value(fitness_value[, normalized])

Return a clone holding a different fitness value.

__init__(topology_graph)[source]

Initialize a MoleculeRecord instance.

Parameters

topology_graph (TopologyGraph) – The topology graph of a ConstructedMolecule.

clone()[source]

Return a clone.

Returns

The clone. Has the same type as the original record.

Return type

MoleculeRecord

get_fitness_value(normalized=True)[source]

Get the fitness value of the molecule in the record.

Parameters

normalized (bool, optional) – Toggles the return of the normalized vs unnormalized fitness value. The unnormalized fitness value is guaranteed to be constant for the same molecule across generations, while the normalized one is allowed to change.

Returns

  • object – The fitness value.

  • None (NoneType) – If a fitness value has not been assigned to the record.

get_molecule()[source]

Get the molecule held by the record.

Returns

The molecule held by the record.

Return type

ConstructedMolecule

get_topology_graph()[source]

Get the topology graph of the molecule.

Returns

The topology graph.

Return type

TopologyGraph

with_fitness_value(fitness_value, normalized=True)[source]

Return a clone holding a different fitness value.

Parameters
  • fitness_value (object) – The fitness value of the clone.

  • normalized (bool, optional) – Toggles if the normalized or unnormalized fitness value is being set. If False, both the normalized and unnormalized fitness values with be set to fitness_value.

Returns

The clone. Has the same type as the original record.

Return type

MoleculeRecord