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

Parameter Space Constraint #401

Open
Rblack999 opened this issue Feb 13, 2022 · 2 comments
Open

Parameter Space Constraint #401

Rblack999 opened this issue Feb 13, 2022 · 2 comments

Comments

@Rblack999
Copy link

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 Rblack999 changed the title Parameter Space Constraint - Parameter Space Constraint Feb 13, 2022
@apaleyes
Copy link
Collaborator

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
Copy link
Collaborator

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

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

No branches or pull requests

2 participants