amplify.client.ocean.LeapHybridSamplerClient

class LeapHybridSamplerClient

A class for using D-Wave Leap Hybrid Solver client.

__init__(self: amplify.client.ocean.LeapHybridSamplerClient, 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

Maximux number of problem variables accepted by Leap Hybrid Solver client.

parameters

Parameters of Leap Hybrid Solver client.

proxy

Sets or gets the address of proxy server.

solver

Set or get the name of solver to be used.

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

Maximux number of problem variables accepted by Leap Hybrid Solver client. For more information, see maximum_number_of_variables.

Type:

int

property parameters

Parameters of Leap Hybrid Solver client. See LeapHybridSamplerClientLeapHybridSolverParameters for all available parameters.

Type:

LeapHybridSamplerClientLeapHybridSolverParameters

property proxy

Sets or gets the address of proxy server.

Type:

str

solve(*args, **kwargs)

Solves a given polynomial or matrix model.

Overloads:

  1. solve(polynomial)

  2. solve(matrix, constant)

パラメータ:
戻り値:

Client's result class whose type depends on the input client.

戻り値の型:

LeapHybridSamplerClientResult

Example

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

client = LeapHybridSamplerClient()
client.token = "XXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
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

result = client.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.]']
property solver

Set or get the name of solver to be used. It should be set to "hybrid_binary_quadratic_model_version2" or "hybrid_binary_quadratic_model_version2p" to use Leap Hybrid Solver client.

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