EmbeddingComposite

Class

A dimod composite that maps unstructured problems to a structured sampler.

A structured sampler can only solve problems that map to a specific graph: the D-Wave system’s architecture is represented by a Chimera graph.

The EmbeddingComposite uses the minorminer library to map unstructured problems to a structured sampler such as a D-Wave system.

class EmbeddingComposite(child_sampler)[source]

Composite to map unstructured problems to a structured sampler.

Inherits from dimod.ComposedSampler.

Enables quick incorporation of the D-Wave system as a sampler in the D-Wave Ocean software stack by handling the minor-embedding of the problem into the D-Wave system’s Chimera graph.

Parameters:sampler (dimod.Sampler) – Structured dimod sampler.

Examples

This example uses EmbeddingComposite to instantiate a composed sampler that submits a simple Ising problem to a D-Wave solver selected by the user’s default D-Wave Cloud Client configuration file. The composed sampler handles minor-embedding of the problem’s two generic variables, a and b, to physical qubits on the solver.

>>> from dwave.system.samplers import DWaveSampler
>>> from dwave.system.composites import EmbeddingComposite
>>> sampler = EmbeddingComposite(DWaveSampler())
>>> h = {'a': -1., 'b': 2}
>>> J = {('a', 'b'): 1.5}
>>> response = sampler.sample_ising(h, J)
>>> for sample in response.samples():    
...     print(sample)
...
{'a': 1, 'b': -1}

Sampler Properties

EmbeddingComposite.properties dict – Properties in the form of a dict.
EmbeddingComposite.parameters dict[str, list] – Parameters in the form of a dict.

Composite Properties

EmbeddingComposite.children list – Children property inherited from dimod.Composite class.
EmbeddingComposite.child First child in children.

Methods

EmbeddingComposite.sample(bqm[, chain_strength]) Sample from the provided binary quadratic model.
EmbeddingComposite.sample_ising(h, J, …) Samples from an Ising model using an implemented sample method.
EmbeddingComposite.sample_qubo(Q, **parameters) Samples from a QUBO using an implemented sample method.