MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / check_problem

Method check_problem

dwave/cloud/solver.py:1547–1581  ·  view source on GitHub ↗

Test if an Ising model matches the graph provided by the solver. Args: linear (list/dict): Linear terms of the model (h). quadratic (dict[(int, int), float]): Quadratic terms of the model (J). Returns: bool

(self, linear, quadratic)

Source from the content-addressed store, hash-verified

1545 return parameters
1546
1547 def check_problem(self, linear, quadratic):
1548 """Test if an Ising model matches the graph provided by the solver.
1549
1550 Args:
1551 linear (list/dict):
1552 Linear terms of the model (h).
1553
1554 quadratic (dict[(int, int), float]):
1555 Quadratic terms of the model (J).
1556
1557 Returns:
1558 bool
1559
1560 Examples:
1561 This example creates a client using the local system's default D-Wave
1562 Cloud Client configuration file, which is configured to access an
1563 Advantage QPU, and tests a simple :term:`Ising` model for two target
1564 minor embeddings (that is, representations of the model's graph by
1565 coupled qubits on the QPU's sparsely connected graph), where only
1566 the second is valid.
1567
1568 >>> from dwave.cloud import Client
1569 >>> with Client.from_config() as client: # doctest: +SKIP
1570 ... solver = client.get_solver()
1571 ... print(solver.check_problem({0: -1, 1: 1},{(0, 1):0.5}))
1572 ... print(solver.check_problem({30: -1, 31: 1},{(30, 31):0.5}))
1573 ...
1574 False
1575 True
1576 """
1577 # handle legacy format
1578 if not isinstance(linear, abc.Mapping):
1579 linear = {idx: val for idx, val in enumerate(linear) if val != 0}
1580
1581 return self.nodes.issuperset(linear) and self.edges.issuperset(quadratic)
1582
1583 def estimate_qpu_access_time(self,
1584 num_qubits: int,

Callers 1

_sampleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected