StructuredSolver.sample_ising(linear, quadratic, offset=0, label=None, **params)[source]#

Sample from the specified Ising model.

  • linear (dict/list) – Linear biases of the Ising problem. If a dict, should be of the form {v: bias, …} where v is a spin-valued variable and bias is its associated bias. If a list, it is treated as a list of biases where the indices are the variable labels.

  • 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).

  • offset (float, optional, default=0) – Constant offset applied to the model.

  • label (str, optional) – Problem label you can optionally tag submissions with for ease of identification.

  • **params – Parameters for the sampling method, solver-specific.




This example creates a client using the local system’s default D-Wave Cloud Client configuration file, which is configured to access an Advantage 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)   
...     for i in range(5):
...         print(computation.samples[i][u], computation.samples[i][v])
(1, -1)
(1, -1)
(1, -1)
(1, -1)
(1, -1)