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)

Solves a given polynomial or matrix model.

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_system4.1', 'Advantage_system6.3' and 'Advantage2_prototype1.1' 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

Get the solver name with its version string.

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)

Solves a given polynomial or matrix model.

Overloads:

  • solve(*polynomial*)
  • 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_system4.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 = "Advantage_system6.3" # 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_system4.1', 'Advantage_system6.3' and 'Advantage2_prototype1.1' 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

Get the solver name with its version string. The token must be set before calling this property.

Type:

str