navicatGA.smiles_solver

Attributes

Classes

SmilesGenAlgSolver

Shared base for solvers whose chromosome genes are drawn from a

Module Contents

Bases: navicatGA.alphabet_solver.AlphabetGenAlgSolver

Shared base for solvers whose chromosome genes are drawn from a per-gene alphabet (SMILES fragments, SELFIES tokens, XYZ fragments).

Factors out the alphabet/equivalences setup, population init/refill, crossover-point sampling, and mutation logic that SmilesGenAlgSolver/SelfiesGenAlgSolver/XYZGenAlgSolver used to each reimplement independently. Subclasses still own create_offspring (crossover behaviour genuinely differs between them) and write_population (different depiction backend per representation).

Example child solver class for the GA. This child solver class is an example meant for a particular purpose, which also shows how to use the GA with SMILES as a core molecular representation. It might require heavy modification for other particular usages. Only the parameters specific for this child class are covered here.

Parameters: :param starting_population: list containing the starting SMILES elements for all chromosomes; overridden by starting_random=True :type starting_selfies: list :param starting_random: whether to initialize all chromosomes with random elements from alphabets; overrides starting_selfies :type starting_random: bool :param alphabet_list: list containing the alphabets for the individual genes; or a single alphabet for all :type alphabet_list: list :param chromosome_to_smiles: object that can take a chromosome and generate a smiles string :type chromosome_to_smiles: object :param multi_alphabet: whether alphabet_list contains a single alphabet or a list of n_genes alphabet :type multi_alphabet: bool :param equivalences: list of integers that set the equivalent genes of a chromosome; see examples for clarification :type equivalences: list :param max_counter: maximum number of times a wrong structure will try to be corrected before skipping :type max_counter: int :param base_kwargs: any GenAlgSolver parameter (max_gen, pop_size, mutation_rate, …); see GenAlgSolver for the full list and defaults

Creates an offspring from 2 parents.

Print xyz for all the population at the current state.