navicatGA.smiles_solver¶
Attributes¶
Classes¶
Shared base for solvers whose chromosome genes are drawn from a |
Module Contents¶
- class navicatGA.smiles_solver.SmilesGenAlgSolver(starting_population: list = [['']], starting_random: bool = False, alphabet_list: list = ['C', 'N', 'P', 'O', '[Si]', 'F', '[H]'], chromosome_to_smiles=concatenate_list(), multi_alphabet: bool = False, equivalences: Sequence = None, max_counter: int = 10, n_genes: int = 1, fitness_function=None, excluded_genes: Sequence = None, **base_kwargs)¶
Bases:
navicatGA.alphabet_solver.AlphabetGenAlgSolverShared 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
- create_offspring(first_parent, sec_parent, crossover_pt, offspring_number)¶
Creates an offspring from 2 parents.
- write_population(basename='chromosome')¶
Print xyz for all the population at the current state.
- max_counter = 10¶
- starting_population = [['']]¶
- starting_random = False¶
- navicatGA.smiles_solver.logger¶