dimod.reference.samplers.SimulatedAnnealingSampler.sample¶
-
SimulatedAnnealingSampler.sample(bqm, beta_range=None, num_reads=10, num_sweeps=1000)[source]¶ Sample from low-energy spin states using simulated annealing.
Parameters: - bqm (
BinaryQuadraticModel) – Binary quadratic model to be sampled from. - beta_range (tuple, optional) – Beginning and end of the beta schedule (beta is the inverse temperature) as a 2-tuple. The schedule is applied linearly in beta. Default is chosen based on the total bias associated with each node.
- num_reads (int, optional) – Number of reads. Each sample is the result of a single run of the simulated annealing algorithm.
- num_sweeps (int, optional) – Number of sweeps or steps. Default is 1000.
Returns: A dimod
Responseobject.Return type: Note
This is a reference implementation, not optimized for speed and therefore not an appropriate sampler for benchmarking.
Examples
This example provides samples for a two-variable QUBO model.
>>> import dimod >>> sampler = dimod.SimulatedAnnealingSampler() >>> Q = {(0, 0): -1, (1, 1): -1, (0, 1): 2} >>> bqm = dimod.BinaryQuadraticModel.from_qubo(Q, offset = 0.0) >>> response = sampler.sample(bqm, num_reads=2) >>> response.data_vectors['energy'] array([-1., -1.])
- bqm (