Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

de_duplication and pending_X parameter don't seem to work #198

Open
SilverSpirit opened this issue Sep 19, 2018 · 1 comment
Open

de_duplication and pending_X parameter don't seem to work #198

SilverSpirit opened this issue Sep 19, 2018 · 1 comment

Comments

@SilverSpirit
Copy link

SilverSpirit commented Sep 19, 2018

[EDIT: added simpler example and description]

Consider the example below:

import GPyOpt
import numpy as np

np.random.seed(1234)

X_step = np.array([[x] for x in [-50.0, 25.0, -51.0, -52.0, -49.0,
                                 24.0, 26.0, 41.0, 23.0, 27.0, 22.0,
                                 20.0, 21.0, 28.0, 18.0, 17.0, 19.0,
                                 11.0, 10.0, 9.0, 5.0, 6.0, 4.0, 3.0,
                                 2.0, 1.0]])

Y_step = np.array([[y] for y in [36.0, 81.0, 2704.0, 2809.0, 2500.0,
                                 529.0, 625.0, 1600.0, 484.0, 676.0,
                                 441.0, 361.0, 400.0, 729.0, 289.0,
                                 256.0, 324.0, 100.0, 81.0, 64.0, 16.0,
                                 25.0, 9.0, 4.0, 1.0, 0.0]])

domain = [{'name': 'var_1', 'type': 'discrete', 'domain': range(-100, 100)}]
suggestions = np.array([[0]])

bo_step = GPyOpt.methods.BayesianOptimization(f=None,
                                              domain=domain,
                                              X=X_step,
                                              Y=Y_step,
                                              de_duplication=True)

for i in range(0, 35):
    x_next = bo_step.suggest_next_locations(pending_X=suggestions)
    suggestions = np.vstack((suggestions, x_next))

print(suggestions.T)

The output is:

[[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
   0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. -1.  7. -2.  8. -3. -4.]]

GPyOpt suggests 0. some twenty nine times despite being told that the point is pending evaluation and then starts suggesting other points. Is this expected behavior?

I suspect that this is because of using np.any() here and also for ignored_X.

@SilverSpirit SilverSpirit changed the title pending_X parameter is ignored de_duplication and pending_X parameter don't seem to work Sep 21, 2018
@dblanm
Copy link

dblanm commented Oct 17, 2022

To anyone who comes through this issue, remember to enable de_duplication:

bo_step = GPyOpt.methods.BayesianOptimization(..., de_duplication=True)
x_next_0 = bo_step.suggest_next_locations()
X_next = [x_next_0]
x_next = bo_step.suggest_next_locations(ignored_X=np.array(X_next))

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

No branches or pull requests

2 participants