# Algorithm

This section describes an overview of Bayesian optimization. For technical details, please refer to this reference .

## Bayesian optimization

Bayesian optimization is a method that can be used in complex simulations or real-world experimental tasks where the evaluation of the objective function (e.g., property values) is very costly. In other words, Bayesian optimization solves the problem of finding explanatory variables (material composition, structure, process and simulation parameters, etc.) that have a better objective function (material properties, etc.) with as few experiments and simulations as possible. In Bayesian optimization, we start from a situation where we have a list of candidates for the explanatory variables to be searched (represented by the vector \({\bf x}\)). Then, from among the candidates, the one that is expected to improve the objective function \(y\) is selected by making good use of prediction by machine learning (using Gaussian process regression). We then evaluate the value of the objective function by performing experiments and simulations on the candidates. By repeating the process of selection by machine learning and evaluation by experimental simulation, optimization can be achieved in as few times as possible.

The details of the Bayesian optimization algorithm are described below.

Step1: Initialization

Prepare the space to be explored in advance. In other words, list up the composition, structure, process, simulation parameters, etc. of the candidate materials as a vector \({\bf x}\). At this stage, the value of the objective function is not known. A few candidates are chosen as initial conditions and the value of the objective function \(y\) is estimated by experiment or simulation. This gives us the training data \(D = \{ {\bf x}_i, y_i \}_{(i=1, \cdots, N)}\) with the explanatory variables \({\bf x}\) and the objective function \(y\).

Step2: Selection of candidates

Using the training data, learn a Gaussian process. For Gaussian process, the mean of the predictions at arbitary \({\bf x}\) is \(\mu_c ({\bf x})\) and the variance is \(\sigma_c ({\bf x})\) are given as follows

where \(k({\bf x}, {\bf x}')\) is a function called as a kernel, and it represents the similarity of two vectors. In general, the following Gaussian kernel is used:

Using this kernel function, \({\bf k}({\bf x})\) and \(K\) are computed as follows

For all candidates that have not yet been tested or simulated, the prediction \(\mu_c ({\bf x})\) and the variance associated with the uncertainty of the prediction \(\sigma_c ({\bf x})\) are estimated. Using this, the acquisition function is calculated. Then, the candidate \({\bf x}^*\) is selected that maximizes the acquisition function from among the candidates for which we do not yet know the value of the objective function. In this case, \(\sigma\) and \(\eta\) are called hyperparameters, and PHYSBO will automatically set the best value.

As an acquisition function, for example, Maximum Probability of Improvement (PI) and Maximum Expected Improvement (EI) are useful. The score of PI is defined as follows.

where \(\Phi(\cdot)\) is the cumulative distribution function. The PI score represents the probability of exceeding the maximum \(y_{\max}\) of the currently obtained \(y\). In addition, the EI score is the expected value of the difference between the predicted value and the current maximum \(y_{\max}\) and is given by

where \(\phi(\cdot)\) is a probability density function.

Step3: Experiment (Simulation)

Perform an experiment or simulation on the candidate \({\bf x}^*\) with the largest acquisition function selected in step 2, and estimate the objective function value \(y\). This will add one more piece of training data. Repeat steps 2 and 3 to search for candidates with good scores.

## Accelerating Bayesian Optimization with PHYSBO

In PHYSBO, random feature map, Thompson sampling, and Cholesky decomposition are used to accelerate the calculation of Bayesian optimization. First, the random feature map is introduced. By introducing the random feature map \(\phi (\mathbf{x})\), we can approximate the Gaussian kernel \(k(\mathbf{x},\mathbf{x}')\) as follows.

where \(z_{\omega, b} (\mathbf{x}) = \sqrt{2} \cos (\boldsymbol{\omega}^\top \mathbf{x}+b)\). Then, \(\boldsymbol{\omega}\) is generated from \(p(\boldsymbol{\omega}) = (2\pi)^{-d/2} \exp (-\|\boldsymbol{\omega}\|^2/2)\) and \(b\) is chosen uniformly from \([0, 2 \pi]\) is chosen uniformly from \([0, 2 \pi]\). This approximation is strictly valid in the limit of \(l \to \infty\), where the value of \(l\) is the dimension of the random feature map.

\(\Phi\) can be represented as a \(l\) row \(n\) column matrix with \(\phi(\mathbf{x}_i)\) in each column by \(\mathbf{x}\) vector of training data as follows:

It is seen that the following relation is satisfied:

Next, a method that uses Thompson sampling to make the computation time for candidate prediction \(O(l)\) is introduced. Note that using EI or PI will result in \(O(l^2)\) because of the need to evaluate the variance. In order to perform Thompson sampling, the Bayesian linear model defined below is used.

where \(\phi(\mathbf{x})\) is random feature map described above and \(\mathbf{w}\) is a coefficient vector. In a Gaussian process, when the training data \(D\) is given, this \(\mathbf{w}\) is determined to follow the following Gaussian distribution.

In Thompson sampling, one coefficient vector is sampled according to this posterior probability distribution and set to \(\mathbf{w}^*\), which represents the acquisition function as follows

The \(\mathbf{x}^*\) that maximizes \(\text{TS} (\mathbf{x})\) will be selected as the next candidate. In this case, \(\phi (\mathbf{x})\) is an \(l\) dimensional vector, so the acquisition function can be computed with \(O(l)\).

Next, the manner for accelerating the sampling of \(\mathbf{w}\) is introduced. The matrix \(A\) is defined as follows.

Then the posterior probability distribution is given as

Therefore, in order to sample \(\mathbf{w}\), we need to calculate \(A^{-1}\). Now consider the case of the newly added \((\mathbf{x}', y')\) in the Bayesian optimization iteration. With the addition of this data, the matrix \(A\) is updated as

This update can be done using the Cholesky decomposition ( \(A= L^\top L\) ), which reduces the time it takes to compute \(A^{-1}\) to \(O(l^2)\). If we compute \(A^{-1}\) at every step, the numerical cost becomes \(O(l^3)\). The \(\mathbf{w}\) is obtained by

where \(\mathbf{w}_0\) is sampled from \(\mathcal{N} (0,A^{-1})\) and \(\boldsymbol{\mu}\) is calculated by

By using these techniques, a computation time becomes almost linear in the number of training data.