dwave.cloud.computation.Future.result¶
-
Future.result()¶ 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: dict 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(),occurrences(),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.occurrences()instead.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: # doctest: +SKIP ... 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)