Bayesian optimization for the DQW example#

Input files:
  • double_QW_AlGaAs.nnp

Python scripts:
  • double_QW_bayesian.py

Download files

This page describes the optimization of the double quantum well design using Bayesian optimization. For a description of the physical model and device parameters, as well as setup of the problem, see optimization of a simple nano device page.

Optimization progress#

The code below shows how to use the Bayesian optimization once the IO and the Metric objects are defined.

from nextnano_optimizers.optimizers import BayesianOptimization

variable_boundaries = ([4.0, 4.0, 0.0, 0.0], [12.0, 12.0, 0.3, 0.3])  # nm, nm, -, -

BETA = 1.0  # UCB hyperparameter

optimizer = BayesianOptimization(nn_io, metric, variable_boundaries)
optimizer.setup_plotting(objective_log_scale=True)

result = optimizer.run(
   trials=300, n_initial=40, seed=0, live_progress=True, acquisition="UCB", acquisition_kwargs={"beta": BETA}
)

From the total budget of 300 evaluations, the first 40 are used for random sampling of the design space. The remaining 260 evaluations are performed using the UCB acquisition function with \(\beta=1.0\). The optimization progress is shown in the figure below:

Progress of the Bayesian optimization

Figure 9 Live progress of the Bayesian optimization of the DQW design. The left panel shows the objective of every evaluation together with the best value found so far, on a logarithmic scale set by objective_log_scale=True. The right panels show the four design parameters over the same evaluations.#

The algorithm converges to a point close to a global minimum after about 170 evaluation, further refining the design at about 240 evaluations.

Optimization results#

The best design found by the Bayesian optimization can be inspected with the code below:

x = result["champion_x"]
print(f"Optimal: Lx_QW1 = {x[0]:.3f} nm\n"
      f"         Lx_QW2 = {x[1]:.3f} nm\n"
      f"         Al_QW1 = {x[2]:.3f}\n"
      f"         Al_QW2 = {x[3]:.3f}")
print(f"Objective: {result['champion_f']:.4g}")

The optimization results, namely the objective value and the optimized parameters are shown in the table below.

Table 4 Best design found by the Bayesian optimization, compared with the design used to generate the targets.#

Design

Objective

Lx_QW1 (nm)

Lx_QW2 (nm)

Al_QW1

Al_QW2

Ideal design

0

10.506

11.302

0.182

0.219

Champion solution

0.032

10.524

11.345

0.181

0.218

Within the budget of 300 evaluations the Bayesian optimization recovers the ideal design with an accuracy of 0.05nm in the well widths and 0.001 in the Al fractions.