예제 #1
0
STOPPING_RULE = 'max_eval'
MAX_EVAL = 400
MUTATION_RATE = 0.1
MUTATION_U = 0.
MUTATION_ST = 0.2
REF = [1., 1.]

# Load theoritical values
theo = PROBLEM.solutions()

pop = GOMORS(problem=PROBLEM,
             dim=DIMENSION,
             size=POP_SIZE,
             n_objs=N_OBJS,
             max_generation=MAX_GENERATION,
             max_episode=MAX_EPISODE,
             reference=REF,
             minimize=MINIMIZE,
             stopping_rule=STOPPING_RULE,
             max_eval=MAX_EVAL,
             revolution=False)
pop.selection_fun = pop.compute_front
pop.mutation_fun = gaussian_mutator
pop.crossover_fun = multiroutine_crossover(
    routines=[nsga_crossover, random_crossover], ns=[1., 1.])
pop.embedded_ea = NSGA2
pop.mutaton_rate = MUTATION_RATE

# Parametrization
params_ea = {
    'u': MUTATION_U,
예제 #2
0
DIMENSION = 30
POP_SIZE = 64
N_OBJS = 2
MAX_GENERATION = 30
MAX_EPISODE = 120
STOPPING_RULE = 'max_eval'
MUTATION_RATE = 0.1
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,
             stopping_rule=STOPPING_RULE)
pop.selection_fun = pop.compute_front
pop.mutation_fun = gaussian_mutator
pop.bounds.append([0., 1.])
pop.crossover_fun = nsga_crossover
pop.mutaton_rate = MUTATION_RATE
pop.verbose = True

# Parametrization
region = 0
params_ea = {
    'u': MUTATION_U,
예제 #3
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
예제 #4
0
# Kursawe
PM_FUN = kursawe
MINIMIZE = True
DIMENSION = 3
N_OBJS = 2
POP_SIZE = 64
MAX_GENERATION = 40
MAX_EPISODE = 60
MUTATION_RATE = 0.1
MUTATION_U = 0.
MUTATION_ST = 0.7
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)
pop.mutation_fun = gaussian_mutator
pop.bounds.append([-5., 5.])
pop.crossover_fun = nsga_crossover
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': (4, 8),
     'activation': 'relu',
예제 #5
0
POP_SIZE = 64
N_OBJS = 2
MAX_GENERATION = 40
MAX_EPISODE = 50
STOPPING_RULE = 'max_eval'
MAX_EVAL = 2500
MUTATION_RATE = 0.1
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,
             stopping_rule=STOPPING_RULE,
             max_eval=MAX_EVAL)
pop.selection_fun = pop.compute_front
pop.mutation_fun = gaussian_mutator
pop.bounds = np.repeat([[0., 1.], [-5., 5.]], [1, DIMENSION - 1], axis=0)
pop.crossover_fun = multiroutine_crossover(
    routines=[nsga_crossover, random_crossover], ns=[1., 1.5])
pop.mutaton_rate = MUTATION_RATE

# Parametrization
params_ea = {
    'u': MUTATION_U,
    'st': MUTATION_ST,