emukit icon indicating copy to clipboard operation
emukit copied to clipboard

Parameter Space Constraint

Open Rblack999 opened this issue 2 years ago • 2 comments

In exploring this library, I am trying to define a very particular parameter space for an optimization problem and am wondering if/how it can be implemented? I'm trying to do BO Experimental Design, and have defined my parameter space as the following:

parameter_space = ParameterSpace([DiscreteParameter('x1',np.linspace(0,1,11)), DiscreteParameter('x2',np.linspace(0,1,11)), DiscreteParameter('x3',np.linspace(0,1,11)), DiscreteParameter('x4',np.linspace(0,1,11)), DiscreteParameter('x5',np.linspace(0,1,11)), DiscreteParameter('x6',np.linspace(0,1,11))])

Essentially, a 6 column matrix with each [[0,0.1,0.2...1]] in spacing of 0.1.

However, I would like to constrain this to have summation of x1 to x6 == 1. That is, only select x_new values to output a single vector but with the columns (x1 to x6) adding up to 1, rejecting any vector that does not meet this criteria.

Is this possible to implement? I have looked into the constraint libraries but have come up short. If not using constraints, is their a way to explicitly define that space (it will be a shape(2121,6) matrix in the end). My understanding is that a matrix cannot be used, but only a 1d or 2d (n,1) array can be used.

Thanks!

Rblack999 avatar Feb 13 '22 22:02 Rblack999

Sounds like you just need to define a linear constraint. We support those, here is the doc link. Note that when your lower and upper bounds are the same, this turns into equality constraint, which is what you are after.

Also, here is an example of how to do constraints in Emukit. It talks about non-linear ones, but the idea is the same, you just use a different, simpler, class. https://nbviewer.org/github/emukit/emukit/blob/main/notebooks/Emukit-tutorial-constrained-optimization.ipynb

apaleyes avatar Feb 14 '22 13:02 apaleyes

Oh, by the way, while using constraints please be aware of an annoying bug #291 which might impact your code

apaleyes avatar Feb 14 '22 18:02 apaleyes