{'fraction_non_alphanumeric': 0.030515748890667056, 'fraction_numerical': 0.006655997672219393, 'mean_word_length': 4.390119584395217, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Hybrid Batch Bayesian Optimization

Bayesian Optimization aims at optimizing an unknown non-convex/concave function that is costly to evaluate. We are interested in application scenarios where concurrent function evaluations are possible. Under such a setting, BO could choose to either sequentially evaluate the function, one input at a time and wait for the output of the function before making the next selection, or evaluate the function at a batch of multiple inputs at once. These two different settings are commonly referred to as the sequential and batch settings of Bayesian Optimization. In general, the sequential setting leads to better optimization performance as each function evaluation is selected with more information, whereas the batch setting has an advantage in terms of the total experimental time (the number of iterations). In this work, our goal is to combine the strength of both settings. Specifically, we systematically analyze Bayesian optimization using Gaussian process as the posterior estimator and provide a hybrid algorithm that, based on the current state, dynamically switches between a sequential policy and a batch policy with variable batch sizes. We provide theoretical justification for our algorithm and present experimental results on eight benchmark BO problems. The results show that our method achieves substantial speedup (up to %78) compared to a pure sequential policy, without suffering any significant performance loss.


Introduction
Bayesian optimization tries to optimize an unknown function f (·) by requesting a set of experiments when f (·) is costly to evaluate [8,4]. In this work, we are interested in finding a point x * ∈ X d such that: where X d is our d-dimensional compact input space and f (·) is the non-concave underlying function which has multiple local optima. The function f (·) might be the performance of a black box device characterized by input x. For example, in our motivating application we try to optimize the power output of nano-enhanced Microbial Fuel Cells (MFCs). MFCs [3] use micro-organisms to generate electricity. It has been shown that efficiency of generated electricity power significantly depends on the surface properties of the anode [12]. Our problem involves optimizing the surface properties of the anodes in order to maximize the output power. The goal is to develop an efficient BO algorithm for this application since running an experiment is very expensive and time consuming. Focusing on the task of function maximization, each run of BO consists of two main steps: estimating the values of the unknown function f (·) via a probabilistic model such as GP, and selecting the best next experiment(s) according to the probabilistic model via some selection criterion. The results of the experiment(s) are then be added to update the probabilistic model and this cycle is repeated until we meet a stopping criterion.
Most of the proposed selection criteria in BO are sequential, where only one experiment is selected at each iteration [11,8,14,9]. Sequential policies usually perform very well in practice, since they optimize the experiment selection at each iteration by using the maximum available information for each experiment. However, they are not time efficient in many applications where running an experiment takes a long time, and we have the capability to run multiple experiments in parallel. This motivates the batch algorithms in which more than one experiment is selected at each iteration.
Recently, Azimi et al. [2] introduced a batch BO approach that selects a batch of k experiments at each iteration that approximates the behavior of a given sequential heuristic. Ginsbourger et al. [7] introduced a constant liar heuristic algorithm to select a batch of experiments based on the Expected Improvement (EI) [9] policy. Specifically, after selecting an experiment by EI, the output of the selected point is set to a constant value. This experiment is then added to the prior and the procedure is repeated until k experiments are selected. Although these two batch algorithms [2,7] can speedup the experiment selection by a factor of k, their results show that batch selection in general performs worse than the sequential EI policy, especially when the total number of experiments is small. This observation motivates us to introduce a Hybrid BO approach that dynamically alternates between sequential and batch selection to achieve improved time efficiency over sequential without degrading the optimization performance.
In this paper, we focus on a class of batch policies that is based on simulating a sequential policy and provide a systematic approach to analyze such batch BO policies. We analytically connect the mismatch between the BO's probabilistic model and the underlying true function to the performance of the batch policy. We provide full characterization of simulated-based batch policies when the batch size is 2. For the purpose of illustration, consider a batch policy that selects 2 experiments. The first experiment matches the sequential policy. The choice of the second experiment, however, will depend on what is the simulated outcome of the first experiment. We show that the distance between the second experiment picked by a simulation-based batch policy (without the knowledge of the output of the first experiment) and the one picked by the sequential policy (with the knowledge of the output of the first experiment) is upper-bounded by a quantity that is proportional to the square root of the estimation error (of the outcome of the first experiment).
This analysis naturally gives rise to our hybrid batch/sequential algorithm. Our algorithm works as follows: At each step, given any sequential policy (EI in this paper), find the best next single experiment and estimate its possible outcome via BO's probabilistic model (GP in this paper). Then, update the prior with that point and choose the next best single experiment and so on. We analytically show that this process can be continued until a certain stopping criterion is met. This stopping criterion measures how much a simulated experiment is going to bias our probabilistic model (mainly because of inaccuracy in estimation of the outcomes of the first experiment). If the bias is small, we continue to add more examples to our batch; and if it is large, we stop.
The proposed algorithm has the appealing property that it behaves more like a sequential policy in early stages when the number of observed experiments is small, and naturally transits to batch mode in later stages when more experiments are available. This is because the stopping criterion tends to be more stringent in early stages because the bias of the prior can be potentially large, forcing the algorithm to act sequentially. The beauty of this algorithm is that it evolves from a sequential algorithm to a batch algorithm in an optimal manner characterized by our theoretical results.
Experimental results show that the proposed algorithm can achieve up to 78% speedup over the sequential policy without degrading the performance even with a very small number of experiments. We also show that, by increasing the number of experiments, the speedup rate is increased significantly which is consistent with the theoretical results presented in the paper.
The paper is organized as follows. We introduce the Gaussian Process which is used as our model in Section 2. The proposed dynamic batch algorithm is described in Section 3. Section 4 presents the experimental results and the paper is concluded in Section 5

Gaussian Process
A BO algorithm has two main ingredients: a probabilistic model for the unknown function, and, a selection criterion for choosing next best experiment(s) based on the model. We select GP [13] as our probabilistic model and EI [9] as our selection criterion. We study the properties of GP in this section and postpone the analysis of EI to the next section.
We use GP to build the posterior over the outcome values given our observation set . , x n } is the set of inputs and y O = {y 1 , y 2 , . . . , y n } is the set of outcomes (of the experiment) such that y j = f (x j ) and f (·) is the underlying unknown function.
For a new input point x i , GP models the unknown output y i = f (x i ) as a normal random variable where, k(·, ·) is any arbitrary kernel function. Under the GP model, the variance of a point z depends only on the location of the observed points and is independent of their outputs, i.e., σ 2 z|O,x = σ 2 z|O,x . Therefore, we can update the variance of any point z after finalizing our new query set x without the knowledge of their true outputs y = f (x). The following theorem characterizes the change in the variance of z if we query x.
From a practical point of view, this theorem enables us to update the variance of z via computing the difference ∆(σ z ) and add it to the previous value. This scheme is much faster than recalculating the variance of z directly. The computational bottleneck of this update is only the matrix inversion in D with complexity O(m 3 ), considering the fact that k(x O , x O ) −1 has been computed before, while the complexity of the direct variance computation is O (n + m) 3 .
The actual expected value µ z|O,x heavily depends on the true outputs y = f (x), which are not available. Without the knowledge of the true outputs, we make an estimation µ z|O,x based on the GP-suggested output values y. We bound this estimation error in the next theorem.
Here, · 2 is vector 2-norm. This theorem tells us that our estimation error at point z is proportional to the parameter γ z , which is known to us without the knowledge of y. Intuitively, if γ z is small, we would think that our estimation µ z|O,x is accurate and hence, we can make our decision about the point z without knowing y, i.e., before the result of experiment on x returns. This observation tells us that it is possible to do batch BO without a big loss in performance.
Remark: If we want to minimize our estimation error of µ z|O,x in expectation, we should set y = µ x|O . This is in some sense trivial and even counter intuitive. One might claim that if the unknown function is upper-bounded by M , then the best choice for y is M since it increases the expected value around the optimal point in the GP model. However, this theorem shows that this choice is overly optimistic.
The previous theorem provides a performance bound based on our estimation error on y, however, from a practical point of view, that bound cannot be computed since we do not know the exact values of y. As a practical measure, we would like to focus on the expected value of the estimation error as opposed to the error itself. Next corollary provides an upper-bound on the expected error, by simply taking expectation from the result of theorem 2. Moreover, Remark 1: We focus on the second bound in this corollary, which has two terms. The first term (γ z θ x ) measures "how close" the point z is to x. The second term captures the bias of our estimator y. According to this corollary, the best choice for y is the mean µ x|O .
Remark 2: This corollary entails that if for some small value of , we have then, we are guaranteed that E y |µ z|O,x − µ z|O,x | ≤ . Since γ z and θ x are both computable without the knowledge of y, this observation motivates us to use this as a stopping criterion for our algorithm to determine if the current estimation bias is too large to continue selecting more examples in the batch. In the nutshell, when we want to query a batch of samples, if this criterion is met, we are sure that our estimation of y is accurate and hence, we do not need to wait for the label of the selected examples before making the next selection.

Hybrid Batch Bayesian Optimization
In a sequential approach, we query for only one experiment at a time using a selection criterion (policy), mainly because the selection criterion requires the output of the previous query to find the next best one. Suppose we have the capability of running n b experiments in parallel, and we are limited by the total number of possible experiments n l . At each iteration, the question is whether or not we can query more than one sample to speed up the experimental procedure without losing performance comparing to the sequential approach.
We use Expected Improvement (EI) as our base sequential selection criterion. Below we provide the formal definition for EI.
Definition 2. EI [9] at point x with associated GP prediction y|O ∼ N (µ x|O , σ 2 x|O ) is defined to be where, u = (y max − µ x|O )/σ x|O and y max = max yi∈y O y i . Also, Φ(·) and φ(·) represent standard Gaussian distribution and density functions respectively.
Our proposed algorithm selects a batch (possibly one) of samples at each iteration based on the EI policy, where the batch size is dynamically determined at each step. In particular, the algorithm will continue to select more experiments if the condition in (3) is satisfied for the select point z.
To explain the algorithm, suppose we are at the beginning of the first round of the algorithm. Thus far, we have observed y O = f (x O ) at some randomly chosen sample points x O . To form our batch query, we start from an empty set of samples and gradually add the next best sample one at a time. The first sample we pick (x 1 ) is identical to the first sample that sequential EI picks (x * 1 ), simply because both maximize the same objective, i.e., x 1 = x * 1 . To pick our second sample, we estimate y * 1 = f (x * 1 ) by some valueŷ 1 . This estimation, changes the EI function of all unobserved points to some EI function formulated as In the light of this lemma, there is hope that x 2 = arg max EI (a potential batch sample from our algorithm) is close to x * 2 = arg max EI (the optimal sample picked by sequential policy). The next theorem bounds the error of our algorithm in terms of the second selected point in comparison to the sequential EI.
Theorem 3. Let Σ min be the minimum singular value of the Hessian matrix d 2 EI dx 2 (x) on the line intersecting x 2 and x * 2 . Then, Here x 2 is the second point selected by our simulation based batch method without knowing the outcome of x 1 , whereas x * 2 is the second point selected by the sequential EI method after knowing the outcome of x 1 . Remark 1: The parameter Σ min captures the curvature of the EI function around its optimal point x 2 . This curvature cannot be zero unless x * 2 is very far from x 2 , which is very unlikely due to the closeness of their expected values (see Corollary 1).
Remark 2: This theorem shows that the sample estimation error is proportional to the square root of the estimation error of y * 1 . This means that the sample estimation is more sensitive to the output estimation error for functions taking value in [0, 1].
This line of analysis can be extended to next samples. These results show that an algorithm based on the estimation can be successful. In practice, after we optimized EI for x 2 , then, we check the condition (3) (i.e., γ x2 (θ x * 1 + ŷ 1 − µ y|O 2 ) ≤ ) and if this condition is satisfied, we add x 2 to our batch query and move on to x 3 and so on. Algorithm 1 summarizes our proposed method for hybrid batch Bayesian optimization.

Algorithm 1 Hybrid Batch Expected Improvement
Input: Total budget of experiments (n l ), maximum batch size (n b ), the predictor ( y), current observation O = (xO,y O ) and stopping threshold .
end while In early stages, this algorithm behaves more like a sequential policy since the criterion for building up a batch is very hard to satisfy, mainly because θ x is large when we have only a few samples in O. After collecting enough samples, the term θ x starts decreasing and as it gets closer and closer to zero, we can select larger and larger batch sizes. Thus, the algorithm gradually transits into a batch policy while maintaining a close match to the performance to the pure sequential policy.  Table 1.

Experimental Results
The other two real benchmarks are Fuel Cell and Hydrogen. In Fuel Cell, the goal is to maximize the generated electricity from microbial fuel cells with by changing the nano structure properties of the anodes. We fit a regression model on the data to build our function f (·) for evaluation. In Hydrogen benchmark, the data has been collected as part of a study on Hydrogen production from a particular bacteria where the goal is to maximize the amount of Hydrogen production by optimizing the PH and Nitrogen levels of growth medium. Both Fuel cell and Hydrogen data are in [0, 1] 2 . Their contour plots are shown in Figure 1.
Setting. We use a GP using a zero-mean prior and Gaussian kernel function k(x, y) = exp(− 1 l x − y 2 ), with kernel width l = 0.01Σ d i=1 l i , where, l i is the length of the i th dimension [2]. For this kernel function, we can directly This corollary entails that after selecting the first experiment x * 1 , the set of points z such that ∆(σ z ) ≥ are located inside a hyper sphere centered at x * 1 . In other words, those inside the hyper sphere are those whose variance is affected significantly (more than ) when x * 1 is selected.

Corollary 3. Under the assumption of Corollary 2, we have
Similar to corollary 2, the corollary 3 represents a hyper sphere centered at x * 1 and the points which are inside the hyper sphere are those whose expected values are affected more than when x * 1 is selected. We run our algorithm on each benchmark for 100 independent times and the average simple regret is reported as the result. The simple regret is the difference between the maximum value of f (·), denoted by M , and y max after finishing the experimental procedure. In each run, the algorithm starts with 2 initial random points for 2, 3-dimensional benchmarks and 5 initial random points for higher dimensional benchmarks. The total number of experiments n l is set to 15 for 2, 3-dimensional and 30 for the higher dimensional benchmarks. The maximum batch size at each iteration, n b , is set to 5. The parameter is set to 0.02 for 2, 3-dimensional and 0.2 for higher dimensional benchmarks. Note that, our experimental setup is designed to match typical scenarios encountered in real applications, where we typically start with a very small number of random experiments, and are restricted with a total budget.
Results. Our algorithm requires us to select a specific estimation forŷ. Recall that our theoretical analysis from Theorem 2 suggests that to minimize the estimation error of µ z|O,x in expectation, we should use y = µ x|O . Here we hope to confirm this by comparing different possible estimations forŷ. In particular, we consider 6 different estimations ofŷ including: 1)ŷ = M , which means we expect to observe the best possible output for each experiment selected by EI; 2)ŷ = y max , where y max = max yi∈y O y i is our current best observation; 3)ŷ = (1 + ζ)y max , which means each step of EI algorithm is expected to improve the best current observation by margin ζ, we set the value of ζ to 0.1 in our experiment; 4)ŷ = µ x|O , which means we set the value ofŷ to be the expected output at that point; 5)ŷ = y min , where y min = min yi∈y O y i is the current minimum observed output; and 6)ŷ = random, which setŷ to a uniform random value drawn in [y min , y max ].
To demonstrate the effectiveness of our algorithm, we consider two state-of-the-art batch BO algorithms in the literature: 1) simulation matching (Matching) [2] and 2) the constant liar approach in which the output of the selected samples in the batch is set to their mean in order to select the next experiment (CL(μ)) [7]. For both methods, we set the batch size to k = 5. We have also reported the performance of the sequential EI and pure random selection policies.
The speedup of our proposed approach is calculated as the percentage of the samples in the whole experiment that are selected in batch mode. More specifically, if we finish n l samples in T steps, the speedup is calculated as 1 − T n l . Clearly, the maximum speedup in our setting is %80, that can be only achieved if we select 5 experiments at each time steps. For example, the speedup of proposed baseline batch approaches, Matching and CL(μ), are %80. Table 2 shows the result.
Interestingly, all of the 6 considered estimators achieved similar performance (comparable to EI) in terms of their regrets. The key difference between the different estimators is the level of speedup they achieve. In particular, we observe that the most speedup is achieved byŷ = µ x|O , for which we are able to produce over 70% speedup (very close to fully batch) for the three high dimensional functions Michalewicz, Shekel and Hartman 6.
Further inspection of the speedup rates reveal that settingŷ to a large value, for example M , y max , and (1+ζ)y max , generally leads to less speedup than the other choices. This can be explained by noting that a large value ofŷ will lead to higher chance of violating the condition required for making the next experiment selection in Algorithm 1, which is stated in Equation 3. In particular, for a largeŷ, the next point selected by EI will most likely be very close to x, since the mean of the points close to x are high. This will lead to a large γ z . Further, the quantity y − µ x|O 2 is likely very large. Consequently, it is easy to violate this condition thus stop the selection process early on. In contrast, if y = y min , although y − µ x|O 2 is large, we expect γ z to be small because the next point z selected by EI will likely to be far away from x since the mean and variance of the points close to x are very small. Considering the two terms jointly, we expect to achieve a higher speedup by settingŷ = y min comparing to settingŷ to a large value, which is exactly what we observe in our experiments. Finally, by settingŷ to µ x|O , we have y − µ x|O 2 = 0 and the stopping criterion only depends on γ z θ x . Thus we expect to achieve the maximum speedup among the different choices we consider forŷ.
Our experimental investigation shows that the size of the batch generally increases as the experiment goes forward. This is consistent with our theoretical results in which the value of γ z θ x + y − µ x|O 2 decreases as the variances decreases. Note that, sampling at any arbitrary point when the number of observations is small would change the variance of the input space significantly comparing to the case where there are a lot of observation points. Therefore, the stopping criteria of Algorithm 1 is less likely to be met in the early stages of the experimental procedure where there are a few observation points.
The µ-Constant Batch Approach. This part of the experiments is motivated by our theoretical analysis and the goal is to shed some lights on a batch method recently proposed by Ginsbourger et al. [7], which selects a batch of experiments that jointly maximize the EI objective. They show that finding such a batch of experiments is practically intractable. Therefore, they introduced a heuristic approach called Constant liar to select a batch of k experiments. After selecting the first experiment, Constant liar sets the output of the selected experiment as a constant value c. That experiment is then added to the set of observations and the next experiment is selected. This procedure is repeated until k experiments are selected. They introduced several possible ways for setting c, including c = M , c = µ and c = y min . They empirically demonstrated that setting c = M provided them a good result for their particular test functions. However, there is no theoretical justification or guidance toward what is the best c.
Our theoretical analysis, in particular Corollary 1, indicates that by setting c (ŷ in this paper) to µ x|O , the condition for continued experiment selection can be easily met comparing to other settings, i.e., γ z θ x ≤ . Thus, a batch of k ≥ 1 experiments are requested at most iterations without degrading the performance. This theoretical result also justifies the choice of setting c = µ x|O in the constant liar approach. We call this approach µ-Constant Batch. We run this algorithm on proposed 8 benchmarks for different batch sizes 5 and 10. Figures 2 and 3 show the performance of µ-Constant along with 5 competitive approaches: 1) Sequential EI; 2) Constant liar withŷ = M ; 3) Constant liar withŷ = y max ; 4) Constant liar withŷ = y min ; and 5) Matching, which is a recently proposed approach by Azimi et al. [2]. For this set of experiments, we use the same experimental setup as used in Table 2.
The results show that the µ-constant batch approach performs very competitively compared to the Matching approach, which is one of the best existing batch Bayesian optimization approach in the literature. In addition, it is more practical than the Matching approach for high dimensional applications since its computational complexity is significantly less than the Matching algorithm. Note that the performance of µ-Constant is also shown in Table 2 as CL(μ). It is worth emphasizing that while µ-Constant achieves highly competitive batch performance, it is consistently worse than sequential EI and the proposed Hybrid Batch EI algorithm. This result suggests that the stopping criterion used in Algorithm 1 is in fact effective toward identifying the condition under which we must stop increasing the batch size to avoid significant performance degradation compared to the sequential EI.

Conclusion
In the Bayesian optimization framework, we investigated the problem of batch query selection with the goal of maintaining the performance of a sequential policy which using fewer iterations. Although our results are for general BO problems, for the sake of clarity, we focused on the task of maximizing an unknown non-convex/concave function.
There are two main contributions in this paper.
Firstly, we introduce a systematic way to analyze the performance and limits of simulation-based batch BO methods by a) proving universal bounds on the bias caused by the simulation (estimation-of-outcome) error; and b) analyzing the selection of the second experiment when we have an estimate of the outcome of the first experiment. In all cases, we provide theoretical bounds on the error, relating the simulation error to the prediction error of the next best experiment.
Secondly, based on the analysis above, we proposed an algorithm that behaves optimally in expectation. This algorithm at each step decides whether or not to pick another query to add to the current batch, and as such dynamically determines the appropriate batch size at each step. In early iterations, our algorithm behaves more similar to the sequential policy and gradually moves toward a batch policy with variable batch sizes.
The empirical evaluation over both synthetic and real data shows substantial speedup (up to 78% ) compared to the corresponding sequential policy, with little to nothing loss in the optimization performance. Our theoretical results also shed some interesting light on the Constant-liar approach, a recently proposed batch selection method based on the EI objective.
A Proof of Theorem 1 Recalling the notation introduced in the Theorem statement, we have This concludes the proof of the theorem.

B Proof of Theorem 2
By definition and block matrix inversion lemma, we have For the second part, we have This concludes the proof of the theorem.