SafeOpt - Safe Bayesian Optimization¶
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].

[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. |
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.
API Documentation¶
The safeopt package implements tools for Safe Bayesian optimization.
Main classes¶
These classes provide the main functionality for Safe Bayesian optimization.
SafeOpt
implements the exact algorithm, which is very inefficient
for large problems. SafeOptSwarm
scales to higher-dimensional
problems by relying on heuristics and adaptive swarm discretization.
SafeOpt (gp, parameter_set, fmin[, …]) |
A class for Safe Bayesian Optimization. |
SafeOptSwarm (gp, fmin, bounds[, beta, …]) |
SafeOpt for larger dimensions using a Swarm Optimization heuristic. |
Utilities¶
The following are utilities to make testing and working with the library more pleasant.
sample_gp_function (kernel, bounds, …[, …]) |
Sample a function from a gp with corresponding kernel within its bounds. |
linearly_spaced_combinations (bounds, num_samples) |
Return 2-D array with all linearly spaced combinations with the bounds. |
plot_2d_gp (gp, inputs[, predictions, …]) |
Plot a 2D GP with uncertainty. |
plot_3d_gp (gp, inputs[, predictions, …]) |
Plot a 3D gp with uncertainty. |
plot_contour_gp (gp, inputs[, predictions, …]) |
Plot a 3D gp with uncertainty. |