Overview of Amplify-BBOpt¶

Optimization process flow¶

Amplify-BBOpt performs black-box optimization using a sequential optimization approach.

As illustrated in the optimization flow diagram below, sequential optimization proceeds by repeating multiple optimization cycles. In Step ② — the minimization of the surrogate model — an Ising machine based on quantum or quantum-inspired technologies is utilized.

_images/typical_flow.drawio.svg

Execution procedure¶

This section describes the overall workflow and execution steps of Amplify-BBOpt. Black-box optimization can be performed by following the steps below:

(1) Create Decision Variables

First, create the decision variables.

(2) Define the Objective Function

Next, define the black-box objective function using the @blackbox decorator provided by Amplify-BBOpt. The contents of this function typically involve numerical simulations or experimental measurements, and related post-processing.

(3) Run the Optimization

Instantiate the optimization class Optimizer and execute the optimization with optimize().

(4) Evaluate the Results

The results can be obtained from the attributes of Optimizer or as optimization history.

Hint

If needed, you can also specify constraints on the decision variables after Step (2). In such cases, the optimization will be carried out while satisfying the given constraints.

Implementation example¶

Below is an example of black-box optimization for designing a fluid device with the goal of minimizing drag.

Inside the black-box objective function my_blackbox_func, we use a hypothetical external simulator module, DragSimulator, to run a simulation that computes the drag force on an object placed in a flow field.

Based on the simulation results, the optimizer searches for design parameters that minimize the objective value (drag force), yielding design parameters for an efficient fluid device with reduced drag.

import DragSimulator  # A hypothetical simulator class

from amplify import FixstarsClient
from amplify_bbopt import blackbox, KMTrainer, Optimizer, RealVariable


# (1) Create decision variables, and (2) define a black-box objective function
@blackbox
def my_blackbox_func(
    width: float = RealVariable(bounds=(1, 20)),
    height: float = RealVariable(bounds=(1, 5)),
    angle: float = RealVariable(bounds=(0, 45)),
) -> float:
    """Return the drag force acting on the object obtained by the simulation."""
    drag_force = DragSimulator(width, height, angle).simulate()
    return drag_force


# (3) Instantiation of the optimization class and execution
optimizer = Optimizer(  
    blackbox=my_blackbox_func,
    trainer=KMTrainer(),  # Set a surrogate model class
    client=FixstarsClient(),  # Set an Ising machine
)

optimizer.add_random_training_data(num_data=2) # Add samples to the initial training data

optimizer.optimize(num_iterations=10) # Perform optimization cycles for 10 times


# Print the optimization result
print(f"{optimizer.best=}")