dwave.cloud.solver.StructuredSolver.check_problem

StructuredSolver.check_problem(linear, quadratic)[source]

Test if an Ising model matches the graph provided by the solver.

Parameters:
  • linear (list/dict) – Linear terms of the model (h).
  • quadratic (dict[(int, int), float]) – Quadratic terms of the model (J).
Returns:

boolean

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, and tests a simple Ising model for two target embeddings (that is, representations of the model’s graph by coupled qubits on the QPU’s sparsely connected graph), where only the second is valid.

>>> from dwave.cloud import Client
>>> print((0, 1) in solver.edges)   # doctest: +SKIP
False
>>> print((0, 4) in solver.edges)   # doctest: +SKIP
True
>>> with Client.from_config() as client:  # doctest: +SKIP
...     solver = client.get_solver()
...     print(solver.check_problem({0: -1, 1: 1},{(0, 1):0.5}))
...     print(solver.check_problem({0: -1, 4: 1},{(0, 4):0.5}))
...
False
True