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
Maximux number of problem variables accepted by Leap Hybrid Solver client.
Parameters of Leap Hybrid Solver client.
Sets or gets the address of proxy server.
Set or get the name of solver to be used.
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
Maximux number of problem variables accepted by Leap Hybrid Solver client. For more information, see maximum_number_of_variables.
- Type:
- property parameters
Parameters of Leap Hybrid Solver client. See
LeapHybridSamplerClientLeapHybridSolverParameters
for all available parameters.
- solve(*args, **kwargs)
Solves a given polynomial or matrix model.
Overloads:
solve(polynomial)
solve(matrix, constant)
- Parameters:
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.
- Returns:
Client’s result class whose type depends on the input client.
- Return type:
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.