Exemplo n.º 1
0
    for i in range(generations):
        for dataset in datasets:
            for key in sum_dataset.keys():
                sum_dataset[key][i] += dataset[key][i]

    avg_func = lambda x: float(x) / n

    avg_dataset = {
        'generation_number': generations,
        'simulation': simulation,
        'average_fitnesses':
        list(map(avg_func, sum_dataset['average_fitnesses'])),
        'sigmas': list(map(avg_func, sum_dataset['sigmas'])),
        'best_fitnesses': list(map(avg_func, sum_dataset['best_fitnesses']))
    }

    return avg_dataset


if __name__ == "__main__":
    S = ONE_MAX
    N = 10
    G = 100

    avg_dataset = average_n_runs(S, N, G)

    plot_simulation_results(
        avg_dataset,
        title="Averages {} runs of {}".format(N, S['problem'].NAME),
        savefig="../report/img/{}.png".format(datetime.now()))
Exemplo n.º 2
0
            for key in sum_dataset.keys():
                sum_dataset[key][i] += dataset[key][i]

    avg_func = lambda x: float(x) / n

    avg_dataset = {
        'generation_number': generations,
        'simulation': simulation,
        'average_fitnesses': list(map(avg_func, sum_dataset['average_fitnesses'])),
        'sigmas': list(map(avg_func, sum_dataset['sigmas'])),
        'best_fitnesses': list(map(avg_func, sum_dataset['best_fitnesses']))
    }

    return avg_dataset

if __name__ == "__main__":
    S = ONE_MAX
    N = 10
    G = 100

    avg_dataset = average_n_runs(S, N, G)

    plot_simulation_results(
        avg_dataset,
        title="Averages {} runs of {}".format(
            N,
            S['problem'].NAME
        ),
        savefig="../report/img/{}.png".format(datetime.now())
    )
Exemplo n.º 3
0
    'adult_selection_method': full_generational_replacement,

    'mate_selection_method': ranked,

    'crossover_method': splice,
    'crossover_rate': 0.25,

    'mutation_method': mutate_string_genome,
    'mutation_rate': 0.01,

    'stop': {
        'fitness': 1.0,
        'generation': None
    },

    'plot_sigmas': False
}

SIMULATIONS = [
    ONE_MAX,
    LOLZ,
    LOCALLY_SURPRISING,
    GLOBALLY_SURPRISING
]

if __name__ == "__main__":
    for simulation in SIMULATIONS:
        results = run_simulation(simulation)
        plot_simulation_results(results)
Exemplo n.º 4
0
import datetime
from evo_alg import plot_simulation_results
from experiments.average_n_runs import average_n_runs
from problems.simulations import LOLZ

simulation = LOLZ

r = average_n_runs(simulation, 100, 100)

plot_simulation_results(
    r,
    # title="Averages {} runs of {}".format(
    #     N,
    #     S['problem'].NAME
    # ),
    savefig="../report/img/{}.png".format(datetime.datetime.now())
)