コード例 #1
0
    },
    'crossover_method': mix,
    'crossover_rate': 0.9,
    'mutation_method': mutate_bit_genome,
    'mutation_rate': 0.01,
    'stop': {
        'fitness': None,
        'generation': 100
    }
}

G = 100
N = 100
X = list(range(1, G + 1))
results = []
for msm in MATE_SELECTION_METHODS:
    print(msm)
    simulation.update({'mate_selection_method': msm})
    results.append({
        'x': X,
        'y': average_n_runs(simulation, N, G)['average_fitnesses'],
        'label': str(msm).split(' ')[1]
    })

plot_results(datasets=results,
             savefig="../report/img/{}.png".format(datetime.datetime.now()),
             xlabel="Generation number",
             ylabel="Fitness",
             title="Different parent selection functions",
             ncol=3)
コード例 #2
0
ファイル: different_rates.py プロジェクト: babingto/IT3708
from problems.simulations import ONE_MAX

avgs = []
x = list(range(1, 101))
for s in [
    {
        'crossover_rate': c,
        'mutation_rate': m
    } for c in (0.75, 1.0) for m in (0.01, 0.005)
]:
    simulation = ONE_MAX
    simulation.update(s)
    label = "{}, {}".format(
        simulation['crossover_rate'],
        simulation['mutation_rate']
    )
    avgs.append({
        'x': x,
        'y': average_n_runs(simulation, n=10, generations=100)['average_fitnesses'],
        'label': label
    })

plot_results(
    datasets=avgs,
    savefig="../report/img/{}_avg.png".format(datetime.now()),
    xlabel="Generation number",
    ylabel="Fitness",
    title="Average fitness with specified crossover rate, mutation rate",
    ncol=4
)
コード例 #3
0
ファイル: different_rates.py プロジェクト: mathiasose/IT3708
from experiments.average_n_runs import average_n_runs
from plot import plot_results
from problems.simulations import ONE_MAX

avgs = []
x = list(range(1, 101))
for s in [{
        'crossover_rate': c,
        'mutation_rate': m
} for c in (0.75, 1.0) for m in (0.01, 0.005)]:
    simulation = ONE_MAX
    simulation.update(s)
    label = "{}, {}".format(simulation['crossover_rate'],
                            simulation['mutation_rate'])
    avgs.append({
        'x':
        x,
        'y':
        average_n_runs(simulation, n=10, generations=100)['average_fitnesses'],
        'label':
        label
    })

plot_results(
    datasets=avgs,
    savefig="../report/img/{}_avg.png".format(datetime.now()),
    xlabel="Generation number",
    ylabel="Fitness",
    title="Average fitness with specified crossover rate, mutation rate",
    ncol=4)
コード例 #4
0
    'mutation_method': mutate_bit_genome,
    'mutation_rate': 0.01,

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

G = 100
N = 100
X = list(range(1, G+1))
results = []
for msm in MATE_SELECTION_METHODS:
    print(msm)
    simulation.update({'mate_selection_method': msm})
    results.append({
        'x': X,
        'y': average_n_runs(simulation, N, G)['average_fitnesses'],
        'label': str(msm).split(' ')[1]
    })

plot_results(
    datasets=results,
    savefig="../report/img/{}.png".format(datetime.datetime.now()),
    xlabel="Generation number",
    ylabel="Fitness",
    title="Different parent selection functions",
    ncol=3
)
コード例 #5
0
ファイル: lolz_same_settings.py プロジェクト: babingto/IT3708
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())
)