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

Support for equality constraints #31

Closed
redcican opened this issue Sep 7, 2022 · 2 comments
Closed

Support for equality constraints #31

redcican opened this issue Sep 7, 2022 · 2 comments

Comments

@redcican
Copy link

redcican commented Sep 7, 2022

请问你们支持恒等约束吗? 如果接受,该如何设置?

@jhj0411jhj
Copy link
Member

我认为在黑盒优化中,优化黑盒恒等约束是十分困难的。目前OpenBox不支持黑盒恒等约束。您可以尝试将恒等约束 $c(x) = 0$ 转化为两个不等式约束 $c(x)-\epsilon \le 0$$c(x)+\epsilon \ge 0$,然后执行优化。但是,这样做的效果不被保证,并且恒等约束不会被100%满足。

最近,我们实现了一个新的功能以支持对输入超参数进行约束 (be455c2) ,并发布了一个新的版本 (pip install openbox>=0.7.18)。如果您的约束是关于输入超参数的,请参考(#37)以获取更多信息。

此外,我想知道您的恒等约束是否是类似这样的形式:a+b+c=0?其中a,b,c是超参数。在这种情况下,我建议您只定义两个超参数ab,然后在目标函数中计算c=-a-b


I think in black-box optimization, it's very hard to optimize black-box equality constraints. Currently OpenBox has no support for black-box equality constraints. You can try to convert the equality constraint $c(x) = 0$ into two inequality constraints $c(x)-\epsilon \le 0$ and $c(x)+\epsilon \ge 0$, and then run the optimization. However, the performance is not guarantted and the equality constraint cannot be 100% satisfied.

Recently, we added a new feature to support constraints (conditions) between hyperparameters (be455c2) and released a new version (pip install openbox>=0.7.18). If your constraint is about input hyperparameters, please refer to this issue (#37) for more details.

Furthermore, I would like to know if your equality constraint is like a+b+c=0, where a,b,c are hyperparameters. In this situation, I suggest you define two parameters a and b, and calculate c=-a-b in the objective function.

@jhj0411jhj
Copy link
Member

If the constraint is like $x_1+x_2+x_3=m$, and you want $x_i \in [0,1]$, I suggest you define two hyperparameters $x_1$ and $x_2$, and define a sample_condition, which calculates $x_3=m-x_1-x_2$, and judges whether $x_3 \in [0,1]$:

def sample_condition(config):
    x3 = m - config['x1'] - config['x2']
    return 0 <= x3 <= 1

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