dwave.preprocessing.composites.SpinReversalTransformComposite.sample

SpinReversalTransformComposite.sample(bqm, *, num_spin_reversal_transforms=2, **kwargs)[source]

Sample from the binary quadratic model.

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

  • num_spin_reversal_transforms (integer, optional, default=2) – Number of spin reversal transform runs.

Returns

SampleSet

Examples

This example runs 100 spin reversals applied to one variable of a QUBO problem.

>>> from dimod import ExactSolver
>>> from dwave.preprocessing.composites import SpinReversalTransformComposite
>>> base_sampler = ExactSolver()
>>> composed_sampler = SpinReversalTransformComposite(base_sampler)
...
>>> Q = {('a', 'a'): -1, ('b', 'b'): -1, ('a', 'b'): 2}
>>> response = composed_sampler.sample_qubo(Q,
...               num_spin_reversal_transforms=100)
>>> len(response)
400