Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lq-CMA-ES on a linear function #226

Open
nikohansen opened this issue Jan 30, 2023 · 1 comment
Open

lq-CMA-ES on a linear function #226

nikohansen opened this issue Jan 30, 2023 · 1 comment

Comments

@nikohansen
Copy link
Contributor

nikohansen commented Jan 30, 2023

Seems to work fine in 4-D (confirmed in plots) even though the model optimum seems to be (in some runs) in the wrong position (the first coordinate should be negative here as is the one of the incumbent).

import cma
x, es = cma.fmin_lq_surr2(lambda x: x[0], 4 * [1], 1, {'tolfacupx': 1e7})
es.surrogate.model.xopt
(4_w,8)-aCMA-ES (mu_w=2.6,w_1=52%) in dimension 4 (seed=173331, Mon Jan 30 14:28:41 2023)
Iterat #Fevals   function value  axis ratio  sigma  min&max std  t[m:s]
    1      5 6.215994990973674e-01 1.0e+00 1.01e+00  1e+00  1e+00 0:00.0
    2      6 -2.432495786087054e+00 1.4e+00 1.35e+00  1e+00  2e+00 0:00.0
    3      7 -4.432495786087054e+00 1.5e+00 1.79e+00  2e+00  2e+00 0:00.0
   51     55 -3.130000098985985e+07 7.4e+00 6.51e+06  3e+06  1e+07 0:00.1
termination on tolfacupx=10000000.0 (Mon Jan 30 14:28:41 2023)
final/bestever f-value = -3.130000e+07 -3.130000e+07 after 55/57 evaluations
incumbent solution: [-30184337.2435357, -12389244.93773907, 10474158.540809048, 3434412.5840689354]
std deviation: [10736839.080872687, 5123362.03878537, 4678639.153572443, 2990627.555213554]
array([ 2.22130972e+12,  8.98455545e+11, -6.58257448e+11, -3.16643176e+11])

The sorting of sampled solutions is almost always correct (and surrogate fitness values are not too far off):

X = es.ask()
F = [es.surrogate.model.eval(x) for x in X]
np.argsort([x[0] for x in X]), np.argsort(F)
(array([7, 4, 0, 2, 3, 6, 1, 5]), array([7, 4, 0, 2, 3, 6, 1, 5]))

However in 14-D

x, es = cma.fmin_lq_surr2(lambda x: x[0], 14 * [1], 1, {'tolfacupx': 1e17})
cma.plot()

divergence becomes much slower after the switch to the full model at evaluation ~185

lin14

X = es.ask()
F = [es.surrogate.model.eval(x) for x in X]
np.argsort([x[0] for x in X]), np.argsort(F)
(array([ 8,  0,  7,  9,  6,  4,  1,  2,  3, 10,  5]),
 array([ 5,  7,  4,  3, 10,  8,  0,  6,  1,  2,  9]))
@nikohansen
Copy link
Contributor Author

Rerunning after activating the logging like

cma.fitness_models.Logger = cma.logger.Logger
[...]
es.surrogate.logger.plot()

reveals that the evaluated solutions have a large enough Kendall tau most of the time.

lin14kendall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant