Amplify-BBOptΒΆ

Amplify-BBOpt is a Python module to facilitate execution of black-box optimization.

Amplify-BBOpt is built around the Amplify SDK, a Python library for formulating combinatorial optimization problems and running external optimization solvers such as Ising machines.

Of course, you can implement black-box optimization for various problems (such as these) using the Amplify SDK. Amplify-BBOpt just makes it easier.

Note

Depending on the black-box optimizer you will use with Amplify-BBOpt, you may need an API token for the optimization solver. For Amplify Annealing Engine (AE), you can get a free API token after user registration.

Attention

Amplify-BBOpt is currently in version 0.x.x and is actively under development. The API and functionality are subject to change as the software has yet to reach a stable release. Users should be aware that breaking changes or modifications may occur without prior notification.

How easy is Amplify-BBOpt?ΒΆ

The Amplify SDK’s tutorial describes example problems of black-box optimization. One of them is β€œOptimization of the Airfoil Geometry with Fluid Flow Simulation”. The implementation is relatively straightforward, considering it utilizes an Ising machine, thanks to the Amplify SDK. However, the code is undeniably lengthy. Below is an example code snippet doing similar stuff by using Amplify-BBOpt:

import numpy as np
from amplify import FixstarsClient
from amplify_bbopt import (
    DatasetGenerator,
    FMQAOptimizer,
    RealVariable,
    blackbox,
)


@blackbox
def bb_func(
    xi0: float = RealVariable(bounds=(1, 10), nbins=20),
    eta0: float = RealVariable(bounds=(1, 10), nbins=20),
    alpha: float = RealVariable(bounds=(0, 40), nbins=40),
) -> float:
    # Definition of the black-box function to compute the negative lift-drag ratio as `cost`.
    # This is omitted as this part is not directly relevant here...
    return cost

# Generate initial training data set
data = DatasetGenerator(objective=bb_func).generate(num_samples=10)

# Set up solver client
client = FixstarsClient()
client.parameters.timeout = 2000  # 2 seconds
client.token = "xxxxxxxxxxx"  # Enter your Amplify API token.

# Instantiate the kernel-QA optimizer
optimizer = FMQAOptimizer(data=data, client=client, objective=bb_func)

# Perform kernel-QA optimization for [num_cycles] cycles
optimizer.optimize(num_cycles=20)

# Print results
print(f"{optimizer.best_solution=}")  # Solution (optimal input)
print(f"{optimizer.best_objective=:.3e}")  # Objective function value