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
