dwave.preprocessing.composites.SpinReversalTransformComposite.sample#
- SpinReversalTransformComposite.sample(bqm: BinaryQuadraticModel, *, num_spin_reversal_transforms: int = 1, **kwargs)[source]#
Sample from the binary quadratic model.
- Parameters:
bqm – Binary quadratic model to be sampled from.
num_spin_reversal_transforms – Number of spin reversal transform runs. A value of
0
will not transform the problem. If you specify a nonzero value, each spin reversal transform will result in an independent run of the child sampler.
- Returns:
A sample set. Note that for a sampler that returns
num_reads
samples, the sample set will containnum_reads*num_spin_reversal_transforms
samples.
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