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
Disclaimer: the figure above shows that this library allows to build and run BO algorithms made of the same primitives as several published BO methods, but they should not be considered as their official implementations.
Tested on Ubuntu 18.04 and python 3.8.
Create a conda environment and activate it.
conda create -n mcbo_env python=3.8
conda activate mcbo_env
# install MCBO to be able to run optimization on custom problems
pip install -e .
# You can specify the path where all results will be stored by default
echo './results/' > ./mcbo/tasks/eda_seq_opt/results_root_path.txt
# if you want to run optimization of built-in Black-box, run the following (may take a while to get everything installed)
chmod u+x ./bbox_setup.sh
./bbox_setup.sh
- 21 SFU test functions
ackley
: Ackley 20 caterorical dimensions (11 categories each).ackley-53
: Ackley 50 binary dimensions, 3 numerical.pest
: Pest Control
antibody_design
: Antibody Designrna_inverse_fold
: RNA Inverse Foldingaig_optimization
: EDA Sequence Optimization (AIG sequence optimization)aig_optimization_hyp
: EDA Sequence and Parameter Optimization (AIG sequence and parameter optimization)mig_optimization
: MIG Sequence Optimizationsvm_opt
: SVM hyperparameter tuning and feature selectionxgboost_opt
: XG-Boost hyperparameter tuning
All the tasks are accessible via the task_factory
function. Below we show how to obtain the task
and search_space
class for the RNA inverse fold task.
from mcbo.factory import task_factory
import torch
task_name = 'rna_inverse_fold'
task = task_factory(task_name=task_name)
search_space = task.get_search_space()
gp_o
: GP with overlap kernel.gp_to
: GP with transformed-overlap kernel.gp_hed
: GP with the Hamming embedding via dictionary kernel.gp_ssk
: GP with string subsequence kernel.gp_diff
: GP with diffusion kernel.lr_sparse_hs
: Bayesian linear regression with Hoorseshoe prior.
ga
: Genetic algorithm.sa
: Simulated Annealing.ls
: Exhaustive Local Search.is
: Interleaved search with Hill-Climbing and Gradient-Descent.mab
: Multi-Armed Bandit for categorical and Gradient-Descent for numerical.
ei
: Expected Improvement.lcb
: Lower Confidence Bound.ts
: Thompson Sampling.
basic
: Hamming distance for categorical variables, hyperectangle limit for numerical variables.
rs
: Random Search.ls
: Local Search.sa
: Simulated Annealing.ga
: Genetic Algorithm.mab
: Multi-Armed Bandit.
- A simple script to build Casmopolitan optimizer and run it on RNA inverse fold.
import torch
from mcbo import task_factory
from mcbo.optimizers.bo_builder import BoBuilder
if __name__ == '__main__':
task_kws = dict(target=65)
task = task_factory(task_name='rna_inverse_fold', **task_kws)
search_space = task.get_search_space()
bo_builder = BoBuilder(
model_id='gp_to', acq_opt_id='is', acq_func_id='ei', tr_id='basic'
)
optimizer = bo_builder.build_bo(search_space=search_space, n_init=20, device=torch.device("cuda"))
for i in range(100):
x = optimizer.suggest(1)
y = task(x)
optimizer.observe(x, y)
print(f'Iteration {i + 1:3d}/{100:3d} - f(x) = {y[0, 0]:.3f} - f(x*) = {optimizer.best_y:.3f}')
- To run and save optimization results with several seeds and optimizers,
we provide the
./experiments/run_task_exps.py
script callingrun_experiment
function.
python ./experiments/run_task_exps.py --device_id 0 --task_id "rna_inverse_fold" --optimizers_ids gp_to__is__ei__tr --seeds 42 --verbose 2
It is possible to reproduce our optimization results by running the script ./all_runs.sh.
chmod u+x ./experiments/all_runs.sh
./experiments/all_runs.sh
Results will be saved in ./resutls/
or in user specified path.
We provide notebooks to visualize rankings and regrets. Many plotting tools are available in general_plot_utils.py.
- The task should be a class inheriting TaskBase
- Create a folder containing the code of the new task in the tasks folder.
- The folder can also contain a README providing a description of the task, associated search_space, dependencies
- Add the new task to the factory script (prefer local import of the new task class if it depends on packages not listed in requirements.txt).
- Add reference to the task in the present README.md in the dedicated section.
If you use this library, please cite MCBO paper:
Kamil Dreczkowski, Antoine Grosnit, and Haitham Bou Ammar. Framework and Benchmarks for Combinatorial and Mixed-variable Bayesian Optimization
@misc{dreczkowski2023mcbo,
title={Framework and Benchmarks for Combinatorial and Mixed-variable Bayesian Optimization},
author={Kamil Dreczkowski and Antoine Grosnit and Haitham Bou Ammar},
year={2023},
eprint={2306.09803},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
For official implementations of the existing algorithms that our library can build and which inspired some of our primitives, we refer to
- BOSS: https://github.com/henrymoss/BOSS
- COMBO: https://github.com/QUVA-Lab/COMBO/
- Casmopolitan: https://github.com/xingchenwan/Casmopolitan
- CoCaBO: https://github.com/rubinxin/CoCaBO_code
- BOCS: https://github.com/baptistar/BOCS
- BOiLS: https://github.com/huawei-noah/HEBO/tree/master/BOiLS
- BODi: https://github.com/aryandeshwal/BODi/