dwave.system.composites.ReverseBatchStatesComposite.sample

ReverseBatchStatesComposite.sample(bqm, **parameters)[source]

Sample the binary quadratic model using reverse annealing from multiple initial states.

Parameters:
  • bqm (dimod.BinaryQuadraticModel) – Binary quadratic model to be sampled from.
  • **parameters – Parameters for the sampling method, specified by the child sampler.
Returns:

dimod.SampleSet that has initial_state field.

Examples

This example runs 100 reverse anneals each from two initial states on a problem constructed by setting random \(\pm 1\) values on a clique (complete graph) of 15 nodes, minor-embedded on a D-Wave system using the DWaveCliqueSampler sampler.

>>> import dimod
>>> from dwave.system import DWaveCliqueSampler, ReverseBatchStatesComposite
...
>>> sampler = DWaveCliqueSampler()       # doctest: +SKIP
>>> sampler_reverse = ReverseBatchStatesComposite(sampler)   # doctest: +SKIP
>>> schedule = [[0.0, 1.0], [10.0, 0.5], [20, 1.0]]
...
>>> bqm = dimod.generators.ran_r(1, 15)
>>> init_samples = [{i: -1 for i in range(15)}, {i: 1 for i in range(15)}]
>>> sampleset = sampler_reverse.sample(bqm,
...                                    anneal_schedule=schedule,
...                                    initial_states=init_samples,
...                                    num_reads=100,
...                                    reinitialize_state=True)  # doctest: +SKIP