Пример #1
0
def plot_experiments(*exp_names,
                     log=False,
                     transform_map=lambda x: x,
                     ylim=(0, 1),
                     stat_type=["objective"],
                     color=None,
                     fill=True):
    plt.figure(figsize=(12, 8))

    if log:
        plt.yscale("log")

    if ylim is not None:
        plt.ylim(ylim)

    for s in stat_type:
        rename_dict = {}
        for name in exp_names:
            appendix = (".train" if s == "fitness" else ".test")
            rename_dict[name] = name + appendix

        utils.plot_experiments(OUT_DIR,
                               exp_names,
                               transform_map=transform_map,
                               stat_type=s,
                               rename_dict=rename_dict,
                               color=color,
                               fill=fill)
    plt.show()
Пример #2
0
def plot_experiments(*exp_names, transform_map=lambda x: x - 150000, ylim=[10000, 150000]):
    plt.figure(figsize=(12,8))
    plt.yscale("log")


    # settings specific for tsp_std.in input
    if ylim is not None:
        plt.ylim(ylim)

    utils.plot_experiments(OUT_DIR, exp_names, transform_map=transform_map)
    plt.show()
Пример #3
0
# use and edit this file to make all the plots you need - it is generally easier
# than plotting directly after the run of the algorithm

import utils

import matplotlib.pyplot as plt

plt.figure(figsize=(12, 8))
utils.plot_experiments('rules', ['default'])
plt.show()
#     plt.savefig(f_name + 'fitness.png')
#     plt.cla()

fit_name = 'f10'
stat_type = "fitness"
plt.yscale('log')
# plt.xscale('log')
# utils.plot_experiments(
#     OUT_DIR, ['default' + '.' + fit_name, 'adapt_variance' + '.' + fit_name, 'adapt_fitness_probability.' + fit_name], stat_type=stat_type)
# plt.savefig(fit_name + stat_type + ".png")

experiments = ['diff_evolution' + '.' + name for name in fit_names]
# utils.plot_experiments(
#     OUT_DIR, experiments, stat_type=stat_type)
# plt.savefig("diff_evolution_" + stat_type + ".png")
# utils.plot_experiments(
#     OUT_DIR, ['diff_evolution' + '.' + "f01"], stat_type=stat_type)
# plt.savefig("diff_evolution_" + stat_type + ".png")

# for name in fit_names:
#     plt.xscale('log')

#     utils.plot_experiments(
#         OUT_DIR, ['diff_evolution' + '.' + name], stat_type=stat_type)
#     plt.savefig("diff_evolution_" + name + stat_type + ".png")
#     plt.close()
for name in fit_names:
    utils.plot_experiments(OUT_DIR, ['diff_evolution' + '.' + name],
                           stat_type=stat_type)
plt.savefig("diff_evolution_" + stat_type + ".png")
# use and edit this file to make all the plots you need - it is generally easier
# than plotting directly after the run of the algorithm

import utils

import matplotlib.pyplot as plt 

plt.figure(figsize=(12,8))
utils.plot_experiments('continuous', ['default.f01', 'tuned.f01'], 
                       rename_dict={'default.f01': 'Sphere (default)',
                                    'tuned.f01': 'Sphere (tuned)'})
plt.show()
 
Пример #6
0
def plot_all_experiments():
    with open(OUT_DIR + "/" + EXP_NAMES_LIST, "r") as f:
        utils.plot_experiments(OUT_DIR,
                               list(set(f.read().strip().split("\n"))))
    plt.show()
Пример #7
0
        # log.write_files()

    # print an overview of the best individuals from each run
    for i, bi in enumerate(best_inds):
        print(
            f'Run {i}: difference = {fit(bi).objective}, bin weights = {bin_weights(weights, bi)}'
        )

    # write summary logs for the whole experiment
    utils.summarize_experiment(OUT_DIR, EXP_ID)

    # read the summary log and plot the experiment
    evals, lower, mean, upper = utils.get_plot_data(OUT_DIR, EXP_ID)
    plt.figure(figsize=(12, 8))
    utils.plot_experiment(evals,
                          lower,
                          mean,
                          upper,
                          legend_name='Default settings')
    plt.legend()
    plt.show()

    # you can also plot mutiple experiments at the same time using
    # utils.plot_experiments, e.g. if you have two experiments 'default' and
    # 'tuned' both in the 'partition' directory, you can call
    utils.plot_experiments('partition', ['default', 'tuned'],
                           rename_dict={'default': 'Default setting'})
    # the rename_dict can be used to make reasonable entries in the legend -
    # experiments that are not in the dict use their id (in this case, the
    # legend entries would be 'Default settings' and 'tuned')
Пример #8
0
import utils

utils.plot_experiments(
    '.', [
        'partition/k10_p100_g500_x0.8_m0.2_mf0.1_r10(default)',
        'final_bad/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned)',
        'final_worse/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned)',
        'final_bad_but_better/k10-p1024-g20480-s10-x0.0-m0.1-mf0.002-ms0.15-dc0.0-r10(tuned)',
        'final_better_9/k10-p500-g10000-s10-x0.0-m0.002-mf0.05-ms0.33-dc0.1-r10(tuned)',
        'final_better_11/k10-p800-g20000-s10-x0.0-m0.001-mf0.02-ms0.15-dc0.05-r10(tuned)'
    ],
    rename_dict={
        'final_better_11/k10-p800-g20000-s10-x0.0-m0.001-mf0.02-ms0.15-dc0.05-r10(tuned)':
        'final_better_11/k10-p800-g20000-s10-x0.0-m0.001-mf0.02-ms0.15-dc0.05-r10(tuned - best found)',
        'final_better_9/k10-p500-g10000-s10-x0.0-m0.002-mf0.05-ms0.33-dc0.1-r10(tuned)':
        'final_better_9/k10-p500-g10000-s10-x0.0-m0.002-mf0.05-ms0.33-dc0.1-r10(tuned - enhanced fit)',
        'final_bad/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned)':
        'final_bad/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned - no special mutations)',
        'final_worse/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned)':
        'final_worse/k10-p800-g10000-s10-x0.0-m0.00125-mf0.01-ms0.15-dc0.0-r10(tuned - no special mut & init)',
        'final_bad_but_better/k10-p1024-g20480-s10-x0.0-m0.1-mf0.002-ms0.15-dc0.0-r10(tuned)':
        'final_bad_but_better/k10-p1024-g20480-s10-x0.0-m0.1-mf0.002-ms0.15-dc0.0-r10(tuned - init + low params - no special mut)',
    })
Пример #9
0
import utils

for graph in ['f01', 'f02', 'f06', 'f08', 'f10']:
    utils.plot_experiments('continuous', [
        '.'.join(['default', graph]),
        '.'.join(['diff-threesome', graph]),
        '.'.join(['diff-threesome-small-F', graph]),
        '.'.join(['diff-threesome-small-CF', graph]),
        '.'.join(['diff-basic-adaptive', graph]),
        '.'.join(['diff-threesome-adaptive', graph]),
        '.'.join(['diff-g******g-adaptive', graph]),
    ])