Skip to content

Commit

Permalink
[MCBO]: add support for RDUCB.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntGro committed Aug 2, 2023
1 parent 0e30d83 commit 5702186
Show file tree
Hide file tree
Showing 32 changed files with 1,829 additions and 35 deletions.
6 changes: 0 additions & 6 deletions MCBO/.gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
.idea/
/mcbo/acq_optimizers/old/
/mcbo/old
/boils/old
/mcbo/tasks/eda_seq_opt/scripts/main_eda_seq_opt_34_level.sh
/mcbo/tasks/eda_seq_opt/scripts/main_eda_seq_opt_34_lut.sh
/libs/mockturtle
/mcbo/optimizers/old_bo/
/mcbo/optimizers/utils/tlbo_utils/
/mcbo/tasks/eda_seq_opt/scripts/eda_results_checker.*.py
/perso.md
/mcbo/tasks/nn_transfer/
/mcbo/tasks/data/nn_transfer/
/cocabo/
/hebo/
/mcbo/tasks/antibody_design/path_to_AbsolutNoLib.txt
/mcbo/tasks/eda_seq_opt/utils/utils_design_groups_perso.py
/mcbo/tasks/eda_seq_opt/scripts/eda_results_checker_34.py
Expand Down
5 changes: 4 additions & 1 deletion MCBO/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This library provides an easy way to mix-and-match Bayesian optimization components in order to run new
and existing mixed-variable or combinatorial Bayesian optimization. Motivations and principles are described in
[this paper](https://arxiv.org/pdf/2306.09803.pdf)
[this paper](https://arxiv.org/pdf/2306.09803.pdf).

<p align="center">
<img src="./paper/images/all_mix_match.PNG" width="750"/>
Expand Down Expand Up @@ -74,6 +74,7 @@ search_space = task.get_search_space()
- `gp_hed`: GP with the Hamming embedding via dictionary kernel.
- `gp_ssk`: GP with string subsequence kernel.
- `gp_diff`: GP with diffusion kernel.
- `gp_rd`: GP with random tree decomposition additive kernel (for very high dimension).
- `lr_sparse_hs`: Bayesian linear regression with Hoorseshoe prior.


Expand All @@ -84,6 +85,7 @@ search_space = task.get_search_space()
- `ls`: Exhaustive Local Search.
- `is`: Interleaved search with Hill-Climbing and Gradient-Descent.
- `mab`: Multi-Armed Bandit for categorical and Gradient-Descent for numerical.
- `mp`: Message passing (compatible with `gp_rd` model)

### Acquisition functions

Expand Down Expand Up @@ -189,3 +191,4 @@ some of our primitives, we refer to
- BOCS: https://github.com/baptistar/BOCS
- BOiLS: https://github.com/huawei-noah/HEBO/tree/master/BOiLS
- BODi: https://github.com/aryandeshwal/BODi/
- RDUCB: https://github.com/huawei-noah/HEBO/tree/master/RDUCB
29 changes: 29 additions & 0 deletions MCBO/THIRD PARTY OPEN SOURCE SOFTWARE NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ THE OPEN SOURCE SOFTWARE IN THIS SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WIL
BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
SEE THE APPLICABLE LICENSES FOR MORE DETAILS.

------------------------------------------------------------------------------------------------------------------------

Copyright Notice and License Texts

Software: Mockturtle (https://mockturtle.readthedocs.io/)
Expand All @@ -32,6 +34,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

Software: ABC: System for Sequential Synthesis and Verification (http://www.eecs.berkeley.edu/~alanmi/abc/)
Copyright notice: Copyright (c) 2018-2020
Expand All @@ -52,5 +55,31 @@ A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

---

Software: https://github.com/eric-vader/HD-BO-Additive-Models/blob/master/hdbo/acquisition_optimizer.py

MIT License

Copyright (c) 2020 Eric Han

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



2 changes: 2 additions & 0 deletions MCBO/mcbo/acq_funcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
from mcbo.acq_funcs.ei import EI
from mcbo.acq_funcs.factory import acq_factory
from mcbo.acq_funcs.lcb import LCB
from mcbo.acq_funcs.additive_lcb import AddLCB
from mcbo.acq_funcs.additive_lcb import AddLCB
42 changes: 42 additions & 0 deletions MCBO/mcbo/acq_funcs/additive_lcb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.

# This program is free software; you can redistribute it and/or modify it under
# the terms of the MIT license.

# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the MIT License for more details.

from typing import Tuple
import torch

from mcbo.acq_funcs.lcb import LCB
from mcbo.models.gp.rand_decomposition_gp import RandDecompositionGP


class AddLCB(LCB):
def __init__(self, beta: float = 1.96):
super().__init__(beta)

def evaluate(self,
x: torch.Tensor,
model: RandDecompositionGP,
**kwargs
) -> torch.Tensor:
val = 0
for clique in model.graph:
val += self.partial_evaluate(x, model, clique, **kwargs)

return val

def partial_evaluate(self,
x: torch.Tensor,
model: RandDecompositionGP,
clique: Tuple[int],
**kwargs
) -> torch.Tensor:
mean, var = model.partial_predict(x, clique)
mean = mean.flatten()
std = var.clamp_min(1e-9).sqrt().flatten()

return mean - self.beta * std
5 changes: 5 additions & 0 deletions MCBO/mcbo/acq_funcs/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mcbo.acq_funcs.ei import EI
from mcbo.acq_funcs.lcb import LCB
from mcbo.acq_funcs.pi import PI
from mcbo.acq_funcs.additive_lcb import AddLCB
from mcbo.acq_funcs.thompson_sampling import ThompsonSampling


Expand All @@ -18,6 +19,10 @@ def acq_factory(acq_func_id: str, **kwargs):
beta = kwargs.get('beta', 1.96)
acq_func = LCB(beta)

elif acq_func_id == "addlcb":
beta = kwargs.get('beta', 1.96)
acq_func = AddLCB(beta)

elif acq_func_id == 'ei':
acq_func = EI(augmented_ei=False)

Expand Down
Loading

0 comments on commit 5702186

Please sign in to comment.