Simulated Annealing Sampler#


dwave-neal is deprecated since dwave-ocean-sdk 6.1.0 in favor of dwave-samplers and will be removed in dwave-ocean-sdk 8.0.0.

To migrate, use

from dwave.samplers import SimulatedAnnealingSampler

rather than

from neal import SimulatedAnnealingSampler


class SimulatedAnnealingSampler[source]#

Simulated annealing sampler for binary quadratic models.

Simulated annealing can be used for heuristic optimization or approximate Boltzmann sampling. This implementation approaches the equilibrium distribution by performing updates at a sequence of decreasing temperatures, terminating at the target \(\beta\).[1] By default each spin is updated once in a fixed order per point per \(\beta\) according to a Metropolis-Hastings update. When \(\beta\) is large the target distribution concentrates, at equilibrium, over ground states of the model. Samples are guaranteed to match the equilibrium for long, smooth \(\beta\) schedules.

For more information, see Kirkpatrick, S.; Gelatt Jr, C. D.; Vecchi, M. P. (1983). “Optimization by Simulated Annealing”. Science. 220 (4598): 671–680

Also aliased as Neal.


This example solves a simple Ising problem.

>>> from dwave.samplers import SimulatedAnnealingSampler
>>> sampler = SimulatedAnnealingSampler()
>>> h = {'a': 0.0, 'b': 0.0, 'c': 0.0}
>>> J = {('a', 'b'): 1.0, ('b', 'c'): 1.0, ('a', 'c'): 1.0}
>>> sampleset = sampler.sample_ising(h, J, num_reads=10)
>>> print(

Sampler Properties#


A dict containing any additional information about the sampler.


Keyword arguments accepted by the sampling methods.


sample(bqm[, beta_range, num_reads, ...])

Sample from a binary quadratic model.

sample_ising(h, J, **parameters)

Sample from an Ising model using the implemented sample method.

sample_qubo(Q, **parameters)

Sample from a QUBO using the implemented sample method.



alias of SimulatedAnnealingSampler