Skip to content

EricssonResearch/collaborative-safe-bo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoSBO: Collaborative Safe Bayesian Optimization

This project is dedicated to the implementation of the safe Bayesian optimization algorithms: SafeOpt-MC and CoSBO. This work has been carried as a master thesis by Alina Castell Blasco, supervised by Maxime Bouton and is associated with the following publication:

Alina Castell Blasco, Maxime Bouton, "Safe Collaborative Bayesian Optimization", IEEE NOMS 2026.

It contains evaluations of the two optimization methods across various scenarios and budgets, outputting the optimization values for each configuration. In addition, it includes an evaluation framework that processes the optimal data obtained, plots the intermediate optimized functions, and generates plots for analysis and comparison between methods. Finally, it provides a random exploration implementation for a more complete study.

Installation

Prerequisites

  • Python 3.10

  • Virtual environment (optional but recommended)

Clone the repository

Go to the repository's folder and install the required libraries:

pip install -r requirements.txt

Structure

The structure of the code pipeline is:

├─ main.py
│  ├─ Config
│  ├─ Optimizer
│  │  ├─ SafeOptMC
│  │  │  ├─GlobalState
│  │  │  └─ utils.py
│  │  └─ CoSBO
│  │     ├─ Config
│  │     ├─ GlobalState
│  │     ├─ SafeOptMC
│  │     └─ utils.py
│  ├─ Simulator
│  │  ├─ Config
│  │  └─ utils.py
│  └─ utils.py
├─ postprocessing.py
└─ resultplotter.py

Brief description of the modules:

  • main.py: evaluates optimization methods and generates data on optimal values for each step in the process.
  • Config: stores adjustable constants used across all modules.
  • GlobalState: updates global variables when the GP model is modified.
  • Optimizer: executes optimization methods and returns their optimal values.
  • SafeOptMC: provides the SafeOpt-MC algorithm for safe optimization and the implementation of a random exploration strategy.
  • CoSBO: CoSBO algorithm that initializes optimization process with a collaborative approach and continues optimizing using the SafeOpt-MC algorithm.
  • Simulator: generates simulations of specific scenarios and provides functions to compute various performance and safety metrics.
  • utils.py: provides utility functions for all modules.

The structure of the code directory is:

collaborative-safe-bo
├─ data
│  ├─ cosbo
│  ├─ optims
│  ├─ optims_random_exploration
│  ├─ random_exploration
│  └─ safeoptmc
├─ safe
│  └─ static
│     ├─ cosbo
│     └─ safeoptmc
├─ simulator_data
├─ simulator_config
└─ static
   ├─ cosbo
   ├─ randcom_exploration
   └─ safeoptmc

Brief description of the directories:

  • data, safe and static are empty directories that will store the output data generated from the optimization. data stores '.csv' files, and the rest store '.png' intermediate plots.
  • simulator-data consists of the input data '.json' files to create the scenarios, these data structures are created with the next directory.
  • simulator-generation includes experimental data and the notebook used to create the data for the simulation scenarios.

Usage

First, create empty folders depicted in the structure above: data, safe, and static, as well as the folders inside them. During the optimization process, plots and data will be generated there.

Second, modify any function/scenario specifications on the config.py file.

Then, run the main.py function for a specific algorithm, scenario, traffic volume and initial point with the following command line:

python main.py {method} --scenario {number} --traffic {number} --star {number}

where the options are:

  • method {safeoptmc,cosbo}
  • --scenario {1...5}
  • --traffic {1...3}
  • --start {1...11}

To run all scenarios and traffic volumes in a loop use the line:

for i in {1..5} do
   for j in {1..3} do
      for k in {1..11} do
         python main.py {method} --scenario $i --traffic $j --start $k
      done
   done
done

Note

Start by running the method safeoptmc since its results are used as collaborator data for the cosbo method.

To run the random-exploration strategy, the method safeoptmc has to be indicated and a random seed with the argument --seed {0...9}. This strategy will not be performed unless a seed is indicated.

Finally, post-process the generated data and create evaluation plots with:

python postprocessing.py {method} {action}
python resultplotter.py {action}

About

This project is dedicated to the implementation of the safe Bayesian optimization algorithms: SafeOpt-MC and CoSBO. This work is associated with the following publication: Alina Castell Blasco, Maxime Bouton, "Collaborative Safe Bayesian Optimization", IEEE NOMS 2026

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages