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

how to add constraint which act also like a blackbox function without explicit function? #247

Open
WeiYUN13 opened this issue Jun 24, 2019 · 1 comment

Comments

@WeiYUN13
Copy link

how to add constraint which act also like a blackbox function without explicit function?
I only see the form like x[:,1] + x[:,2] but no form like a defined function to call in the constraints.

Thank you so much

@ekalosak
Copy link
Contributor

One approach to this might be to add the black-box "constraint" behavior to the objective function: the constraints are explicitly defined, but the objective function already contains the black-box behavior of the optimization target.

To be more concrete, consider the following pseudocode:
bad (notice the function call in the constraint)

def fun(x): 
    return (6*x-2)**2*np.sin(12*x-4)
domain = [{'name': 'var_1', 'type': 'continuous', 'domain': (0,1)}]
constraint = [{'name': 'constr_1', 'constraint': 'fun(x) - 6.0'}]

good

PENALTY_VAL = 0
def fun(x):
    _r = (6*x-2)**2*np.sin(12*x-4)
    r = _r if (_r - 6 > 0) else PENALTY_VAL
    return r
domain = [{'name': 'var_1', 'type': 'continuous', 'domain': (0,1)}]

There must be a rejection mechanism somewhere in the GPyOpt codebase, but I'm not at leisure to search for it right now - please keep us posted as this develops!!

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