Safe Bayesian Optimization

Overview

SafeOpt - Safe Bayesian Optimization

Build Status Documentation Status

This code implements an adapted version of the safe, Bayesian optimization algorithm, SafeOpt [1], [2]. It also provides a more scalable implementation based on [3] as well as an implementation for the original algorithm in [4]. The code can be used to automatically optimize a performance measures subject to a safety constraint by adapting parameters. The prefered way of citing this code is by referring to [1] or [2].

Youtube video
[1] F. Berkenkamp, A. P. Schoellig, A. Krause, Safe Controller Optimization for Quadrotors with Gaussian Processes in Proc. of the IEEE International Conference on Robotics and Automation (ICRA), 2016, pp. 491-496.
[2] F. Berkenkamp, A. Krause, A. P. Schoellig, Bayesian Optimization with Safety Constraints: Safe and Automatic Parameter Tuning in Robotics, ArXiv, 2016, arXiv:1602.04450 [cs.RO].
[3] Rikky R.P.R. Duivenvoorden, Felix Berkenkamp, Nicolas Carion, Andreas Krause, Angela P. Schoellig, Constrained Bayesian optimization with Particle Swarms for Safe Adaptive Controller Tuning, in Proc. of the IFAC (International Federation of Automatic Control) World Congress, 2017.
[4] Y. Sui, A. Gotovos, J. W. Burdick, and A. Krause, Safe exploration for optimization with Gaussian processes in Proc. of the International Conference on Machine Learning (ICML), 2015, pp. 997–1005.

Warning: Maintenance mode

This package is no longer actively maintained. That bein said, pull requests to add functionality or fix bugs are always welcome.

Installation

The easiest way to install the necessary python libraries is by installing pip (e.g. apt-get install python-pip on Ubuntu) and running

pip install safeopt

Alternatively you can clone the repository and install it using

python setup.py install

Usage

The easiest way to get familiar with the library is to run the interactive example ipython notebooks!

Make sure that the ipywidgets module is installed. All functions and classes are documented on Read The Docs.

License

The code is licenced under the MIT license and free to use by anyone without any restrictions.

Comments
  • 2d-optimization flipped axis

    2d-optimization flipped axis

    we have used this toolbox as an example in our application (https://github.com/upb-lea/openmodelica-microgrid-gym), where we will design a current controller (standard PI; Kp/Ki) for an inverter.

    expected behavoiur

    When fliping the dimensions of our two dimensional optimization space, we would expect the ploted results should only flip the axis.

    grafik

    Observed behavior

    However, when observing the point marked in green, the values change!

    what we investigated

    bounds are flipped accourdingly

    Ideas

    We have the impression, that the first dimension is explored much better than the second dimension. in the left plot the y values never exeed 0.06 even though they are deemed save in the right experiment. Similarly in the right plot, it never dares to try above 150, but in the left it is explored and also save. Therefore we assume it is related to the handling of expanders.

    Do you have any hints on how to investigate it further. We are not certain that it is a bug, but the anti-symmetry seems odd.

    opened by Webbah 2
  • plot_3d=True

    plot_3d=True

    Hi. Your algorithm is pretty good and it's very useful in many cases. But,there is an error:"TypeError: object of type 'numpy.float64' has no len()." when i try to change plot_3d=False to True in 2d_example.n It's not a big matter in Jupyter notebook(In jupyter it can still display the 3D function images),but it is unexecutable in Pycham. Do you know how to make it? Thanks.

    opened by pengz1234 2
  • upper bound constraints

    upper bound constraints

    Hi. I wonder whether it is possible to add the upper bound constraints, i.e., gps<=fmax, which are opposite to the lower bound constraints, i.e., gps>=fmin. It seems to be possible to add the upper bound constraints to the "comput_safe_set" functioon when lipschitz constant L is infinite.

    opened by wang90063 2
  • Correct imports to use library with python 3.10

    Correct imports to use library with python 3.10

    With Python 3.10 Sequence was moved to collections.abc. This PR ensures that the library can be used for Python < 3.10 as well as for Python >= 3.10.

    opened by Pythonix 0
  • MovieLen 100k with the original SafeOpt algorithm

    MovieLen 100k with the original SafeOpt algorithm

    Hi there!

    I'm trying to replicate the result of SafeOpt on the MovieLen 100k dataset and use it as a baseline for my class project. I tried to follow the procedure described in the paper but I failed to reproduce the result. Can I get some help? Thank you!

    Here are the steps that I followed:

    Screen Shot 2021-11-16 at 10 25 11 AM Screen Shot 2021-11-16 at 10 25 19 AM

    And here is my code: Screen Shot 2021-11-16 at 10 36 26 AM

    The problem right now is that

    • the algorithm breaks the safety constraint pretty quick (explored movies that have a 1.0 rating)
    • the algorithm tends to be stuck at one or multiple high rating recommendations after some iterations and it is not able to generate novel results.
    • similar to the second point, it explores only a small portion of the reachable set

    We experimented with different std and noise variance but did not actually make significant improvement. I wonder do you notice any mistake we made in our code? In addition, would it be possible to share the code you used for the evaluation in the paper?

    Thank you very much!

    opened by Lancial 1
  • Effect of search space boundaries on exploration

    Effect of search space boundaries on exploration

    grafik

    (Only boundaries for GP changed in the 2 plots) Do you have any hints how a change in the boundaries effect exploration that much? Our understanding was, that boundaries shouldn't effect exploration at all but only act as a limit.

    opened by Webbah 2
Owner
Felix Berkenkamp
Research Scientist
Felix Berkenkamp
Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks

Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks. Bayesian-Torch is designed to be flexible and seamless in extending a deterministic deep neural network architecture to corresponding Bayesian form by simply replacing the deterministic layers with Bayesian layers.

Intel Labs 210 Jan 4, 2023
LBK 20 Dec 2, 2022
Spearmint Bayesian optimization codebase

Spearmint Spearmint is a software package to perform Bayesian optimization. The Software is designed to automatically run experiments (thus the code n

Formerly: Harvard Intelligent Probabilistic Systems Group -- Now at Princeton 1.5k Dec 29, 2022
Simple, but essential Bayesian optimization package

BayesO: A Bayesian optimization framework in Python Simple, but essential Bayesian optimization package. http://bayeso.org Online documentation Instal

Jungtaek Kim 74 Dec 5, 2022
Bayesian optimization in PyTorch

BoTorch is a library for Bayesian Optimization built on PyTorch. BoTorch is currently in beta and under active development! Why BoTorch ? BoTorch Prov

null 2.5k Dec 31, 2022
Bayesian Optimization using GPflow

Note: This package is for use with GPFlow 1. For Bayesian optimization using GPFlow 2 please see Trieste, a joint effort with Secondmind. GPflowOpt GP

GPflow 257 Dec 26, 2022
Information-Theoretic Multi-Objective Bayesian Optimization with Continuous Approximations

Information-Theoretic Multi-Objective Bayesian Optimization with Continuous Approximations Requirements The code is implemented in Python and requires

null 1 Nov 3, 2021
Bayesian Optimization Library for Medical Image Segmentation.

bayesmedaug: Bayesian Optimization Library for Medical Image Segmentation. bayesmedaug optimizes your data augmentation hyperparameters for medical im

Şafak Bilici 7 Feb 10, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 3, 2023
library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization

NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information. It is designed as a simple, unifi

Steven G. Johnson 1.4k Dec 25, 2022
Racing line optimization algorithm in python that uses Particle Swarm Optimization.

Racing Line Optimization with PSO This repository contains a racing line optimization algorithm in python that uses Particle Swarm Optimization. Requi

Parsa Dahesh 6 Dec 14, 2022
Keeping it safe - AI Based COVID-19 Tracker using Deep Learning and facial recognition

Keeping it safe - AI Based COVID-19 Tracker using Deep Learning and facial recognition

Vansh Wassan 15 Jun 17, 2021
The implementation of the algorithm in the paper "Safe Deep Semi-Supervised Learning for Unseen-Class Unlabeled Data" published in ICML 2020.

DS3L This is the code for paper "Safe Deep Semi-Supervised Learning for Unseen-Class Unlabeled Data" published in ICML 2020. Setups The code is implem

Guolz 36 Oct 19, 2022
The code for the NSDI'21 paper "BMC: Accelerating Memcached using Safe In-kernel Caching and Pre-stack Processing".

BMC The code for the NSDI'21 paper "BMC: Accelerating Memcached using Safe In-kernel Caching and Pre-stack Processing". BibTex entry available here. B

Orange 383 Dec 16, 2022
[NeurIPS 2021] Better Safe Than Sorry: Preventing Delusive Adversaries with Adversarial Training

Better Safe Than Sorry: Preventing Delusive Adversaries with Adversarial Training Code for NeurIPS 2021 paper "Better Safe Than Sorry: Preventing Delu

Lue Tao 29 Sep 20, 2022
A solution to ensure Crowd Management with Contactless and Safe systems.

CovidTrack A Solution to ensure Crowd Management with Contactless and Safe systems. ML Model Mask Detection Social Distancing Detection Analytics Page

Om Khare 1 Nov 10, 2021
Infrastructure as Code (IaC) for a self-hosted version of Gnosis Safe on AWS

Welcome to Yearn Gnosis Safe! Setting up your local environment Infrastructure Deploying Gnosis Safe Prerequisites 1. Create infrastructure for secret

Numan 16 Jul 18, 2022
SafePicking: Learning Safe Object Extraction via Object-Level Mapping, ICRA 2022

SafePicking Learning Safe Object Extraction via Object-Level Mapping Kentaro Wad

Kentaro Wada 49 Oct 24, 2022