Beispiel #1
0
# where n is the number of times the meta-heuristic algorithms are run to get the mean
n = 1
problem_name = 'zdt'
problem_number = 6

# To account for the fact that the zero index array in util functions
# are actually the 1st feval
pop_size = 24
seed = 33
default_rf = 3

# i is the problem number chosen
i = 4
dim = 30
problem_function = getattr(pg.problems, problem_name)
problem = pg.problem(problem_function(i, param=dim))

max_fevals = 110

working_fevals = max_fevals-1

file_string = '/Users/rogerko/dev/Opossum/benchmark/csv/benchmark_problem' + str(i) + '_dvar' + str(dim) + '.txt'
stream = open(file_string, 'a')
hv_rbfmopt_plot = calculate_mean_rbf(n, max_fevals, working_fevals, seed, problem, default_rf, output_stream=stream)
stream.close()

csv_file_string = '/Users/rogerko/dev/Opossum/benchmark/csv/benchmark_problem' + str(i) + '_dvar' + str(dim) + '.csv'

# load the txt file and gen csv
gen_csv(file_string, csv_file_string)
working_fevals = max_fevals - 1
pop_size = 24
seed = 33

# For the each problem in the problem suite
for i in range(problem_number):
    problem_function = getattr(pg.problems, problem_name)
    if (problem_name == "dtlz"):
        problem = pg.problem(problem_function(i + 1, dim=dim, fdim=fdim))
    else:
        problem = pg.problem(problem_function(i + 1, param=dim))
    algo_moead = pg.algorithm(pg.moead(gen=1))
    algo_nsga2 = pg.algorithm(pg.nsga2(gen=1))

    # Hypervolume calculations, mean taken over n number of times
    hv_rbfmopt_plot = calculate_mean_rbf(n, max_fevals, working_fevals, seed,
                                         problem, cycle)
    hv_moead_plot = calculate_mean_pyg(n, algo_moead, working_fevals, pop_size,
                                       seed, problem)
    hv_nsga2_plot = calculate_mean_pyg(n, algo_nsga2, working_fevals, pop_size,
                                       seed, problem)
    fevals_plot = range(0, max_fevals)

    save_values(
        'storedvalues/rbfmopt_hv_' + problem.get_name() + '_fevals' +
        str(max_fevals) + '.txt', hv_rbfmopt_plot.tolist())
    save_values(
        'storedvalues/moead_hv_' + problem.get_name() + '_fevals' +
        str(max_fevals) + '.txt', hv_moead_plot.tolist())
    save_values(
        'storedvalues/nsga2_hv_' + problem.get_name() + '_fevals' +
        str(max_fevals) + '.txt', hv_nsga2_plot.tolist())
problem_number = 6

# max_fevals = (dim+1) * 50
max_fevals = 30

# To account for the fact that the zero index array in util functions
# are actually the 1st feval
working_fevals = max_fevals-1
pop_size = 24
seed = 33

cycle = 3
max_filter = 3

# For the each problem in the problem suite
for i in range(problem_number):
    if i == 4:
        continue

    problem_function = getattr(pg.problems, problem_name)

    problem = pg.problem(problem_function(i+1, param=dim))

    hv_rbfmopt_plot = calculate_mean_rbf(n, max_fevals, working_fevals, seed, problem, cycle, None)
    save_values('store_hv/rbfmopt_hv_ncycle' + str(cycle) + '_filter' + 'None' + '_fevals' + str(max_fevals) + problem.get_name() + '.txt', hv_rbfmopt_plot.tolist())

    for j in range(3):
        hv_rbfmopt_plot = calculate_mean_rbf(n, max_fevals, working_fevals, seed, problem, cycle, (j+1)*max_filter*dim)
        save_values('store_hv/rbfmopt_hv_ncycle' + str(cycle) + '_filter' + str((j+1)*max_filter*dim) + '_fevals' + str(max_fevals) + problem.get_name() + '.txt', hv_rbfmopt_plot.tolist())