def main(): suite = 'rw-top-trumps' function = 5 instance = 5 dim = 128 nobj = 1 rep = 2000 name = suite + '_f' + str(function) + 'i' + str(instance) + 'd' + str(dim) problem = tt_problem(suite, name, dim, nobj, function, instance, rep) minimize_plot(problem, random_search(10000), name + '_10k64', num_retries=64) minimize_plot(problem, Cma_cpp(10000), name + '_10k64', num_retries=64) minimize_plot(problem, De_cpp(10000), name + '_10k64', num_retries=64) minimize_plot(problem, Bite_cpp(10000, M=16), name + '_10k64', num_retries=64) suite = 'rw-top-trumps-biobj' function = 3 instance = 5 dim = 128 nobj = 2 rep = 2000 name = suite + '_f' + str(function) + 'i' + str(instance) + 'd' + str(dim) problem = tt_problem(suite, name, dim, nobj, function, instance, rep) mo_minimize_plot(problem, random_search(4000), name + '_4k512', num_retries=512) mo_minimize_plot(problem, Cma_cpp(4000), name + '_4k512', num_retries=512) mo_minimize_plot(problem, De_cpp(4000), name + '_4k512', num_retries=512) mo_minimize_plot(problem, Bite_cpp(4000, M=16), name + '_4k512', num_retries=512) mode.minimize_plot(name, problem.fun, problem.bounds, 2, popsize=200, nsga_update=True, max_eval=1000000) mode.minimize_plot(name, problem.fun, problem.bounds, 2, popsize=200, nsga_update=False, max_eval=1000000)
def test_cma_cordinated_retry(dim=6): # coordinated retry with CMA-ES optimizer with reduced popsize # faster for small dimension, use default for dim > 12 return advretry.minimize(problem.fun, problem.bounds, logger=logger(), optimizer=Cma_cpp(2000, popsize=13))
def test_gclde_cordinated_retry(problem): # coordinated retry with GCLDE->CMA sequence optimizer return advretry.minimize(problem.fun, problem.bounds, logger=logger(), optimizer=Sequence( [GCLDE_cpp(750), Cma_cpp(750, popsize=13)]))
def test_gclde_cordinated_retry(dim=6): # coordinated retry with GCLDE->CMA sequence optimizer return advretry.minimize(obj_f_c, bounds(dim), logger=logger(), optimizer=Sequence( [GCLDE_cpp(750), Cma_cpp(750, popsize=13)]))
def de_pyg_cma(max_evaluations=50000, popsize=31, stop_fitness=-math.inf, de_max_evals=None, cma_max_evals=None): """Sequence de c++ -> cmaes pagmo.""" deEvals = np.random.uniform(0.1, 0.3) if de_max_evals is None: de_max_evals = int(deEvals * max_evaluations) if cma_max_evals is None: cma_max_evals = int((1.0 - deEvals) * max_evaluations) opt1 = De_pyg(popsize=popsize, max_evaluations=de_max_evals, stop_fitness=stop_fitness) opt2 = Cma_cpp(popsize=popsize, max_evaluations=cma_max_evals, stop_fitness=stop_fitness) return Sequence([opt1, opt2])
problems = [ Cassini1(), Cassini2(), Rosetta(), Tandem(5), Messenger(), Gtoc1(), MessFull(), Sagas(), Cassini1minlp() ] algos = [ de2_cma(min_evals), de_cma(min_evals), da_cma(min_evals), Cma_cpp(min_evals), De_cpp(min_evals), Hh_cpp(min_evals), Da_cpp(min_evals), Dual_annealing(min_evals), Differential_evolution(min_evals) ] def messengerFullLoop(opt, num, max_time=1200, log=logger()): problem = MessFull() minimizers = None # remote actors created by minimize will be reused log.info(problem.name + ' ' + opt.name) for i in range(num): ret, minimizers = minimize(problem.fun, problem.bounds,
# Copyright (c) Dietmar Wolz. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory. import math from fcmaes.astro import MessFull, Messenger, Gtoc1, Cassini1, Cassini2, Rosetta, Tandem, Sagas from fcmaes.optimizer import logger, de_cma, da_cma, Cma_cpp, De_cpp, Da_cpp, Dual_annealing, Differential_evolution from fcmaes.retry import minimize problems = [Cassini1(), Cassini2(), Rosetta(), Tandem(5), Messenger(), Gtoc1(), MessFull(), Sagas()] max_evals = 50000 algos = [de_cma(max_evals), da_cma(max_evals), Cma_cpp(max_evals), De_cpp(max_evals), Da_cpp(max_evals), Dual_annealing(max_evals), Differential_evolution(max_evals)] def test_all(num_retries = 10000, num = 10): for problem in problems: for algo in algos: _test_optimizer(algo, problem, num_retries, num) def _test_optimizer(opt, problem, num_retries = 32, num = 10): log = logger() log.info(problem.name + ' ' + opt.name) for _ in range(num): ret = minimize(problem.fun, problem.bounds, math.inf, num_retries, log, optimizer=opt) def main(): test_all()
Rosetta(), Tandem(5), Messenger(), Gtoc1(), MessFull(), Sagas(), Cassini1minlp() ] max_evals = 50000 algos = [ de_cma(max_evals), de2_cma(max_evals), da_cma(max_evals), Cma_cpp(max_evals), De_cpp(max_evals), Hh_cpp(max_evals), Da_cpp(max_evals), Bite_cpp(max_evals), Csma_cpp(max_evals), Dual_annealing(max_evals), Differential_evolution(max_evals) ] def test_all(num_retries=10000, num=1): for problem in problems: for algo in algos: _test_optimizer(algo, problem, num_retries, num)