liveBook · Manning

Optimize_acqf

As explained in Bayesian Optimization in Action

optimize_acqf is a BoTorch function that optimizes an acquisition function to return a high-scoring candidate and its acquisition value.

optimize_acqf selects the next location to evaluate in Bayesian optimization by maximizing an acquisition function over bounded search space. Rather than exhaustively scoring every location—a poor fit as dimensionality grows—it searches for a candidate with the highest acquisition score and returns both the candidate and that score. This makes acquisition policies actionable: a Gaussian-process model estimates the objective, a policy values possible queries, and optimize_acqf chooses the query to run next. section 4.1.1 section 4.5

Select one next query

For a one-dimensional search space from -5 to 5, pass a policy, bounds shaped as lower and upper limits, and q=1. The returned next_x is the location with the maximized score; acq_val is that maximum. Repeating this after fitting the GP and then appending the evaluated label forms the core loop for an expensive black-box objective. section 4.1.1 section 4.2.3

The search uses L-BFGS, a quasi-Newton method described as generally more effective than gradient descent here. Because acquisition optimization can have difficult search landscapes, it starts from raw samples and runs multiple restarts. Higher num_restarts and raw_samples make the search more exhaustive but slower. A practical starting heuristic is 20 times the number of dimensions for restarts and 50 times the number of dimensions for raw samples; increase them when maximization fails and reduce them when runtime matters. section 4.1.1

Optimize a policy in PyTorch

Use botorch.optim.optimize_acqf(policy, bounds=bounds, q=1, num_restarts=20, raw_samples=50). The policy supplies acquisition scores, bounds constrain candidates, and q controls how many locations are returned. Runtime warnings can report a failed SciPy candidate-optimization attempt followed by a retry from new initial conditions; warnings may be suppressed, but the search behavior still merits inspection. section 4.1.1 section 4.2.3

Figure 4.2 The BayesOpt loop, which combines a GP for modeling and a policy for decision making. This complete workflow may now be used to optimize black box functions.

Use the BayesOpt-loop diagram to place acquisition optimization between policy scoring and evaluating the selected black-box query. section 4.1.1

For parallel evaluation, set q=k, where k is the batch size. optimize_acqf then returns next_x as a k-by-d tensor: k candidate points across d search dimensions. The same GP-fitting and BayesOpt-loop structure can be retained while changing from sequential queries to batches. Batch policies such as qProbabilityOfImprovement, qExpectedImprovement, and qUpperConfidenceBound use this interface. section 7.2.2 section 7.6

Not every batch acquisition function is optimized with this helper. Batch maximum-value entropy search poses a computational challenge that prevents its use with L-BFGS in this setting. Cyclic refinement of individual batch members is instead available through optimize_acqf_cyclic. Choosing the intended q value remains important for either helper because it determines the optimization throughput. section 7.6

How Bayesian Optimization in Action covers it

How deep it goes
Explains call arguments, L-BFGS restarts, search-cost trade-offs, warnings, and batch output shapes without detailing L-BFGS internals.
Examples
Demonstrates one-dimensional Forrester optimization, repeated PoI queries, and batched two-dimensional hyperparameter-tuning-style optimization.
What it assumes
Assumes a fitted GP model, an acquisition-policy object, and bounded PyTorch search-space tensors.
What you can do after
Apply it via BoTorch to generate bounded single-point or parallel candidate queries from an acquisition policy.
How it connects
Connects acquisition functions, Gaussian processes, Bayesian optimization, Probability of Improvement, Expected Improvement, and Upper Confidence Bound.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bayesian Optimization in Action. The section links point to the parts of the book it draws on.