Exemple #1
0
# Sampling configs
samplers = [
    pop.random_sampling,
    pop.random_sampling,
    pop.hv_improvement_sampling,
    pop.max_mini_x_dist_sampling,
    pop.max_mini_y_dist_sampling,
    pop.hv_improvement_sampling,
]
sample_sizes = [1] * 6
sample_rates = [0.1, 0.8, 0.6, 0.6, 0.6, 1.]
sample_candidates = ['decision_space', 'pop'] + ['pm_hat'] * 3 + ['gap']

# ===============================Initialization================================

pop.config_surrogate(typ='rbf', params=params_surrogate, n_process=2)
pop.config_gap_opt(at='least_crowded',
                   radius=0.1,
                   size=POP_SIZE,
                   max_generation=MAX_GENERATION,
                   selection_fun=None,
                   mutation_fun=None,
                   mutation_rate=None,
                   crossover_fun=nsga_crossover,
                   trial_method='lhs',
                   trial_criterion='cm',
                   u=0.,
                   st=0.2)

#pop.config_sampling(methods=samplers, sizes=sample_sizes,
#                    sample_rates=sample_rates,
Exemple #2
0
     'batch_size': 4,
     'warm_start': True,
     'beta_1': 0.9,
     'beta_2': 0.999,
     'epsilon': 1e-12,
     'alpha': 0.00001,
     'learning_rate': 'adaptive',
     'learning_rate_init': 0.002,
     'max_iter': 500,
     'verbose': False,
     'no_improvement_tol': 500,
     }

# ===============================Initialization================================

pop.config_surrogate(typ='ANN', params=params_surrogate)
pop.config_gap_opt(at='least_crowded',
                   radius=0.1,
                   size=2 * POP_SIZE,
                   max_generation=MAX_GENERATION,
                   selection_fun=None,
                   mutation_fun=None,
                   mutation_rate=None,
                   crossover_fun=nsga_crossover,
                   trial_method='lhs',
                   trial_criterion='cm',
                   u=0.,
                   st=0.02)
pop.config_sampling(methods='default',
                    sizes='default',
                    rate='default',
             'trial_method': 'lhs',
             'trial_criterion': 'cm'}

kernel = C(1.0, (1e-3, 1e3)) * RBF(1.0, (1e-3, 1e1)) + \
         W(noise_level=1e-8, noise_level_bounds=(1e-10, 1e-5))

params_surrogate = \
    {'kernel': kernel,
     'alpha': 0.,
     'optimizer': heuristic_optimizer,
     'normalize_y': True,
     }

# ===============================Initialization================================

pop.config_surrogate(typ='kriging', params=params_surrogate, n_process=2)
pop.config_gap_opt(at='least_crowded', radius=0.5, size=POP_SIZE,
                   max_generation=2*MAX_GENERATION, selection_fun=None,
                   mutation_fun=None, mutation_rate=None,
                   crossover_fun=None, trial_method='lhs',
                   trial_criterion='cm', u=0., st=0.12)
pop.config_sampling(methods='default', sizes='default', rate='default',
                    candidates='default')

pop.run(params_ea=params_ea, params_surrogate=params_surrogate, theo=theo)

# ================================Visualization================================
fig, (ax, ax_metric) = plt.subplots(1, 2, figsize=(10,4), dpi=100)

# Test surrogate results
final_arc = pop.true_front
Exemple #4
0
    'trial_method': 'lhs',
    'trial_criterion': 'cm'
}

kernel = C(1.0, (1e-3, 1e3)) * RBF(1e-1, (1e-4, 1.)) + \
         W(noise_level=1e-8, noise_level_bounds=(1e-10, 1e-5))

params_surrogate = \
    {'kernel': kernel,
     'alpha': 0.,
     'normalize_y': True,
     }

# ===============================Initialization================================

pop.config_surrogate(typ='kriging', params=params_surrogate)
pop.config_gap_opt(at='least_crowded',
                   radius=0.1,
                   size=2 * POP_SIZE,
                   max_generation=MAX_GENERATION,
                   selection_fun=None,
                   mutation_fun=None,
                   mutation_rate=None,
                   crossover_fun=random_crossover,
                   trial_method='lhs',
                   trial_criterion='cm',
                   u=0.,
                   st=0.02)
pop.config_sampling(methods='default',
                    sizes='default',
                    rate='default',
Exemple #5
0
def run_sim(n, path, simtitle, REVOLUTION, PROBLEM, seed):

    POP_SIZE = 100
    MAX_GENERATION = 50
    MAX_EPISODE = 100
    MAX_EVAL = 1000
    STOPPING_RULE = 'max_eval'
    MUTATION_RATE = 0.1
    MUTATION_U = 0.
    MUTATION_ST = 0.2
    REF = [-14.3, 0.05]
    MINIMIZE = True
    VERBOSE = True
    X_SCALER = StandardScaler()

    # Set global numpy random_state
    np.random.seed(seed)

    theo = np.genfromtxt('pareto_Kursawe.txt', dtype='f8')

    # Instantiate a population
    pop = GOMORS(size=POP_SIZE,
                 problem=PROBLEM,
                 max_generation=MAX_GENERATION,
                 max_episode=MAX_EPISODE,
                 reference=REF,
                 minimize=MINIMIZE,
                 stopping_rule=STOPPING_RULE,
                 max_eval=MAX_EVAL,
                 mutation_rate=MUTATION_RATE,
                 revolution=REVOLUTION,
                 embedded_ea=MOEAD,
                 verbose=VERBOSE,
                 no_improvement_step_tol=4)

    pop.selection_fun = pop.compute_front
    pop.mutation_fun = gaussian_mutator
    pop.crossover_fun = random_crossover

    # Parametrization
    params_ea = {
        'u': MUTATION_U,
        'st': MUTATION_ST,
        'trial_method': 'lhs',
        'trial_criterion': 'cm'
    }

    kernel = CubicKernel
    tail = LinearTail

    params_surrogate = \
        {'kernel': kernel,
         'tail': tail,
         'maxp': MAX_EVAL + POP_SIZE,
         'eta': 1e-8,
         }

    # ===============================Initialization============================
    pop.config_surrogate(typ='rbf',
                         params=params_surrogate,
                         n_process=1,
                         X_scaler=X_SCALER,
                         warm_start=True)

    pop.config_gap_opt(at='least_crowded',
                       radius=0.1,
                       size=POP_SIZE,
                       max_generation=MAX_GENERATION,
                       selection_fun=None,
                       mutation_fun=None,
                       mutation_rate=None,
                       crossover_fun=random_crossover,
                       trial_method='lhs',
                       trial_criterion='cm',
                       u=0.,
                       st=0.2)

    pop.config_sampling(methods='default',
                        sizes='default',
                        rate='default',
                        candidates='default')

    pop.run(params_ea=params_ea, params_surrogate=params_surrogate, theo=theo)

    # ============================= Save Results ================================ #
    # path to save
    directory = path + simtitle + '/' + str(n) + '/'
    if not os.path.exists(directory):
        os.makedirs(directory)
    pop.render_features(pop.true_front).tofile(directory + 'xs.dat')
    pop.render_targets(pop.true_front).tofile(directory + 'fs.dat')
    np.array(pop.hypervol_diff).tofile(directory + 'hv_diff.dat')
    np.array(pop.hypervol_cov).tofile(directory + 'hv_cov.dat')
    np.array(pop.hypervol_index).tofile(directory + 'hv_ind.dat')

    # ================================Visualization============================== #
    # plot_res(pop=pop, ref=theo, directory=directory)

    return pop
Exemple #6
0
# Parametrization
params_ea = {'u': MUTATION_U,
             'st': MUTATION_ST,
             'trial_method': 'lhs',
             'trial_criterion': 'cm'}

kernel = [CubicKernel, TPSKernel]
tail = LinearTail

params_surrogate = \
    {'kernel': kernel,
     'tail': tail,
     'maxp': 2000,
     'eta': 1e-8,
     }

# ===============================Initialization================================

pop.config_surrogate(typ='rbf', params=params_surrogate)
pop.config_gap_opt(at='least_crowded', radius=0.5, size=POP_SIZE,
                   max_generation=2*MAX_GENERATION, selection_fun=None,
                   mutation_fun=None, mutation_rate=None,
                   crossover_fun=None, trial_method='lhs',
                   trial_criterion='cm', u=0., st=0.12)
pop.config_sampling(methods='default', sizes='default', rate='default',
                    candidates='default')

pop.surrogate.fit(b, y)

pop.surrogate.benchmark(bounds=np.repeat(pop.bounds, 3, axis=0), dim=3, obj_fun=kursawe)