dwave.system.composites.EmbeddingComposite.sample

EmbeddingComposite.sample(bqm, chain_strength=1.0, **parameters)[source]

Sample from the provided binary quadratic model.

Parameters:
  • bqm (dimod.BinaryQuadraticModel) – Binary quadratic model to be sampled from.
  • chain_strength (float, optional, default=1.0) – Magnitude of the quadratic bias (in SPIN-space) applied between variables to create chains. Note that the energy penalty of chain breaks is 2 * chain_strength.
  • **parameters – Parameters for the sampling method, specified by the child sampler.
Returns:

dimod.Response

Examples

This example uses EmbeddingComposite to instantiate a composed sampler that submits an unstructured Ising problem to a D-Wave solver, selected by the user’s default D-Wave Cloud Client configuration_ file, while minor-embedding the problem’s variables to physical qubits on the solver.

>>> from dwave.system.samplers import DWaveSampler
>>> from dwave.system.composites import EmbeddingComposite
>>> import dimod
>>> sampler = EmbeddingComposite(DWaveSampler())
>>> h = {1: 1, 2: 2, 3: 3, 4: 4}
>>> J = {(1, 2): 12, (1, 3): 13, (1, 4): 14,
...      (2, 3): 23, (2, 4): 24,
...      (3, 4): 34}
>>> bqm = dimod.BinaryQuadraticModel.from_ising(h, J)
>>> response = sampler.sample(bqm)
>>> for sample in response.samples():    
...     print(sample)
...
{1: -1, 2: 1, 3: 1, 4: -1}