dwave.system.samplers.DWaveSampler.sample

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

Sample from the specified Ising 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 warnings. The default behaviour is defined by warnings_default, which itself defaults to IGNORE
  • **kwargs – Optional keyword arguments for the sampling method, specified per solver in DWaveSampler.parameters. D-Wave System Documentation’s solver guide describes the parameters and properties supported on the D-Wave system.
Returns:

A dimod SampleSet object. In it this sampler also provides timing information in the info field as described in the D-Wave System Documentation’s timing guide.

Return type:

dimod.SampleSet

Examples

This example submits a two-variable Ising problem mapped directly to qubits 0 and 1 on a D-Wave system. Given sufficient reads (here 100), the quantum computer should return the best solution, \({1, -1}\) on qubits 0 and 1, respectively, as its first sample (samples are ordered from lowest energy).

>>> from dwave.system import DWaveSampler
>>> sampler = DWaveSampler(solver={'qubits__issuperset': {0, 1}})
>>> sampleset = sampler.sample_ising({0: -1, 1: 1}, {}, num_reads=100)
>>> sampleset.first.sample[0] == 1 and sampleset.first.sample[1] == -1
True

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