예제 #1
0
MUTATION_ST = 0.3
REF = [-14., 0.1]

pop = GOMORS(dim=DIMENSION,
             size=POP_SIZE,
             n_objs=N_OBJS,
             fitness_fun=PM_FUN,
             max_generation=MAX_GENERATION,
             max_episode=MAX_EPISODE,
             reference=REF,
             minimize=MINIMIZE,
             stopping_rule=STOPPING_RULE,
             max_eval=MAX_EVAL)
pop.mutation_fun = gaussian_mutator
pop.bounds.append([-5., 5.])
pop.crossover_fun = multiroutine_crossover(
    routines=[nsga_crossover, random_crossover], ns=[1., 1.])
pop.mutaton_rate = MUTATION_RATE

# Parametrization
params_ea = {
    'u': MUTATION_U,
    'st': MUTATION_ST,
    'trial_method': 'lhs',
    'trial_criterion': 'cm'
}
params_surrogate = \
    {'hidden_layer_sizes': (6, ),
     'activation': 'relu',
     'solver': 'adam',
     'early_stopping': False,
     'batch_size': 4,
예제 #2
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
예제 #3
0
MUTATION_U = 0.
MUTATION_ST = 0.2
REF = [1., 1.]

pop = GOMORS(dim=DIMENSION,
             size=POP_SIZE,
             n_objs=N_OBJS,
             fitness_fun=PM_FUN,
             max_generation=MAX_GENERATION,
             max_episode=MAX_EPISODE,
             reference=REF,
             minimize=MINIMIZE)
pop.selection_fun = pop.compute_front
pop.mutation_fun = gaussian_mutator
pop.regions.append([0., 1.])
pop.crossover_fun = nsga_crossover
pop.mutaton_rate = MUTATION_RATE
pop.verbose = True

# Parametrization
region = 0
params_ea = {
    'u': MUTATION_U,
    'st': MUTATION_ST,
    '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))
예제 #4
0
MUTATION_ST = 0.2
REF = [1., 1.]

pop = GOMORS(dim=DIMENSION,
             size=POP_SIZE,
             n_objs=N_OBJS,
             fitness_fun=PM_FUN,
             max_generation=MAX_GENERATION,
             max_episode=MAX_EPISODE,
             reference=REF,
             minimize=MINIMIZE,
             stopping_rule=STOPPING_RULE)
pop.selection_fun = pop.compute_front
pop.mutation_fun = gaussian_mutator
pop.bounds.append([0., 1.])
pop.crossover_fun = random_crossover
pop.mutaton_rate = MUTATION_RATE

# Parametrization
params_ea = {
    'u': MUTATION_U,
    'st': MUTATION_ST,
    '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,