Evolutionary Optimization with HEBO API

Though we mainly focus on Bayesian optimsation algorithms, we also include evolutionary optimisation algorithms in HEBO, the evolutionary algorithm is a wrapper of algorithms from pymoo, below is an example that applies differential evolution algorithm to optimise the Ackley function.

[10]:
from hebo.design_space import DesignSpace
from hebo.optimizers.evolution import Evolution
from hebo.benchmarks.synthetic_benchmarks import Ackley
[11]:
prob = Ackley(dim = 2)
[12]:
opt = Evolution(prob.space, num_obj = 1, num_constr = 0, algo = 'de', verbose = True)
n_eval = 0
for i in range(30):
    rec     = opt.suggest()
    obs     = prob(rec)
    n_eval += rec.shape[0]
    opt.observe(rec, obs)
print(f'After iter {i+1}, evaluated {n_eval}, best_y is {opt.best_y.squeeze()}')
    1 |     100 |  9.801246852 |  2.02280E+01
    2 |     200 |  2.909631464 |  1.69228E+01
    3 |     300 |  2.815217476 |  1.32613E+01
    4 |     400 |  2.646412912 |  9.695341586
    5 |     500 |  1.242801428 |  6.651983101
    6 |     600 |  0.209210787 |  4.415596345
    7 |     700 |  0.072168031 |  2.681911917
    8 |     800 |  0.029901222 |  1.706953753
    9 |     900 |  0.009651858 |  0.915311097
   10 |    1000 |  0.009651858 |  0.442287468
   11 |    1100 |  0.009651858 |  0.167843522
   12 |    1200 |  0.008691742 |  0.064215683
   13 |    1300 |  0.003673483 |  0.031874574
   14 |    1400 |  0.000484503 |  0.015767501
   15 |    1500 |  0.000196722 |  0.008707443
   16 |    1600 |  0.000120490 |  0.004780801
   17 |    1700 |  0.000120268 |  0.002420470
   18 |    1800 |  0.000119337 |  0.001064583
   19 |    1900 |  0.000119337 |  0.000527714
   20 |    2000 |  0.000079943 |  0.000273763
   21 |    2100 |  2.30069E-06 |  0.000152152
   22 |    2200 |  1.03498E-06 |  0.000090650
   23 |    2300 |  1.03498E-06 |  0.000056089
   24 |    2400 |  1.02798E-06 |  0.000029375
   25 |    2500 |  1.02798E-06 |  0.000014847
   26 |    2600 |  1.94189E-07 |  7.05685E-06
   27 |    2700 |  1.93329E-07 |  3.17235E-06
   28 |    2800 |  1.84926E-08 |  1.49617E-06
   29 |    2900 |  1.32598E-08 |  7.01790E-07
   30 |    3000 |  1.04498E-08 |  3.34182E-07
After iter 30, evaluated 3000, best_y is 1.0449771270515384e-08
[13]:
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.

# This program is free software; you can redistribute it and/or modify it under
# the terms of the MIT license.

# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the MIT License for more details