bayesian-optimization / BayesianOptimization

A Python implementation of global optimization with gaussian processes.
https://bayesian-optimization.github.io/BayesianOptimization/index.html
MIT License
7.9k stars 1.54k forks source link

pbounds step size #449

Closed cqllysto closed 11 months ago

cqllysto commented 12 months ago

Is there any possible way to set a pbounds range to an integer (or other) step size? One of my boundaries can vary from 6 to 10 in integers of 2. (so 6, 8, or 10) is there any way to do this?

Thank you, Aidan Wright

till-m commented 12 months ago

Hi Aidan,

there is no built-in way to deal with this problem both elegantly and well. Two suggestions that I can offer: The easier way would be to round to the appropriate value within your target function:

def my_surrogate_target_func(t):
    t = (t //2) * 2
    return my_target_func(t)

This is relatively straightforward and ensures that your values are appropriate, but it will not help the optimizer understand that 7.7 and 8.3 are the same for your function. That can be done by modifying the kernel of the GP, but it would require you to be somewhat comfortable with python: You can do this yourself (see here to get you started). Alternatively, I toyed with the idea of adding this to the codebase once. I still have this commited to a branch that you can install from, see here for an example on how that would be used.

Let me know if that helps.

till-m commented 11 months ago

I will close this for now. Feel free to reopen if you need any more help.