dwave.system.samplers.DWaveSampler.sample#

DWaveSampler.sample(bqm, warnings=None, **kwargs)[source]#

Sample from the specified binary quadratic model.

Parameters:
  • bqm (BinaryQuadraticModel) – The binary quadratic model. Must match nodelist and edgelist.

  • warnings (WarningAction, optional) – Defines what warning action to take, if any (see the Warnings section). The default behavior is to ignore warnings.

  • **kwargs – Optional keyword arguments for the sampling method, specified per solver in parameters. D-Wave System Documentation’s solver guide describes the parameters and properties supported on the D-Wave system.

Returns:

Sample set constructed from a (non-blocking) Future-like object. In it this sampler also provides timing information in the info field as described in the D-Wave System Documentation’s SAPI Timing Fields.

Return type:

SampleSet

Examples

This example submits a two-variable Ising problem mapped directly to two adjacent qubits on a D-Wave system. qubit_a is the first qubit in the QPU’s indexed list of qubits and qubit_b is one of the qubits coupled to it. Given sufficient reads (here 100), the quantum computer should return the best solution, \({1, -1}\) on qubit_a and qubit_b, respectively, as its first sample (samples are ordered from lowest energy).

>>> from dwave.system import DWaveSampler
...
>>> sampler = DWaveSampler()
...
>>> qubit_a = sampler.nodelist[0]
>>> qubit_b = next(iter(sampler.adjacency[qubit_a]))
>>> sampleset = sampler.sample_ising({qubit_a: -1, qubit_b: 1},
...                                  {},
...                                  num_reads=100)
>>> sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1
True

See Ocean Glossary for explanations of technical terms in descriptions of Ocean tools.