dwave.cloud.computation.Future.result#
- Future.result()[source]#
Results for a submitted job.
Retrives raw result data in a
Futureobject 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:
Note
Helper properties on
Futureobject 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, useFuture.samples()andFuture.num_occurrences()instead.Changed in version 0.8.0: Instead of adding copies of
solutionsandnum_occurrenceskeys (assamplesandoccurrences), we alias them usingaliasdict. Values are available under alias keys, but the keys themselves are not stored or visible.Removed in version 0.12.0: Alias keys
samplesandoccurrencesin 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 viaFutureproperties.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)