def test_all(num_retries = 4000, num = 20): # test C++ version _test_problem(Cassini1(), num_retries, num, useCpp = True) _test_problem(Cassini2(), num_retries, num, useCpp = True) _test_problem(Rosetta(), num_retries, num, useCpp = True) _test_problem(Messenger(), num_retries, num, useCpp = True) _test_problem(Gtoc1(), num_retries, num, value_limit = -1000000, useCpp = True) _test_problem(MessFull(), num_retries, num, value_limit = 10.0, useCpp = True) # test python version _test_problem(Cassini1(), num_retries, num) _test_problem(Cassini2(), num_retries, num) _test_problem(Rosetta(), num_retries, num) _test_problem(Messenger(), num_retries, num) _test_problem(Gtoc1(), num_retries, num, value_limit = -1000000) _test_problem(MessFull(), num_retries, num, value_limit = 10.0) # test dual annealing _test_optimizer("dual_annealing", Cassini1(), num_retries, num) _test_optimizer("dual_annealing", Cassini2(), num_retries, num) _test_optimizer("dual_annealing", Rosetta(), num_retries, num) _test_optimizer("dual_annealing", Messenger(), num_retries, num) _test_optimizer("dual_annealing", Gtoc1(), num_retries, num, value_limit = -200000) _test_optimizer("dual_annealing", MessFull(), num_retries, num) # test differential evolution _test_optimizer("differential_evolution", Cassini1(), num_retries, num) _test_optimizer("differential_evolution", Cassini2(), num_retries, num) _test_optimizer("differential_evolution", Rosetta(), num_retries, num) _test_optimizer("differential_evolution", Messenger(), num_retries, num) _test_optimizer("differential_evolution", Gtoc1(), num_retries, num, value_limit = -200000) _test_optimizer("differential_evolution", MessFull(), num_retries, num)
def getFunctionDetails(a): # [name, lb, ub, dim] param = { "F1": ["F1",-100,100,30], "F2" : ["F2",-10,10,30], "F3" : ["F3",-100,100,30], "F4" : ["F4",-100,100,30] , "F5" : ["F5",-30,30,30], "F6" : ["F6",-100,100,30], "F7" : ["F7",-1.28,1.28,30], "F8" : ["F8",-500,500,30], "F9" : ["F9",-5.12,5.12,30], "F10" : ["F10",-32,32,30], "F11" : ["F11",-600,600,30] , "F12" : ["F12",-50,50,30], "F13" : ["F13",-50,50,30], "F14" : ["F14",-65.536,65.536,2], "F15" : ["F15",-5,5,4], "F16" : ["F16",-5,5,2], "F17" : ["F17",-5,15,2], "F18" : ["F18",-2,2,2] , "F19" : ["F19",0,1,3], "F20" : ["F20",0,1,6], "F21" : ["F21",0,10,4], "F22" : ["F22",0,10,4], "F23" : ["F23",0,10,4], "Ca1" : ["Ca1",Cassini1().bounds.lb,Cassini1().bounds.ub,len(Cassini1().bounds.lb)], "Ca2" : ["Ca2",Cassini2().bounds.lb,Cassini2().bounds.ub,len(Cassini2().bounds.lb)], "Gt1" : ["Gt1",Gtoc1().bounds.lb,Gtoc1().bounds.ub,len(Gtoc1().bounds.lb)], "Mes" : ["Mes",Messenger().bounds.lb,Messenger().bounds.ub,len(Messenger().bounds.lb)], "Mef" : ["Mef",MessFull().bounds.lb,MessFull().bounds.ub,len(MessFull().bounds.lb)], "Sag" : ["Sag",Sagas().bounds.lb,Sagas().bounds.ub,len(Sagas().bounds.lb)], "Tan" : ["Tan",Tandem(5).bounds.lb,Tandem(5).bounds.ub,len(Tandem(5).bounds.lb)], "Ros" : ["Ros",Rosetta().bounds.lb,Rosetta().bounds.ub,len(Rosetta().bounds.lb)], } return param.get(a, "nothing")
def test_coordinated_retry(): numRuns = 10 min_evals = 1500 algo = de_cma_pyg(min_evals) #algo = pyg_de_cma(min_evals) #algo = de_pyg_cma(min_evals) fac = 1.005 _test_optimizer(algo, Gtoc1(), num_retries=10000, num=numRuns, value_limit=-300000.0, stop_val=-1581950 / fac) _test_optimizer(algo, Cassini1(), num_retries=4000, num=numRuns, value_limit=20.0, stop_val=4.9307 * fac) _test_optimizer(algo, Cassini2(), num_retries=6000, num=numRuns, value_limit=20.0, stop_val=8.383 * fac) _test_optimizer(algo, Messenger(), num_retries=8000, num=numRuns, value_limit=20.0, stop_val=8.63 * fac) _test_optimizer(algo, Rosetta(), num_retries=4000, num=numRuns, value_limit=20.0, stop_val=1.3433 * fac) _test_optimizer(algo, Sagas(), num_retries=4000, num=numRuns, value_limit=100.0, stop_val=18.187 * fac) _test_optimizer(algo, Tandem(5), num_retries=20000, num=numRuns, value_limit=-300.0, stop_val=-1500.6 / fac) _test_optimizer(algo, MessFull(), num_retries=50000, num=numRuns, value_limit=12.0, stop_val=1.959 * fac)
def main(): numRuns = 100 min_evals = 1500 _test_optimizer(de_cma(min_evals), Gtoc1(), num_retries=10000, num=numRuns, value_limit=-300000.0, stop_val=-1581949) _test_optimizer(de_cma(min_evals), Cassini1(), num_retries=4000, num=numRuns, value_limit=20.0, stop_val=4.93075) _test_optimizer(de_cma(min_evals), Cassini2(), num_retries=6000, num=numRuns, value_limit=20.0, stop_val=8.38305) _test_optimizer(de_cma(min_evals), Messenger(), num_retries=8000, num=numRuns, value_limit=20.0, stop_val=8.62995) _test_optimizer(de_cma(min_evals), Rosetta(), num_retries=4000, num=numRuns, value_limit=20.0, stop_val=1.34335) _test_optimizer(de_cma(min_evals), Sagas(), num_retries=4000, num=numRuns, value_limit=100.0, stop_val=18.188) _test_optimizer(de_cma(min_evals), Tandem(5), num_retries=20000, num=numRuns, value_limit=-300.0, stop_val=-1500) _test_optimizer(de_cma(min_evals), MessFull(), num_retries=50000, num=numRuns, value_limit=12.0, stop_val=1.960)
def test_archipelago(): max_evals = 500000 popsize = 32 gen = int(max_evals / popsize + 1) algo = pg.algorithm(pg.de1220(gen=gen)) fac = 1.005 _test_archipelago(algo, Cassini1(), num=400, stop_val=4.9307 * fac) _test_archipelago(algo, Cassini2(), num=600, stop_val=8.383 * fac) _test_archipelago(algo, Gtoc1(), num=1000, stop_val=-1581950 / fac) _test_archipelago(algo, Messenger(), num=800, stop_val=8.63 * fac) _test_archipelago(algo, Rosetta(), num=400, stop_val=1.3433 * fac) _test_archipelago(algo, Sagas(), num=400, stop_val=18.187 * fac) _test_archipelago(algo, Tandem(5), num=2000, stop_val=-1500.6 / fac) _test_archipelago(algo, MessFull(), num=5000, stop_val=1.959 * fac)
def Ca2(x): return Cassini2().fun(x)
# LICENSE file in the root directory. # Examples for fcmaes multinode coordinated retry from https://www.esa.int/gsp/ACT/projects/gtop/ import ray from fcmaes.astro import MessFull, Messenger, Cassini2, Rosetta, Gtoc1, Cassini1, Tandem, Sagas, Cassini1minlp from fcmaes.optimizer import logger, de_cma, de2_cma, da_cma, Cma_cpp, De_cpp, Da_cpp, Hh_cpp, Dual_annealing, Differential_evolution, GCLDE_cpp, LCLDE_cpp, LDe_cpp, Sequence from fcmaesray.rayretry import minimize min_evals = 1500 max_nodes = 100 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),
# 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()
def __init__(self): self.base = Cassini2() self.bounds = self.base.bounds self.weight_bounds = Bounds([1, 0.01], [100, 1]) # weighting of objectives self.name = self.base.name