amplify.client.ocean.DWaveSamplerClient

class DWaveSamplerClient

A client class for using DWaveSampler class in D-Wave system. For more information, see DWaveSampler.

__init__(self: amplify.client.ocean.DWaveSamplerClient, token: str = '', solver: str = '', url: str = '', proxy: str = '')None

Methods

__init__(self, token, solver, url, proxy)

solve(*args, **kwargs)

Overloaded function.

Attributes

num_bits

N/A

parameters

Parameters of DWaveSamplerClient.

proxy

Sets or gets the address of proxy server.

solver

Set to one of the 'Advantage_system1.1', 'DW_2000Q_6', and 'DW_2000Q_VFYC_6' solvers.

solver_names

Provides a list of the available solver names.

token

Authentication token for a D-Wave account.

url

The end point url for D-Wave Sampler.

version

Version of D-Wave Sampler client of Amplify SDK.

property num_bits

N/A

property parameters

Parameters of DWaveSamplerClient. See DWaveSamplerClientQuantumSolverParametersOcean for all available parameters.

Type

DWaveSamplerClientQuantumSolverParametersOcean

property proxy

Sets or gets the address of proxy server.

Type

str

solve(*args, **kwargs)

Overloaded function.

  1. solve(self: amplify.client.ocean.DWaveSamplerClient, arg0: amplify.BinaryPoly) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  2. solve(self: amplify.client.ocean.DWaveSamplerClient, arg0: amplify.BinaryIntPoly) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  3. solve(self: amplify.client.ocean.DWaveSamplerClient, arg0: amplify.IsingPoly) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  4. solve(self: amplify.client.ocean.DWaveSamplerClient, arg0: amplify.IsingIntPoly) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  5. solve(self: amplify.client.ocean.DWaveSamplerClient, matrix: amplify.BinaryMatrix, constant: float = 0.0) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  6. solve(self: amplify.client.ocean.DWaveSamplerClient, matrix: amplify.BinaryIntMatrix, constant: int = 0) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  7. solve(self: amplify.client.ocean.DWaveSamplerClient, matrix: amplify.IsingMatrix, constant: float = 0.0) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

  8. solve(self: amplify.client.ocean.DWaveSamplerClient, matrix: amplify.IsingIntMatrix, constant: int = 0) -> qubo::client::ClientResult<qubo::client::DWaveSamplerClient, decltype(nullptr)>

Solves a given polynomial or matrix model.

Overloads

  1. solve(polynomial)

  2. solve(matrix, constant)

Parameters
Returns

Result class of D-Wave Sampler clinet.

Return type

DWaveSamplerClientResult

Example

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

# Available physical bits need to be used
# Here, the bits labeled by 38 and 39 are used
gen = BinarySymbolGenerator()
q = gen.array(40)
f = 2 * q[38] * q[39] - q[38] - q[39] + 1

client = DWaveSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.solver = "Advantage_system1.1"
client.parameters.num_reads = 100

result = client.solve(f)
>>> f
2 q_38 q_39 - q_38 - q_39 + 1
>>> [f"energy = {s.energy}, q_38 = {s.values[38]}, q_39 = {s.values[39]}" for s in result]
['energy = 0.0, q_38 = 0, q_39 = 1',
 'energy = 0.0, q_38 = 1, q_39 = 0']

Note

The graph types available for D-Wave machine are the Pegasus or Chimera topology. The problems that can be handled by solve method are limited to the ones that are consistent with the Pegasus or Chimera graph. For example, the following problem leads to an error.

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

client = DWaveSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client.solver = "DW_2000Q_VFYC_6" # Chimera graph

gen = BinarySymbolGenerator()
q = gen.array(2)
f = 2 * q[0] * q[1] # invalid problem (no connection between 0 and 1 on the Chimera graph)

# result = client.solve(f) # Error: Problem graph incompatible with solver
property solver

Set to one of the 'Advantage_system1.1', 'DW_2000Q_6', and 'DW_2000Q_VFYC_6' solvers.

Type

str

property solver_names

Provides a list of the available solver names.

Type

list

property token

Authentication token for a D-Wave account.

Type

str

property url

The end point url for D-Wave Sampler.

Type

str

property version

Version of D-Wave Sampler client of Amplify SDK.

Type

str