Beispiel #1
0
def plus_algo(add_e_evaluation, add_v_variation, add_s_selection):
    crossover = SinglePointCrossover()
    mutation = SinglePointMutation(mutation_function)
    evo_alg = MuPlusLambda(add_e_evaluation, add_s_selection, crossover,
                           mutation, 0.2, 0.4, 20)
    evo_alg.variation = add_v_variation
    return evo_alg
Beispiel #2
0
def evol_alg():
    crossover = SinglePointCrossover()
    mutation = SinglePointMutation(mutation_function)
    selection = Tournament(SELECTION_SIZE)
    fitness = MultipleValueFitnessFunction()
    evaluator = Evaluation(fitness)
    return MuPlusLambda(evaluator, selection, crossover, mutation, 0.2, 0.4,
                        OFFSPRING_SIZE)
def ev_alg():
    crossover = SinglePointCrossover()
    mutation = SinglePointMutation(np.random.random)
    selection = Tournament(2)
    training_data = np.linspace(0.1, 1, FULL_TRAINING_DATA_SIZE)
    fitness = DistanceToAverage(training_data)
    evaluator = Evaluation(fitness)
    return MuPlusLambda(evaluator, selection, crossover, mutation,
                        0., 1.0, MAIN_POPULATION_SIZE)
Beispiel #4
0
def island():
    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)
    return Island(ev_alg, generator, 25)
Beispiel #5
0
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)

    best_indv_values = []
    best_indv_values.append(island.best_individual().values)
    for i in range(500):
        island.execute_generational_step()
        best_indv_values.append(island.best_individual().values)

    bingo.animation.animate_data(best_indv_values)
Beispiel #6
0
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)
    for i in range(25):
        island.execute_generational_step()
        print("\nGeneration #", i)
        print("-" * 80, "\n")
        report_max_min_mean_fitness(island.population)
        print("\npopulation: \n")
        for indv in island.population:
            print(["{0:.2f}".format(val) for val in indv.values])