dwave.cloud.solver.StructuredSolver.sample_qubo

StructuredSolver.sample_qubo(qubo, offset=0, **params)[source]

Sample from the specified QUBO.

Parameters:
  • qubo (dict[(int, int), float]) – Coefficients of a quadratic unconstrained binary optimization (QUBO) problem. Should be a dict of the form {(u, v): bias, …} where u, v, are binary-valued variables and bias is their associated coefficient.
  • offset (optional, default=0) – Constant offset applied to the model.
  • **params – Parameters for the sampling method, solver-specific.
Returns:

Future

Examples

This example creates a client using the local system’s default D-Wave Cloud Client configuration file, which is configured to access a D-Wave 2000Q QPU, submits a QUBO problem (a Boolean NOT gate represented by a penalty model), and samples 5 times.

>>> 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):
...         print(computation.samples[i][u], computation.samples[i][v])
...
...
(0, 1)
(1, 0)
(1, 0)
(0, 1)
(1, 0)