Back to list

Tech Blog · Paper Reviews

[Classic Revisited] Safe exploration — SafeOpt

Can we find the optimum without ever trying a condition whose result falls below the threshold? We summarize the method, guarantees and experiments of the 2015 SafeOpt paper, along with the assumptions and costs the paper itself states.

Aug 27, 2026 · OPTI-X

You may want to vary a reactor temperature or a cooling rate to find better conditions, but if a single attempt can lead to defects or equipment damage, you cannot explore freely. Sui, Gotovos, Burdick and Krause (ICML 2015) formalized this situation as an optimization problem with the condition that "the result of every condition tried must be at or above a safety threshold." Their method, SafeOpt, gradually expands the range confirmed to be safe and searches for the optimum inside it.

The problem the paper addresses

Bayesian optimization and bandit algorithms accept low immediate results for the sake of long-term performance. The authors point out that this compromise does not suit safety-critical targets. Existing methods that locate the boundary where the result crosses a threshold also try conditions both above and below it, so they do not meet the safety requirement either. The paper's examples are rehabilitation stimulation for patients with spinal cord injuries, recommendations that must avoid items the user dislikes, and robot control that must not damage the hardware.

The problem setting is simple. The result function f is unknown, and only noisy measurements are available. The goal is to find the condition where f is largest while ensuring that every attempt yields a result at or above the safety threshold h. The set of safe conditions is also unknown at the start.

In the original paper, the safety threshold applies to the objective result itself, not to a separate constraint. Translated to a process, it is closer to "do not try conditions where the yield falls below the threshold." Berkenkamp et al. (2016) observed that coupling performance and safety is often undesirable in robotics, and extended the method to handle multiple safety constraints separate from the objective.

What they did: searching while expanding the safe set

SafeOpt rests on two assumptions. First, there must be at least one starting condition known to be safe. Second, f must be smooth enough to be handled by a Gaussian process and must be Lipschitz continuous. Lipschitz continuity means that "if a condition changes by a distance d, the result changes by at most L×d."

At every iteration, the Gaussian process gives a confidence interval (lower and upper bounds) for each condition. A condition joins the safe set when the lower bound of an already-safe condition, minus L×distance, is still at or above the threshold h. Because the confidence intervals only ever narrow, the safe set never shrinks and expands in stages.

Inside the safe set, two kinds of candidates are considered. Potential maximizers are conditions whose upper bound is above the best lower bound so far, so they may still be optimal. Expanders are conditions that, judged optimistically by the upper bound, could certify new conditions outside the safe set as safe if tried. Among both kinds, the condition with the widest confidence interval, that is, the most uncertain one, is tried.

A stopping rule is also defined. When the confidence-interval widths of both candidate kinds all fall to the chosen accuracy ε or below, the search stops and returns the condition in the safe set with the highest lower bound, not the highest mean or upper bound.

One round of SafeOpt

It expands the safe set and searches for the optimum at the same time

  1. 1
    A safe starting pointStart from conditions known to be safe (e.g., existing operating conditions)
    Next
  2. 2
    Update the safe setOnly conditions still at or above the threshold after subtracting L×distance from the lower bound are accepted as safe
    Only conditions in the safe set are candidatesUnconfirmed condition → not tried
  3. 3
    Choose among maximizers and expandersTry the condition with the widest confidence interval among both candidate kinds
    Add the result and recompute

The paper also provides a theoretical guarantee. With a suitable choice of the coefficient that sets the confidence-interval width, two things hold together with high probability (1−δ): every attempt yields a result at or above the threshold h, and after a certain number of iterations a condition within ε of the optimum is found. Here, however, the optimum is not the global optimum but the optimum within the region safely reachable from the starting point. The authors explain that if results can only be known up to an error margin, no safe algorithm can certify anything outside that region as safe. The number of iterations required grows with the size of this region, the required accuracy ε, the allowed failure probability δ, and the complexity of the function.

There is also a practical variant. The method can be changed so that a condition is accepted as safe on its own when its confidence-interval lower bound is at or above the threshold. The theoretical guarantee becomes weaker, but it may work better in some applications and becomes less sensitive to the choice of L. The authors note that in practice one can even set L to infinity and judge safety from the confidence intervals alone.

Standard Bayesian optimization vs. SafeOpt

The difference is how "where it is OK to try" is defined

Standard approach (GP-UCB)
SafeOpt
Where it tries
All candidate conditions
Inside the set confirmed to be safe
Selection rule
Where prediction + uncertainty is largest
The most uncertain point among maximizers and expanders
Safety
No guarantee; below-threshold attempts also occurred in experiments
Every attempt at or above the threshold with high probability
Cost
Accepts low immediate results for long-term performance
Does not look for optima unreachable from the starting point
Source: Sui et al. (2015), Sections 2–4

Results: three experiments

There were two baselines. GP-UCB is the standard approach without safety constraints, and SAFE-UCB is a comparison variant that picks the condition with the largest upper bound inside the same safe set as SafeOpt.

The paper's three experiments

In all three, below-threshold attempts came mainly from GP-UCB

ExperimentCandidate conditionsIterationsObservation
Synthetic functions2-D 50×50 grid, 100 functions × 100 starting points100SafeOpt's average regret smaller than SAFE-UCB's
Movie recommendationMovieLens-100k (1,682 movies, 943 users)300GP-UCB violated the safety threshold fastest
Spinal cord stimulation126 electrode configurations (data from 351 stimulations)300SafeOpt and SAFE-UCB safely explored a large part of the reachable region
Source: Sui et al. (2015), Section 5, Figures 2–5

In the synthetic-function experiment, SAFE-UCB sometimes stayed at a local optimum because it failed to expand boundary conditions lying just above the threshold. SafeOpt, which expands and searches for the optimum together, had smaller average regret (the gap between the value found and the reachable optimum). GP-UCB found the global optimum without safety constraints, so its regret was negative, but some of the values it tried were below the threshold.

In the movie recommendation experiment, the safety threshold is the mean of all ratings. In the example of a user starting from one movie they had rated 5, the first four recommendations from SafeOpt and SAFE-UCB were all above the threshold, while GP-UCB's fourth recommendation received a below-threshold rating. When run on after violations, GP-UCB covered almost the whole reachable region, but the mean rating of the movies it recommended was lower and the spread larger. SafeOpt expanded the safe set more aggressively and reached slightly more movies than SAFE-UCB.

The spinal cord stimulation experiment maximizes the muscle response of rats with spinal cord injuries. Electrode configurations are 4-D points representing cathode and anode locations, and the kernel was fitted to actual stimulation data. Bad configurations harm rehabilitation and cause pain, so the response must be at or above the threshold. Here too, GP-UCB violated the threshold quickly, and SafeOpt and SAFE-UCB had higher mean measured values.

Assumptions and limitations stated by the paper

The guarantees hold only on top of the assumptions. The authors write that without a safe starting point one does not even know where to begin, and that without assumptions about the function's smoothness the problem cannot be solved. In the experiments, L was estimated from the gradients of functions sampled from the Gaussian process.

They also state that the confidence intervals must be conservative for the safety judgments to be accurate, but that overly conservative intervals slow the algorithm down considerably. The original paper also restricts itself to bandit problems, where decisions do not change the state. Safe exploration in systems whose state carries over is a more general problem, and the authors distinguish it by noting that methods for it are more complex and lack convergence guarantees. The candidate conditions were also kept to a finite set, divided into a grid in the experiments.

What to look at on the plant floor

All three experiments in the original paper were problems in which one attempt does not affect the next state. To carry the method over to processes whose state carries over after a setting change, such as reactors or cooling equipment, check the assumptions below before choosing the algorithm.

What to check before carrying it over to a process

Whether the assumptions hold comes before the algorithm

Starting pointIs there a record of safe conditions?
Verified operating conditions serve as the safe starting point
Safety thresholdDoes the threshold apply to the objective, or is it a separate constraint?
The original paper uses the objective itself; separate constraints are a later extension
DistanceHow is the distance between conditions measured?
Distance and L enter directly into the safety test
DynamicsDoes the state carry over after a setting change?
The original paper is a bandit problem where the state does not carry over

How Bayesian optimization chooses the next experiment was covered in Part 4 of the series "Prescription Methods." What SafeOpt left behind is less an algorithm than a way of framing the problem. Frame it not as "find the optimum" but as "find it while trying only where safety is confirmed," and both the methods available and the range you can reach change together.

References

Could this work for your process?

Talk to us