dwave.cloud.computation.Future.result#

Future.result()[source]#

Results for a submitted job.

Retrives raw result data in a Future object that the solver submitted to a remote resource. First calls to access this data are blocking.

Returns:

Results of the submitted job. Should be considered read-only.

Return type:

dict

Note

Helper properties on Future object are preferred to reading raw results, as they abstract away the differences in response between some solvers like. Available methods are: samples(), energies(), variables(), timing(), problem_type(), sampleset() (only if dimod package is installed).

Warning

The dictionary returned by result() depends on the solver used. Starting with version 0.7.0 we will not try to standardize them anymore, on client side. For QPU solvers, please replace ‘samples’ with ‘solutions’ and ‘occurrences’ with ‘num_occurrences’. Better yet, use Future.samples() and Future.num_occurrences() instead.

Changed in version 0.8.0: Instead of adding copies of solutions and num_occurrences keys (as samples and occurrences), we alias them using aliasdict. Values are available under alias keys, but the keys themselves are not stored or visible.

Removed in version 0.12.0: Alias keys samples and occurrences in the result dict, deprecated in 0.8.0, are removed in 0.12.0. We’ll try to keep the result dict as close to raw data returned by SAPI as possible. Postprocessed data is available via Future properties.

Examples

This example creates a solver using the local system’s default D-Wave Cloud Client configuration file, submits a simple QUBO problem (representing a Boolean NOT gate by a penalty function) to a remote D-Wave resource for 5 samples, and prints part of the returned result (the relevant samples).

>>> from dwave.cloud import Client
>>> with Client.from_config() as client:  
...     solver = client.get_solver()
...     u, v = next(iter(solver.edges))
...     Q = {(u, u): -1, (u, v): 0, (v, u): 2, (v, v): -1}
...     computation = solver.sample_qubo(Q, num_reads=5)
...     for i in range(5):
...         result = computation.result()
...         print(result['solutions'][i][u], result['solutions'][i][v])
...
...
(0, 1)
(1, 0)
(1, 0)
(0, 1)
(0, 1)