コード例 #1
0
def run_one_max_problem():
    generator = create_chromosome_generator()
    ev_alg = create_evolutionary_algorithm()

    island = Island(ev_alg, generator, population_size=10)
    display_best_individual(island)

    island.evolve(num_generations=50)

    display_best_individual(island)
コード例 #2
0
ファイル: ZeroMinExample.py プロジェクト: nasa/bingo
def main():
    crossover = SinglePointCrossover()
    mutation = SinglePointMutation(get_random_float)
    selection = Tournament(10)
    fitness = ZeroMinFitnessFunction()
    local_opt_fitness = ContinuousLocalOptimization(fitness)
    evaluator = Evaluation(local_opt_fitness)
    ea = MuPlusLambda(evaluator, selection, crossover, mutation, 0.4, 0.4, 20)
    generator = MultipleFloatChromosomeGenerator(get_random_float, 8)
    island = Island(ea, generator, 25)

    island.evolve(1)
    report_max_min_mean_fitness(island)
    island.evolve(500)
    report_max_min_mean_fitness(island)
コード例 #3
0
def test_island_hof(mocker):
    hof = mocker.Mock()
    crossover = SinglePointCrossover()
    mutation = SinglePointMutation(mutation_function)
    selection = Tournament(10)
    fitness = MultipleValueFitnessFunction()
    evaluator = Evaluation(fitness)
    ev_alg = MuPlusLambda(evaluator, selection, crossover, mutation,
                          0.2, 0.4, 20)
    generator = MultipleValueChromosomeGenerator(mutation_function, 10)
    island = Island(ev_alg, generator, 25, hall_of_fame=hof)

    island.evolve(10)

    hof.update.assert_called_once()
    hof_update_pop = hof.update.call_args[0][0]
    for h, i in zip(hof_update_pop, island.population):
        assert h == i