Computation#
Computation manages the interactions between your code and a solver, which manages interactions between the remote resource and your submitted problems.
Your solver instantiates a Future
object for its calls, via D-Wave Sampler API
(SAPI) servers, to the remote resource.
You can interact through the Future
object with pending (running) or completed
computation—sampling on a QPU or software solver—executed remotely, monitoring problem status,
waiting for and retrieving results, cancelling enqueued jobs, etc.
Some Future
methods are blocking.
Class#
- class Future(solver, id_, return_matrix=False)[source]#
Class for interacting with jobs submitted to SAPI.
Solver
usesFuture
to construct objects for pending SAPI calls that can wait for requests to complete and parse returned messages.Objects are blocked for the duration of any data accessed on the remote resource.
Warning
Future
objects are not intended to be directly created. Problem submittal is initiated by one of the solvers insolver
module and executed by one of the clients.- Parameters:
solver (
Solver
) – Solver responsible for thisFuture
object.id (str, optional, default=None) – Identification for a query submitted by a solver to SAPI. May be None following submission until an identification number is set.
return_matrix (bool, optional, default=False) – Return values for this
Future
object are NumPy matrices.
Examples
This example creates a solver using the local system’s default D-Wave Cloud Client configuration file, submits a simple QUBO problem to a remote D-Wave resource for 100 samples, and checks a couple of times whether the sampling is completed.
>>> from dwave.cloud import Client >>> client = Client.from_config() >>> 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=100) >>> computation.done() False >>> computation.id '1cefeb6d-ebd5-4592-87c0-4cc43ec03e27' >>> computation.done() True >>> client.close()
Methods#
Results for a submitted job. |
|
|
Yield Futures objects as they complete. |
|
Wait for the solver to receive a response for a submitted problem. |
|
Blocking id getter. |
Blocking sampleset getter. |
|
|
Wait for multiple |
Check whether the solver received a response for a submitted problem. |
|
Try to cancel the problem corresponding to this result. |
Properties#
State buffer for the submitted job. |
|
List of active variables in response/answer. |
|
Energy buffer for the submitted job. |
|
Number of sample occurrences buffer for the submitted job. |
|
Return |
|
The id the server will use to identify this problem, None until the id is actually known |
|
Submitted problem type for this computation, as returned by the solver API. |
|
Timing information about a solver operation. |