dimod.reference.composites.structure.StructureComposite.sample#

StructureComposite.sample(bqm, **sample_kwargs)[source]#

Sample from the binary quadratic model.

Parameters:

bqm (BinaryQuadraticModel) – Binary quadratic model to be sampled from.

Returns:

SampleSet

Examples

This example submits an Ising problem to a composed sampler that uses the dimod ExactSolver only on problems structured for a K2 fully connected graph.

>>> nodes = [0, 1]
>>> edges = [(0, 1)]
>>> composed_sampler = dimod.StructureComposite(dimod.ExactSolver(),
...                          nodes, edges)
>>> response = composed_sampler.sample_ising({0: 1, 1: 1}, {})
>>> set(response.first.sample.values())
{-1}