Client

This section describes the Ising machine clients.

Client Class Overview

The client class provides an interface for getting and setting hardware parameters of each Ising machine, as well as for executing it. The typical use of the client class is to give the client class object as a driver to the solver class Solver, so that the solver class can solve logical models using the corresponding Ising machine. See Solver or execution example of each client for more details and examples.

Note

Although the client class can also be used as a solver for the physical model (see physical model solver for more information), it is recommended to use the solver class.

There are two types of parameters that the client class can set:

  • Settings of access information and execution of the Ising machines

    These are provided as the attributes of the client class. It sets configurations such as the URL of the access point and API token. Some clients have settings related to data compression and data transmission methods.

  • Execution parameters of the Ising machines

    It sets the execution parameters according to the API specifications of the machines. It is provided by the attribute parameters of the client class.

See also

Please refer to Client for more information on the client classes and their related classes.

Fixstars

Amplify AE Client Class

Please refer to Fixstars client reference for more information.

Name

Fixstars Amplify Annealing Engine

Client class

FixstarsClient

Execution parameter class

FixstarsClientParameters

Execution result class

FixstarsClientResult

Execution time class

FixstarsClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

262144 or greater

Number of logical bits (Fully connected coupling)

131072

API endpoint (default)

https://optigan.fixstars.com/

Attributes of Amplify AE Client Class

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters FixstarsClientParameters.

version

Get the version string of the Amplify Annealing Engine.

url

Get or set the API URL.

proxy

Get or set the proxy server address.

token

Get or set the API token.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

compression

Specify whether to compress the transmitted data. Defaults to True.

Example of Amplify AE Client

from amplify import BinarySymbolGenerator, Solver
from amplify.client import FixstarsClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = FixstarsClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.timeout = 1000  # Timeout is 1 second

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

D-Wave

Note

To use D-Wave Sampler and Leap Hybrid Solver, dwave-system package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:

$ pip install amplify[extra]

D-Wave Client Classes

Please refer to D-Wave client reference for more information.

Name

D-Wave Sampler (Ocean SDK)

Client class

DWaveSamplerClient

Execution parameter class

DWaveSamplerClientQuantumSolverParametersOcean

Execution result class

DWaveSamplerClientResult

Execution time class

DWaveSamplerClientResultTiming

Physical graph

Zephyr graph (Advantage2_prototype1.1), Pegasus graph (Advantage_system4.1, Advantage_system6.3)

Number of physical bits

563 (Advantage2_prototype1.1), 5627 (Advantage_system4.1), 5614 (Advantage_system6.3)

Number of logical bits (Fully connected coupling)

52 (Advantage2_prototype1.1), 177 (Advantage_system4.1), 175 (Advantage_system6.1)

API endpoint (default)

https://cloud.dwavesys.com/sapi

Name

Leap Hybrid Solver (Ocean SDK)

Client class

LeapHybridSamplerClient

Execution parameter class

LeapHybridSamplerClientLeapHybridSolverParameters

Execution result class

LeapHybridSamplerClientResult

Execution time class

LeapHybridSamplerClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

1000000

Number of logical bits (Fully connected coupling)

1000000

API endpoint (default)

https://cloud.dwavesys.com/sapi

Attributes of D-Wave Client

Name

Description

num_bits

Get the maximum number of executable variables.

D-Wave Sampler:

N/A

Leap Hybrid Solver:

1000000

parameters

Get the execution parameters.

D-Wave Sampler:

DWaveSamplerClientQuantumSolverParametersOcean

Leap Hybrid Solver:

LeapHybridSamplerClientLeapHybridSolverParameters

proxy

Get or set the proxy server address.

solver

Get or set the name of the solver to be executed.

D-Wave Sampler:

Advantage2_prototype1.1, "Advantage_system4.1", "Advantage_system6.3"

Leap Hybrid Solver:

"hybrid_binary_quadratic_model_version2", "hybrid_binary_quadratic_model_version2p"

solver_names

Get the list of available solver names.

token

Get or set the API token.

url

Get or set the API URL.

version

Get the solver name with its version string.

Example of D-Wave Client

D-Wave Sampler Client

from amplify import BinarySymbolGenerator, Solver
from amplify.client.ocean import DWaveSamplerClient

client = DWaveSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Specify the solver (the available solver names can be obtained by `solver_names`)
client.solver = "Advantage_system4.1"
client.parameters.num_reads = 100  # Number of executions

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

By setting token, the list of the available solver names related to the token can be obtained as follows:

>>> client.solver_names
['Advantage_system4.1', 'Advantage_system6.3', 'Advantage2_prototype1.1']

D-Wave Leap Hybrid Solver Client

from amplify import BinarySymbolGenerator, Solver
from amplify.client.ocean import LeapHybridSamplerClient

client = LeapHybridSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Specify the solver (the available solver names can be obtained by `solver_names`)
client.solver = "hybrid_binary_quadratic_model_version2"
client.parameters.time_limit = 3  # Time limit is 3 seconds

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Similar to DwaveSamplerClient, the available solver names can be obtained as follows:

>>> client.solver_names
['hybrid_binary_quadratic_model_version2']

Fujitsu

Fujitsu Client Classes

Please refer to Fujitsu client reference for more information.

Name

FujitsuDASolver

Client class

FujitsuDASolverClient

Execution parameter class

FujitsuDASolverClientParameters

Execution result class

FujitsuDASolverClientResult

Execution time class

FujitsuDASolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

1024

Number of logical bits (Fully connected coupling)

1024

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDASolver (Expert Mode)

Client class

FujitsuDASolverExpertClient

Execution parameter class

FujitsuDASolverExpertClientParameters

Execution result class

FujitsuDASolverExpertClientResult

Execution time class

FujitsuDASolverExpertClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

1024

Number of logical bits (Fully connected coupling)

1024

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDAPTSolver

Client class

FujitsuDAPTSolverClient

Execution parameter class

FujitsuDAPTSolverClientParameters

Execution result class

FujitsuDAPTSolverClientResult

Execution time class

FujitsuDAPTSolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

1024

Number of logical bits (Fully connected coupling)

1024

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDAMixedModeSolver

Client class

FujitsuDAMixedModeSolverClient

Execution parameter class

FujitsuDAMixedModeSolverClientParameters

Execution result class

FujitsuDAMixedModeSolverClientResult

Execution time class

FujitsuDAMixedModeSolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

1024

Number of logical bits (Fully connected coupling)

1024

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA2Solver

Client class

FujitsuDA2SolverClient

Execution parameter class

FujitsuDA2SolverClientParameters

Execution result class

FujitsuDA2SolverClientResult

Execution time class

FujitsuDA2SolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

8192

Number of logical bits (Fully connected coupling)

8192

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA2Solver (Expert Mode)

Client class

FujitsuDA2SolverExpertClient

Execution parameter class

FujitsuDA2SolverExpertClientParameters

Execution result class

FujitsuDA2SolverExpertClientResult

Execution time class

FujitsuDA2SolverExpertClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

8192

Number of logical bits (Fully connected coupling)

8192

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA2PTSolver

Client class

FujitsuDA2PTSolverClient

Execution parameter class

FujitsuDA2PTSolverClientParameters

Execution result class

FujitsuDA2PTSolverClientResult

Execution time class

FujitsuDA2PTSolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

8192

Number of logical bits (Fully connected coupling)

8192

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA2MixedModeSolver

Client class

FujitsuDA2MixedModeSolverClient

Execution parameter class

FujitsuDA2MixedModeSolverClientParameters

Execution result class

FujitsuDA2MixedModeSolverClientResult

Execution time class

FujitsuDA2MixedModeSolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

8192

Number of logical bits (Fully connected coupling)

8192

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA3SolverClient

Client class

FujitsuDA3SolverClient

Execution parameter class

FujitsuDA3SolverClientParameters

Execution result class

FujitsuDA3SolverClientResult

Execution time class

FujitsuDA3SolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

100000

Number of logical bits (Fully connected coupling)

100000

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Name

FujitsuDA4SolverClient

Client class

FujitsuDA4SolverClient

Execution parameter class

FujitsuDA4SolverClientParameters

Execution result class

FujitsuDA4SolverClientResult

Execution time class

FujitsuDA4SolverClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

100000

Number of logical bits (Fully connected coupling)

100000

API endpoint (default)

https://api.aispf.global.fujitsu.com/da/

Attributes of Fujitsu Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters.

FujitsuDASolver:

FujitsuDASolverClientParameters

FujitsuDASolver (Expert Mode):

FujitsuDASolverExpertClientParameters

FujitsuDAPTSolver:

FujitsuDAPTSolverClientParameters

FujitsuDAMixedModeSolver:

FujitsuDAMixedModeSolverClientParameters

FujitsuDA2Solver:

FujitsuDA2SolverClientParameters

FujitsuDA2Solver (Expert Mode):

FujitsuDA2SolverExpertClientParameters

FujitsuDA2PTSolver:

FujitsuDA2PTSolverClientParameters

FujitsuDA2MixedModeSolver:

FujitsuDA2MixedModeSolverClientParameters

FujitsuDA3Solver:

FujitsuDA3SolverClientParameters

FujitsuDA4Solver:

FujitsuDA4SolverClientParameters

url

Get or set the API URL.

proxy

Get or set the proxy server address.

token

Get or set the API token.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

version

Get the API version string of the Fujitsu Digital Annealer.

set_penalty_binary_polynomial

Specify whether to use penalty quadratic polynomial for FujitsuDA3SolverClient / FujitsuDA4SolverClient. Defaults to True.

set_one_way_one_hot_groups

Specify whether to use one-dimensional one-hot constraint information for FujitsuDA3SolverClient / FujitsuDA4SolverClient. Defaults to False.

set_two_way_one_hot_groups

Specify whether to use two-dimensional one-hot constraint information for FujitsuDA3SolverClient / FujitsuDA4SolverClient. Defaults to False.

set_inequalities

Specify whether to use linear inequality constraints for FujitsuDA3SolverClient / FujitsuDA4SolverClient. Defaults to True.

Example of Fujitsu Client

FujitsuDA2PTSolverClient

from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA2PTSolverClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = FujitsuDA2PTSolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.number_iterations = 1000

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Note

Please refer to the corresponding parts of the Schemes of Digital Annealer API reference (QUBO API V2) for details on the parameters of FujitsuDA and FujitsuDA2 clients.

FujitsuDA3SolverClient

from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA3SolverClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = FujitsuDA3SolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.time_limit_sec = 1  # Time limit is 1 second

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]',
 'energy = 0.0, q = [1. 0. 0.]',
 'energy = 0.0, q = [0. 1. 1.]',
 'energy = 1.0, q = [0. 0. 0.]']

Note

Please refer to FujitsuDA3Solver Schemas of Digital Annealer API reference (QUBO API V3) for details of FujitsuDA3SolverClient parameters.

FujitsuDA4SolverClient

from amplify import BinarySymbolGenerator, Solver
from amplify.client import FujitsuDA4SolverClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = FujitsuDA4SolverClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.time_limit_sec = 1  # Time limit is 1 second

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]',
 'energy = 0.0, q = [1. 0. 0.]',
 'energy = 0.0, q = [0. 1. 1.]',
 'energy = 1.0, q = [0. 0. 0.]']

Note

Please refer to FujitsuDA4Solver Schemas of Digital Annealer API reference (QUBO API V4) for details of FujitsuDA4SolverClient parameters.

Toshiba

Toshiba Client Class

Please refer to Toshiba client reference for more information.

Name

Toshiba SQBM+

Client class

ToshibaClient

Execution parameter class

ToshibaClientParameters

Execution result class

ToshibaClientResult

Execution time class

ToshibaClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

100000

Number of logical bits (Fully connected coupling)

100000

API endpoint (default)

N/A

Name

Toshiba SQBM+ (version 2.0.0 ~)

Client class

ToshibaSQBM2Client

Execution parameter class

ToshibaSQBM2ClientParameters

Execution result class

ToshibaSQBM2ClientResult

Execution time class

ToshibaSQBM2ClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

100000

Number of logical bits (Fully connected coupling)

100000

API endpoint (default)

N/A

Attributes of Toshiba Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters.

url

Get or set the API URL.

proxy

Get or set the proxy server address.

token

Get or set the API token.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

version

Get the API version string of the Toshiba SBM/SQBM+.

Attributes of ToshibaSQBM2Client

Attributes that are only available in ToshibaSQBM2Client are as follows.

Name

Description

request_data_type

Get or set the request data format. Two types of data types are supported. 'HDF5' and 'MatrixMarket'. Default is 'HDF5'.

Example of Toshiba Client

ToshibaClient

from amplify import BinarySymbolGenerator, Solver
from amplify.client import ToshibaClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = ToshibaClient()
client.url = "http://xxx.xxx.xxx.xxx:xxxx/"
client.parameters.loops = 0 # not specify the number of loops (only timeout will be used)
client.parameters.timeout = 1  # Timeout is 1 second

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Note

Please refer to Simulated Bifurcation Machine (SBM) User Manual for details of Toshiba SBM.

ToshibaSQBM2Client

from amplify import BinarySymbolGenerator, Solver
from amplify.client import ToshibaSQBM2Client

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = ToshibaSQBM2Client()
client.url = "http://xxx.xxx.xxx.xxx:xxxx/"
client.parameters.loops = 0 # not specify the number of loops (only timeout will be used)
client.parameters.timeout = 1  # timeout 1 second

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Hitachi

Hitachi Client Class

Please refer to Hitachi client reference for more information.

Name

Hitachi CMOS annealing machine (type 4: GPU)

Client class

HitachiClient

Execution parameter class

HitachiClientParameters

Execution result class

HitachiClientResult

Execution time class

HitachiClientResultTiming

Physical graph

King Graph

Number of physical bits

262144 (512x512)

Number of logical bits (Fully connected coupling)

512

API endpoint (default)

https://annealing−cloud.com/api/v2/

Attributes of Hitachi Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters HitachiClientParameters.

url

Get or set the API URL.

proxy

Get or set the proxy server address.

token

Get or set the API token.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

version

Get the API version string of the Hitachi CMOS annealing machine.

Example of Hitachi Client

HitachiClient

from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import HitachiClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = HitachiClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.temperature_num_steps = 10
client.parameters.temperature_step_length = 100
client.parameters.temperature_initial = 100.0
client.parameters.temperature_target = 0.02

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Note

Please refer to API reference V2 for details of Hitachi CMOS annealing machine.

Hiroshima Univ. / NTT DATA

ABS Client Class

Please refer to ABS client reference for details.

Name

ABS QUBO Solver

Client Class

ABSClient

Execution parameter class

ABSClientParameters

Execution result class

ABSClientResult

Execution time class

ABSClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

32768

Number of logical bits (Fully connected coupling)

32768

API URL (default)

https://qubosolver.cs.hiroshima-u.ac.jp

Attributes of ABS Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters ABSClientParameters

url

Get or set the API URL

proxy

Get or set the proxy server address.

user_name

Get or set the user ID

password

Get or set the password

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

version

Get the version string of the ABS QUBO solver client.

Example of ABS Client

ABSClient

from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import ABSClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = ABSClient()
client.user_name = "xxxx"
client.password = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.timeout = 10
client.parameters.word_size = 16
client.parameters.arithmetic_precision = 32

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Note

Please refer to https://qubo.cs.hiroshima-u.ac.jp/solver-trial for details of ABS QUBO Solver.

Gurobi

Note

To make use of Gurobi Client, the software and the license of Gurobi must be installed properly on your computer.

Gurobi Client Class

Please refer to gurobi client reference for details.

Name

Gurobi Optimizer

Client Class

GurobiClient

Execution parameter class

GurobiClientParameters

Execution result class

GurobiClientResult

Execution time class

GurobiClientResultTiming

Attributes of Gurobi Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters GurobiClientParameters

gurobi_path

Get or set the path to the dynamic library of Gurobi.

write_model

Get or set the filepath where to save the model data input to Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are .mps, .rew, .lp, and .rlp. If the model is LP, .dua and .dlp files are also valid to output the dual problem.

write_solution

Get or set the filepath where to save the solution output by Gurobi. Defaults to an empty string and the model data will not be saved. The valid file extensions are .sol and .json.

version

Get the version string of the Gurobi dynamic library.

Example of Gurobi Client

GurobiClient

from amplify import BinaryPoly, gen_symbols, Solver
from amplify.client import GurobiClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = GurobiClient()
client.parameters.time_limit = 10

solver = Solver(client)

result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Note

Please refer to documents for details of Gurobi Optimizer.

IBM Qiskit

Run QAOA with IBM Quantum or its simulator using Qiskit.

Note

To use an actual quantum computer with Qiskit Client, make sure to obtain API token of IBM Quantum in advance.

Note

To use the Qiskit client, amplify.qaoa package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:

$ pip install amplify[extra]

Qiskit Client Class

Please refer to qiskit client reference for details.

Name

Qiskit Classes

Client Class

QiskitClient

Execution parameter class

QiskitClientParameters

Execution result class

QiskitClientResult

Execution time class

QiskitClientResultTiming

Attributes of Qiskit Client

Name

Description

num_bits

Get the maximum number of executable variables.

device

Get or set the environment (“CPU”, “GPU”, “QPU”) in which QAOA will run.

token

Get or set the API token to connect to IBM Quantum.

backend

Get or set the machine name (or simulation method name) on which QAOA will run

parameters

Get the QAOA execution parameters QiskitClientParameters

version

Get the version string of the ampllify.qaoa library.

Note

To run a simulation using a GPU, the qiskit-aer package needs to be uninstalled and replaced with the qiskit-aer-gpu package, as follows:

$ pip uninstall qiskit-aer
$ pip install qiskit-aer-gpu

Example of QiskitClient

Real quantum devices

from amplify import BinarySymbolGenerator, Solver
from amplify.client import QiskitClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = QiskitClient()
client.device = "QPU"  # Set "QPU" to use a real quantum device
client.token = "xxxxxxxx"  # API token is required to use a real quantum device
# Set the machine name: If not specified, a "least busy" machine that
# satisfies the required number of bits for execution is automatically selected.
client.backend = "ibmq_bogota"

# Settings of QAOA parameters
client.parameters.reps = 10     # Depth of the circuit
client.parameters.shots = 1024  # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 216', 'energy = 0.0, q = [0. 0. 1.], frequency = 56', 'energy = 0.0, q = [0. 1. 1.], frequency = 188', 'energy = 0.0, q = [1. 0. 0.], frequency = 235', 'energy = 1.0, q = [0. 1. 0.], frequency = 199', 'energy = 1.0, q = [1. 1. 1.], frequency = 41', 'energy = 1.0, q = [0. 0. 0.], frequency = 62', 'energy = 2.0, q = [1. 1. 0.], frequency = 27']

Note

Please refer to QiskitClientParameters for QAOA parameters in details.

Ideal quantum circuit simulators

from amplify import BinaryPoly, BinarySymbolGenerator, Solver
from amplify.client import QiskitClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = QiskitClient()
client.device = "CPU" # Set "CPU" or "GPU" for simulations
client.backend = "statevector" # Set the simulation method

# Settings of QAOA parameters
client.parameters.reps = 10     # Depth of the circuit
client.parameters.shots = 1024  # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278']

Note

Please refer to Qiskit document for simulator method names.

Simulators that mimic real machines

from amplify import BinaryPoly, BinarySymbolGenerator, Solver
from amplify.client import QiskitClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = QiskitClient()
client.device = "CPU" # Set "CPU" or "GPU" for simulations
client.token = "xxxxxxxx"  # API token is required to use a real quantum device
# Set the machine name: If not specified, a "least busy" machine that
# satisfies the required number of bits for execution is automatically selected.
client.backend = "ibmq_bogota"

# Settings of QAOA parameters
client.parameters.reps = 10     # Depth of the circuit
client.parameters.shots = 1024  # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 250', 'energy = 0.0, q = [0. 1. 1.], frequency = 246', 'energy = 0.0, q = [1. 0. 0.], frequency = 250', 'energy = 1.0, q = [0. 1. 0.], frequency = 278']

Qulacs

Run QAOA with quantum simulator Qulacs.

Note

To use the Qulacs client, amplify.qaoa package needs to be installed. The dependent packages can be installed by installing Amplify SDK as follows:

$ pip install amplify[extra]

Qulacs Client Class

Please refer to qulacs client reference for details.

Name

Qulacs Classes

Client Class

QulacsClient

Execution parameter class

QulacsClientParameters

Execution result class

QulacsClientResult

Execution time class

QulacsClientResultTiming

Attributes of Qulacs Client

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the QAOA execution parameters QulacsClientParameters

version

Get the version string of the ampllify.qaoa library.

Example of QulacsClient

QulacsClient

from amplify import BinarySymbolGenerator, Solver
from amplify.client import QulacsClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = QulacsClient()

# Settings of QAOA parameters
client.parameters.reps = 10     # Depth of the circuit
client.parameters.shots = 1024  # Number of samples
client.parameters.optimizer = "COBYLA" # Classical optimization algorithm for tuning phase

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}, frequency = {s.frequency}" for s in result]
['energy = -1.0, q = [1. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 0. 1.], frequency = 0', 'energy = 0.0, q = [0. 1. 1.], frequency = 30', 'energy = 0.0, q = [1. 0. 0.], frequency = 0', 'energy = 1.0, q = [0. 0. 0.], frequency = 2', 'energy = 1.0, q = [0. 1. 0.], frequency = 988', 'energy = 1.0, q = [1. 1. 1.], frequency = 0', 'energy = 2.0, q = [1. 1. 0.], frequency = 2']

NEC

NEC Client Class

Please refer to the user manual of the NEC Vector Annealing Service for more information.

Name

NEC Vector Annealing Service

Client class

NECClient

Execution parameter class

NECClientParameters

Execution result class

NECClientResult

Execution time class

NECClientResultTiming

Physical graph

Fully connected coupling

Number of physical bits

300000

Number of logical bits (Fully connected coupling)

300000

Attributes of NEC Client Class

Name

Description

num_bits

Get the maximum number of executable variables.

parameters

Get the execution parameters NECClientParameters.

version

Get the version string of the NEC Vector Annealing Service.

proxy

Get or set the proxy server address.

token

Get or set the API token.

set_onehot

Specifies whether to set the onhot constraint parameter of VA. Defaults to False.

set_andzero

Specifies whether to set the andzero constraint parameter of VA. Defaults to False.

set_orone

Specifies whether to set the orone constraint parameter of VA. Defaults to False.

set_maxone

Specifies whether to set the maxone constraint parameter of VA. Defaults to False.

set_minmaxone

Specifies whether to set the minmaxone constraint parameter of VA. Defaults to False.

write_request_data

Get or set the filepath where to save the request data. Defaults to an empty string and the request data will not be saved.

write_response_data

Get or set the filepath where to save the response data. Defaults to an empty string and the response data will not be saved.

Example of NEC Client

from amplify import BinarySymbolGenerator, Solver
from amplify.client import NECClient

gen = BinarySymbolGenerator()
q = gen.array(3)
f = 2 * q[0] * q[1] - q[0] - q[2] + 1

client = NECClient()
client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.parameters.num_sweeps = 500

solver = Solver(client)
result = solver.solve(f)
>>> f
2 q_0 q_1 - q_0 - q_2 + 1
>>> [f"energy = {s.energy}, q = {q.decode(s.values)}" for s in result]
['energy = -1.0, q = [1. 0. 1.]']

Physical Model Solver

It is recommended to use a client class as the driver of the solver class for typical usage, but the client class can also be used as a solver for the physical model.

Note

This function is intended for direct operation of each machine or for debugging purposes.

All clients have solve() method. The followings are possible inputs. For matrix object input, the second argument corresponds to the constant term.

Possible input polynomials must be quadratic, and variable indices and interactions must match the specifications of each machine. The model needs to be a physical model, and the interactions between variables need to be consistent with the graph based on the hardware specifications. Depending on the graph, there may be restrictions on the interactions between variables.

Note

Please refer to D-Wave System Documentation D-Wave machine’s QPU topology.

Note

Although Hitachi CMOS annealing machine is specified by two-dimensional indices, Amplify SDK uses one-dimensional indices. Regarding to the coordinates of the King’s graph \(x\), \(y\), note that one-dimensional variable index \(i = L x + y\) is given. Here, \(L = 512\) represents the length of one side of the King’s graph.

solve() method returns ClientResult class object, which is specific to the client in use.

ClientResult class has the following common attributes. optional is provided only for some clients.

  • execution_parameters (optional) : Get the execution parameters.

  • timing : Get the execution time object.

  • solutions : Get the list of the execution results. Each element has the following attributes:

    • energy : Get the energy value (evaluated value of physical model).

    • values : Get the list of the values of physical variables.

    • frequency : Get the number of identical solutions.