dimod.reference.composites.spin_transform.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.

>>> base_sampler = dimod.ExactSolver()
>>> composed_sampler = dimod.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