dwave.cloud.computation.Future.occurrences

Future.occurrences

Occurrences buffer for the submitted job.

First calls to access data of a Future object are blocking; subsequent access to this property is non-blocking.

Returns:Occurrences. When returned results are ordered in a histogram, occurrences indicates the number of times a particular solution recurred.
Return type:list or NumPy matrix of doubles

Examples

This example creates a solver using the local system’s default D-Wave Cloud Client configuration file, submits a simple Ising problem with several ground states to a remote D-Wave resource for 20 samples, and prints the returned results, which are ordered as a histogram. The problem’s ground states tend to recur frequently, and so those solutions have occurrences greater than 1.

>>> from dwave.cloud import Client
>>> with Client.from_config() as client:  # doctest: +SKIP
...     solver = client.get_solver()
...     quad = {(16, 20): -1, (17, 20): 1, (16, 21): 1, (17, 21): 1}
...     computation = solver.sample_ising({}, quad, num_reads=500, answer_mode='histogram')
...     for i in range(len(computation.occurrences)):
...         print(computation.samples[i][16], computation.samples[i][17],
...               computation.samples[i][20], computation.samples[i][21],
                  ' --> ', computation.energies[i], computation.occurrences[i])
...
(-1, 1, -1, -1, ' --> ', -2.0, 41)
(-1, -1, -1, 1, ' --> ', -2.0, 53)
(1, -1, 1, 1, ' --> ', -2.0, 55)
(1, 1, -1, -1, ' --> ', -2.0, 52)
(1, 1, 1, -1, ' --> ', -2.0, 60)
(1, -1, 1, -1, ' --> ', -2.0, 196)
(-1, 1, -1, 1, ' --> ', -2.0, 15)
(-1, -1, 1, 1, ' --> ', -2.0, 28)