Ejemplo n.º 1
0
    topology_graphs=[stk.cage.FourPlusSix()],
    size=population_size,
    random_seed=random_seed,
    use_cache=True,
)

# #####################################################################
# Selector for selecting the next generation.
# #####################################################################

generation_selector = stk.Sequence(
    stk.AboveAverage(duplicate_mols=False),
    stk.RemoveMolecules(
        remover=stk.AboveAverage(duplicate_mols=False),
        selector=stk.Roulette(
            duplicate_mols=False,
            random_seed=random_seed,
        ),
    ),
    num_batches=population_size,
)

# #####################################################################
# Selector for selecting parents.
# #####################################################################

crossover_selector = stk.StochasticUniversalSampling(
    num_batches=5,
    batch_size=2,
    duplicate_batches=False,
    random_seed=random_seed,
Ejemplo n.º 2
0
        stk.MoleculeRecord(
            topology_graph=get_topology_graph(3), ).with_fitness_value(9),
        stk.MoleculeRecord(
            topology_graph=get_topology_graph(4), ).with_fitness_value(2),
        stk.MoleculeRecord(
            topology_graph=get_topology_graph(5), ).with_fitness_value(1),
        stk.MoleculeRecord(
            topology_graph=get_topology_graph(6), ).with_fitness_value(1),
    )


@pytest.fixture(
    scope='session',
    params=(lambda population: CaseData(
        selector=stk.RemoveMolecules(
            remover=stk.Best(2),
            selector=stk.Best(),
        ),
        population=population,
        selected=(
            stk.Batch(
                records=(population[2], ),
                fitness_values={population[2]: 2},
                key_maker=stk.Inchi(),
            ),
            stk.Batch(
                records=(population[3], ),
                fitness_values={population[3]: 1},
                key_maker=stk.Inchi(),
            ),
            stk.Batch(
                records=(population[4], ),