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
N/A
Parameters of
DWaveSamplerClient
.Sets or gets the address of proxy server.
Set to one of the
'Advantage_system4.1'
,'Advantage_system6.3'
and'Advantage2_prototype1.1'
solvers.Provides a list of the available solver names.
Authentication token for a D-Wave account.
The end point url for D-Wave Sampler.
Get the solver name with its version string.
- property num_bits
N/A
- property parameters
Parameters of
DWaveSamplerClient
. SeeDWaveSamplerClientQuantumSolverParametersOcean
for all available parameters.
- solve(*args, **kwargs)
Solves a given polynomial or matrix model.
Overloads:
- solve(*polynomial*)
- solve(*matrix*, *constant*)
- パラメータ:
polynomial (
BinaryPoly
,BinaryIntPoly
,IsingPoly
orIsingIntPoly
) --Input polynomial model
matrix (
BinaryMatrix
,BinaryIntMatrix
,IsingMatrix
orIsingIntMatrix
) --Input matrix model
constant (
int
orfloat
, optional) --A constant value to be added to the above matrix. The type is set in accordance with the coefficients of the matrix.
- 戻り値:
Result class of D-Wave Sampler clinet.
- 戻り値の型:
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']
注釈
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: