SheffieldML / GPyOpt

Gaussian Process Optimization using GPy
BSD 3-Clause "New" or "Revised" License
929 stars 261 forks source link

Constraint doesn't work #176

Open Paalon opened 6 years ago

Paalon commented 6 years ago

I can't use constraints. Environment: Python 3.6.4 GPyOpt 1.2.1

import GPyOpt

def objective(x):
    return (x[:,0]-0.1)**2

domain = [{'name': 'var_1', 'type': 'continuous', 'domain': (-1, 1)}]
constraints = [{'name': 'const_1', 'constraint': 'x[:,0]'}]

bo = GPyOpt.methods.BayesianOptimization(f=objective, domain=domain, constraints=constraints)
bo.run_optimization(max_iter=15)
bo.plot_acquisition()

figure_1

elzurdo commented 6 years ago

I find that using constrain works (not constraint) as in constraints = [{'name': 'const_1', 'constrain': 'x[:,0]'}]