dwave.system.temperatures.maximum_pseudolikelihood_temperature#

maximum_pseudolikelihood_temperature(bqm=None, sampleset=None, site_energy=None, num_bootstrap_samples=0, seed=None, T_guess=None, optimize_method='bisect', T_bracket=(0.001, 1000)) Tuple[float, ndarray][source]#

Returns a sampling-based temperature estimate.

The temperature T parameterizes the Boltzmann distribution as \(P(x) = \exp(-H(x)/T)/Z(T)\), where \(P(x)\) is a probability over a state space, \(H(x)\) is the energy function (BQM) and \(Z(T)\) is a normalization. Given a sample set (\(S\)), a temperature estimate establishes the temperature that is most likely to have produced the sample set. An effective temperature can be derived from a sample set by considering the rate of excitations only. A maximum-pseudo-likelihood (MPL) estimator considers local excitations only, which are sufficient to establish a temperature efficiently (in compute time and number of samples). If the BQM consists of uncoupled variables then the estimator is equivalent to a maximum likelihood estimator.

The effective MPL temperature is defined by the solution T to

\[0 = \sum_i \sum_{s \in S} f_i(s) \exp(f_i(s)/T),\]

where f is the energy lost in flipping spin i against its current assignment (the effective field).

The problem is a convex root solving problem, and is solved with SciPy optimize.

If the distribution is not Boltzmann with respect to the BQM provided, as may be the case for heuristic samplers (such as annealers), the temperature estimate can be interpreted as characterizing only a rate of local excitations. In the case of sample sets obtained from D-Wave annealing quantum computers the temperature can be identified with a physical temperature via a late-anneal freeze-out phenomena.

Parameters:
  • bqm (dimod.BinaryQuadraticModel, optional) – Binary quadratic model describing sample distribution. If bqm and site_energy are both None, then by default 100 samples are drawn using DWaveSampler, with bqm defaulted as described.

  • sampleset (dimod.SampleSet, optional) – A set of samples, assumed to be fairly sampled from a Boltzmann distribution characterized by bqm.

  • site_energy (samples_like, optional) – A Tuple of effective fields and site labels. Derived from the bqm and sampleset if not provided.

  • num_bootstrap_samples (int, optional, default=0) – Number of bootstrap estimators to calculate.

  • seed (int, optional) – Seeds the bootstrap method (if provided) allowing reproducibility of the estimators.

  • T_guess (float, optional) – User approximation to the effective temperature, must be a positive scalar value. Seeding the root-search method can enable faster convergence. By default, T_guess is ignored if it falls outside the range of T_bracket.

  • optimize_method (str,optional,default='bisect') – SciPy method used for optimization. Options are ‘bisect’ and None (the default SciPy optimize method).

  • T_bracket (list or Tuple of 2 floats, optional, default=(0.001,1000)) – If excitations are absent, temperature is defined as zero, otherwise this defines the range of Temperatures over which to attempt a fit when using the ‘bisect’ optimize_method (the default).

Returns:

(T_estimate,T_bootstrap_estimates)

T_estimate: a temperature estimate T_bootstrap_estimates: a numpy array of bootstrap estimators

Return type:

Tuple of float and NumPy array

Examples

Draw samples from a D-Wave Quantum Computer for a large spin-glass problem (random couplers J, zero external field h). Establish a temperature estimate by maximum pseudo-likelihood.

Note that due to the complicated freeze-out properties of hard models, such as large scale spin-glasses, deviation from a classical Boltzmann distribution is anticipated. Nevertheless, the T estimate can always be interpreted as an estimator of local excitations rates. For example T will be 0 if only local minima are returned (even if some of the local minima are not ground states).

>>> import dimod
>>> from dwave.system.temperatures import maximum_pseudolikelihood_temperature
>>> from dwave.system import DWaveSampler
>>> from random import random
>>> sampler = DWaveSampler()
>>> bqm = dimod.BinaryQuadraticModel.from_ising({}, {e : 1-2*random() for e in sampler.edgelist})
>>> sampleset = sampler.sample(bqm, num_reads=100, auto_scale=False)
>>> T,T_bootstrap =  maximum_pseudolikelihood_temperature(bqm,sampleset)
>>> print('Effective temperature ',T)    
Effective temperature  0.24066488780293813