Comparing the Optimization MethodsΒΆ

[1]:
# import libraries
import jax.numpy as jnp
from optymus.benchmark import methods_comparison
[2]:
from optymus.benchmark import Himmeblau

# define the objective function
f = Himmeblau()

# define the initial point
initial_point = jnp.array([0, 5])

f.plot(n_levels=400)
[3]:
comparison = methods_comparison(f, initial_point, max_iter=10)
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15/15 [00:32<00:00,  2.17s/it]
[4]:
comparison['results']
[4]:
method x_opt f_min n_iter time
0 Simulated Annealing [0.32033302586059254, 2.4544921015415784] 71.7116726081363 10 0.030990
1 RMSprop [-0.010561838806563152, -0.0031040063186497805] 170.21368514446 10 0.048882
2 Yogi [-0.09990946851075325, 4.900401054441406] 323.167543001664 10 0.055044
3 Steepest Descent [-2.8051180808608414, 3.131312517644538] 1.2151348386129352e-15 5 0.056394
4 Adam [-0.10002170260609496, 4.900286739219162] 323.12696700142453 10 0.058388
5 Adagrad [-0.050242196055189405, 4.950201257401999] 341.220381728216 10 0.058709
6 Adamax [-0.04135715608859208, 4.958694311673667] 344.3841718367512 10 0.064358
7 BFGS [-2.8051180871259866, 3.1313125182455286] 9.768169503529298e-19 5 0.084228
8 Univariant [-2.8051180976907424, 3.1313125184240542] 3.74326772617301e-15 3 0.096652
9 Conjugate Gradients (fletcher_reeves) [-2.8051180868544643, 3.131312518243001] 3.1501007730135215e-19 4 0.111740
10 CMA-ES [2.626421342019817, 1.9941089665304592] 4.60052396806301 10 0.198422
11 Powell [-2.805118086953216, 3.1313125182501516] 1.4604973954705433e-23 3 0.225448
12 Newton-Raphson [2.999999999996896, 2.0000000000133182] 2.545076537982263e-21 5 0.323272
13 Particle Swarm Optimization [2.9997535366935963, 1.9999350090290782] 2.639504986103008e-06 10 0.528195
14 Differential Evolution [2.8904660319151163, 2.0965468814572383] 0.3828085776663928 10 1.295606
[5]:
from optymus.plots import plot_optim

plot_optim(f_obj=f, x0=initial_point, comparison=comparison, n=200)