[docs]@dataclass()classMolecule:""" The Molecule dataclass represents a molecule with various attributes used in optimization. Attributes: smiles: The SMILES string representation of the molecule. pedigree: The lineage or origin of the molecule. fitness: The fitness score of the molecule. niche_index: The index of the niche the molecule belongs to. descriptor: The list of physicochemical descriptors of the molecule. predicted_fitness: The predicted fitness score from the surrogate model. predicted_uncertainty: The uncertainty associated with the predicted fitness. acquisition_value: The value assigned by the acquisition function. sa_score: The value assigned by the synthetic accessibility estimator. """smiles:strpedigree:Tuple[str,str,str]fitness:float=Noneniche_index:int=Nonedescriptor:List[float]=Nonepredicted_fitness:int=0predicted_uncertainty:int=0acquisition_value:float=Nonesa_score:float=0.0
[docs]classElite:""" The Elite class represents a phenotypic elite molecule in the Bayesian Illumination algorithm. An elite molecule is one that has the highest fitness within its niche. The class manages the storage and update of this elite molecule. Attributes: index: The index of the niche that this elite belongs to. molecule: The molecule with the highest fitness in this niche. fitness: The fitness score of the elite molecule. """def__init__(self,index:int)->None:""" Initializes the Elite object with the given niche index. Args: index: The index of the niche. """self.index=indexself.molecule=Noneself.fitness=0.0
[docs]defupdate(self,molecule:Molecule)->None:""" Updates the elite molecule if the new molecule has a higher fitness. Args: molecule: The new molecule to be considered as the potential elite. """ifself.moleculeisNoneor(molecule.fitness-self.fitness)>0.0:self.molecule=moleculeself.fitness=molecule.fitnessreturnNone