dwave.cloud.solver.StructuredSolver.sample_ising

StructuredSolver.sample_ising(linear, quadratic, **params)[source]

Sample from the specified Ising model.

Parameters:
  • linear (list/dict) – Linear terms of the model (h).
  • quadratic (dict[(int, int), float]) – Quadratic terms of the model (J), stored in a dict. With keys that are 2-tuples of variables and values are quadratic biases associated with the pair of variables (the interaction).
  • **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 simple Ising problem (opposite linear biases on two coupled qubits), and samples 5 times.

>>> from dwave.cloud import Client
>>> with Client.from_config() as client:
...     solver = client.get_solver()
...     u, v = next(iter(solver.edges))
...     computation = solver.sample_ising({u: -1, v: 1}, {}, num_reads=5)   # doctest: +SKIP
...     for i in range(5):
...         print(computation.samples[i][u], computation.samples[i][v])
...
...
(1, -1)
(1, -1)
(1, -1)
(1, -1)
(1, -1)