@@ -4,44 +4,54 @@ import BlackBoxOptimizationBenchmarking.Chain
44const BBOB = BlackBoxOptimizationBenchmarking
55
66using OptimizationBBO, OptimizationOptimJL, OptimizationEvolutionary, OptimizationNLopt
7- using OptimizationMetaheuristics, OptimizationNOMAD, OptimizationPRIMA, OptimizationOptimisers
7+ using OptimizationMetaheuristics, OptimizationNOMAD, OptimizationPRIMA, OptimizationOptimisers, OptimizationSciPy, OptimizationPyCMA
88
99
10- chain = (t; isboxed= false ) -> Chain (
10+ chain = (t;
11+ isboxed = false ) -> Chain (
1112 BenchmarkSetup (t, isboxed = isboxed),
1213 BenchmarkSetup (NelderMead (), isboxed = false ),
1314 0.9
1415)
1516
1617test_functions = BBOB. list_functions ()
1718dimension = 3
18- run_length = round .(Int, 10 .^ LinRange (1 ,5 , 30 ))
19+ run_length = round .(Int, 10 .^ LinRange (1 , 5 , 30 ))
1920
20- @memoize run_bench (algo) = BBOB. benchmark (setup[algo], test_functions, run_length, Ntrials= 40 , dimension = dimension)
21+ @memoize run_bench (algo) = BBOB. benchmark (
22+ setup[algo], test_functions, run_length, Ntrials = 40 , dimension = dimension)
2123
2224
2325setup = Dict (
2426 " NelderMead" => NelderMead (),
2527 # Optim.BFGS(),
2628 # "NLopt.GN_MLSL_LDS" => chain(NLopt.GN_MLSL_LDS(), isboxed=true), # gives me errors
27- " NLopt.GN_CRS2_LM()" => chain (NLopt. GN_CRS2_LM (), isboxed= true ),
28- " NLopt.GN_DIRECT()" => chain (NLopt. GN_DIRECT (), isboxed= true ),
29- " NLopt.GN_ESCH()" => chain (NLopt. GN_ESCH (), isboxed= true ),
30- " OptimizationEvolutionary.GA()" => chain (OptimizationEvolutionary. GA (), isboxed= true ),
31- " OptimizationEvolutionary.DE()" => chain (OptimizationEvolutionary. DE (), isboxed= true ),
32- " OptimizationEvolutionary.ES()" => chain (OptimizationEvolutionary. ES (), isboxed= true ),
33- " Optim.SAMIN" => chain (SAMIN (verbosity= 0 ), isboxed= true ),
34- " BBO_adaptive_de_rand_1_bin" => chain (BBO_adaptive_de_rand_1_bin (), isboxed= true ),
35- " BBO_adaptive_de_rand_1_bin_radiuslimited" => chain (BBO_adaptive_de_rand_1_bin_radiuslimited (), isboxed= true ), # same as BBO_adaptive_de_rand_1_bin
36- " BBO_separable_nes" => chain (BBO_separable_nes (), isboxed= true ),
37- " BBO_de_rand_2_bin" => chain (BBO_de_rand_2_bin (), isboxed= true ),
29+ " NLopt.GN_CRS2_LM()" => chain (NLopt. GN_CRS2_LM (), isboxed = true ),
30+ " NLopt.GN_DIRECT()" => chain (NLopt. GN_DIRECT (), isboxed = true ),
31+ " NLopt.GN_ESCH()" => chain (NLopt. GN_ESCH (), isboxed = true ),
32+ " OptimizationEvolutionary.GA()" => chain (OptimizationEvolutionary. GA (), isboxed = true ),
33+ " OptimizationEvolutionary.DE()" => chain (OptimizationEvolutionary. DE (), isboxed = true ),
34+ " OptimizationEvolutionary.ES()" => chain (OptimizationEvolutionary. ES (), isboxed = true ),
35+ " Optim.SAMIN" => chain (SAMIN (verbosity = 0 ), isboxed = true ),
36+ " BBO_adaptive_de_rand_1_bin" => chain (BBO_adaptive_de_rand_1_bin (), isboxed = true ),
37+ " BBO_adaptive_de_rand_1_bin_radiuslimited" => chain (
38+ BBO_adaptive_de_rand_1_bin_radiuslimited (), isboxed = true ), # same as BBO_adaptive_de_rand_1_bin
39+ " BBO_separable_nes" => chain (BBO_separable_nes (), isboxed = true ),
40+ " BBO_de_rand_2_bin" => chain (BBO_de_rand_2_bin (), isboxed = true ),
3841 # "BBO_xnes" => chain(BBO_xnes(), isboxed=true), # good but slow
3942 # "BBO_dxnes" => chain(BBO_dxnes(), isboxed=true),
40- " OptimizationMetaheuristics.ECA" => chain (OptimizationMetaheuristics. ECA (), isboxed= true ),
43+ " OptimizationMetaheuristics.ECA" => chain (OptimizationMetaheuristics. ECA (), isboxed = true ),
4144 # "OptimizationMetaheuristics.CGSA" => () -> chain(OptimizationMetaheuristics.CGSA(), isboxed=true), #give me strange results
4245 " OptimizationMetaheuristics.DE" => chain (OptimizationMetaheuristics. DE (), isboxed= true ),
4346 " Optimisers.AdamW" => chain (Optimisers. AdamW (), isboxed= false ),
4447 " Optimisers.RMSProp" => chain (Optimisers. RMSProp (), isboxed= false ),
48+ # SciPy global optimizers
49+ " ScipyDifferentialEvolution" => chain (ScipyDifferentialEvolution (), isboxed= true ),
50+ # "ScipyBasinhopping" => chain(ScipyBasinhopping(), isboxed=true),
51+ # "ScipyDualAnnealing" => chain(ScipyDualAnnealing(), isboxed=true), # taking long time
52+ " ScipyShgo" => chain (ScipyShgo (), isboxed= true ),
53+ " ScipyDirect" => chain (ScipyDirect (), isboxed= true ),
54+ " ScipyBrute" => chain (ScipyBrute (), isboxed= true ),
4555 # "NOMADOpt" => chain(NOMADOpt()), too much printing
4656 # "OptimizationPRIMA.UOBYQA()" => chain(OptimizationPRIMA.UOBYQA()), :StackOverflowError?
4757 # "OptimizationPRIMA.NEWUOA()" => OptimizationPRIMA.UOBYQA(),
@@ -50,8 +60,8 @@ setup = Dict(
5060
5161
5262@time b = BBOB. benchmark (
53- chain (OptimizationMetaheuristics. CGSA (), isboxed= true ),
54- test_functions[1 : 10 ], 100 : 500 : 10_000 , Ntrials= 10 , dimension = 3
63+ chain (OptimizationMetaheuristics. CGSA (), isboxed = true ),
64+ test_functions[1 : 10 ], 100 : 500 : 10_000 , Ntrials = 10 , dimension = 3
5565)
5666
5767plot (b)
@@ -60,41 +70,44 @@ plot(b)
6070Δf = 1e-6
6171f = test_functions[3 ]
6272
63- single_setup = BenchmarkSetup (NLopt. GN_CRS2_LM (), isboxed= true )
73+ single_setup = BenchmarkSetup (NLopt. GN_CRS2_LM (), isboxed = true )
6474
6575sol = [BBOB. solve_problem (single_setup, f, 3 , 5_000 ) for in in 1 : 10 ]
6676@info [sol. objective < Δf + f. f_opt for sol in sol]
6777
68- p = plot (f, size = (600 ,600 ), zoom = 1.5 )
78+ p = plot (f, size = (600 , 600 ), zoom = 1.5 )
6979for sol in sol
70- scatter! (sol. u[1 : 1 ], sol. u[2 : 2 ], label= " " , c= " blue" , marker = :xcross , markersize= 5 , markerstrokewidth= 0 )
80+ scatter! (sol. u[1 : 1 ], sol. u[2 : 2 ], label = " " , c = " blue" ,
81+ marker = :xcross , markersize = 5 , markerstrokewidth = 0 )
7182end
7283p
7384
7485
7586results = Array {BBOB.BenchmarkResults} (undef, length (setup))
7687
77- Threads. @threads for (i,algo) in collect (enumerate (keys (setup)))
88+ Threads. @threads for (i, algo) in collect (enumerate (keys (setup)))
7889 results[i] = run_bench (algo)
7990end
8091
8192results
8293
8394
8495labels = collect (keys (setup))
85- idx = sortperm ([b. success_rate[end ] for b in results], rev= true )
96+ idx = sortperm ([b. success_rate[end ] for b in results], rev = true )
8697
87- p = plot (xscale = :log10 , legend = :outerright , size = (700 ,350 ), margin= 10 Plots. px, dpi= 200 )
98+ p = plot (xscale = :log10 , legend = :outerright ,
99+ size = (700 , 350 ), margin = 10 Plots. px, dpi = 200 )
88100for i in idx
89- plot! (results[i], label = labels[i], showribbon= false , lw= 2.5 , xlim = (1 ,1e5 ), x = :run_length )
101+ plot! (results[i], label = labels[i], showribbon = false ,
102+ lw = 2.5 , xlim = (1 , 1e5 ), x = :run_length )
90103end
91104p
92105
93106
94107success_rate_per_function = reduce (hcat, b. success_rate_per_function for b in results)
95108
96- idx = sortperm (mean (success_rate_per_function, dims= 1 )[:], rev= false )
97- idxfunc = sortperm (mean (success_rate_per_function, dims= 2 )[:], rev= true )
109+ idx = sortperm (mean (success_rate_per_function, dims = 1 )[:], rev = false )
110+ idxfunc = sortperm (mean (success_rate_per_function, dims = 2 )[:], rev = true )
98111idxfunc = 1 : length (test_functions)
99112
100113p = heatmap (
@@ -103,18 +116,19 @@ p = heatmap(
103116 xticks = :all ,
104117 yticks = :all ,
105118 xrotation = 45 ,
106- dpi = 200 ,
119+ dpi = 200
107120)
108121
109122
110123labels = collect (keys (setup))
111- idx = sortperm ([b. distance_to_minimizer[end ] for b in results], rev= false )
124+ idx = sortperm ([b. distance_to_minimizer[end ] for b in results], rev = false )
112125
113- p = plot (xscale = :log10 , legend = :outerright , size = (900 ,500 ), margin= 10 Plots. px, ylim = (0 ,5 ))
126+ p = plot (xscale = :log10 , legend = :outerright ,
127+ size = (900 , 500 ), margin = 10 Plots. px, ylim = (0 , 5 ))
114128for i in idx
115129 plot! (
116130 results[i]. run_length, results[i]. distance_to_minimizer, label = labels[i],
117- showribbon= false , lw= 2 , xlim = (1 ,1e5 ),
131+ showribbon = false , lw = 2 , xlim = (1 , 1e5 ),
118132 xlabel = " Iterations" , ylabel = " Mean distance to minimum"
119133 )
120134end
@@ -127,7 +141,7 @@ runtimes = runtimes ./ runtimes[ref]
127141
128142bar (
129143 labels, runtimes, xrotation = :45 , xticks = :all , ylabel = " Run time relative to NM" ,
130- yscale = :log10 , yticks = [0.1 ,1 , 10 ,100 ],
144+ yscale = :log10 , yticks = [0.1 , 1 , 10 , 100 ],
131145 legend = false , margin = 25 Plots. px
132146)
133147
0 commit comments