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

Class StructuredSolver

dwave/cloud/solver.py:1042–1772  ·  view source on GitHub ↗

Class for D-Wave structured solvers. This class provides :term:`Ising`, :term:`QUBO` and :term:`BQM` sampling methods and encapsulates the solver description returned from the D-Wave cloud API. Args: client (:class:`~dwave.cloud.client.Client`): Client that mana

Source from the content-addressed store, hash-verified

1040
1041
1042class StructuredSolver(BaseSolver):
1043 """Class for D-Wave structured solvers.
1044
1045 This class provides :term:`Ising`, :term:`QUBO` and :term:`BQM` sampling
1046 methods and encapsulates the solver description returned from the D-Wave
1047 cloud API.
1048
1049 Args:
1050 client (:class:`~dwave.cloud.client.Client`):
1051 Client that manages access to this solver.
1052
1053 data (`dict`):
1054 Data from the server describing this solver.
1055 """
1056
1057 _handled_problem_types = {"ising", "qubo"}
1058 _handled_encoding_formats = {"qp"}
1059
1060 def __init__(self, *args, **kwargs):
1061 super().__init__(*args, **kwargs)
1062
1063 # The exact sequence of nodes/edges is used in encoding problems and must be preserved
1064 try:
1065 self._encoding_qubits = self.properties['qubits']
1066 except KeyError:
1067 raise SolverPropertyMissingError("Missing solver property: 'properties.qubits'")
1068
1069 if 'couplers' not in self.properties:
1070 raise SolverPropertyMissingError("Missing solver property: 'properties.couplers'")
1071
1072 # Create a set of default parameters for the queries
1073 self._params = {}
1074
1075 # Add derived properties specific for this solver class
1076 self.derived_properties.update({'lower_noise', 'num_active_qubits', 'version', 'graph_id'})
1077
1078 def __repr__(self):
1079 return f"{type(self).__name__}(name={self.name!r}, graph_id={self.graph_id!r})"
1080
1081 # Derived properties
1082
1083 @property
1084 def version(self) -> dict:
1085 """QPU solver version dict (contains at least ``graph_id``). Returns
1086 an empty dict for non-QPU solvers."""
1087 return v.model_dump() if (v := self.identity.version) else {}
1088
1089 @property
1090 def graph_id(self) -> Optional[str]:
1091 """QPU solver working graph id. Returns ``None`` for non-QPU solvers."""
1092 return self.version.get('graph_id')
1093
1094 @property
1095 def num_active_qubits(self):
1096 "The number of active (encoding) qubits."
1097 return len(self.nodes)
1098
1099 @property

Callers 11

get_structured_solverFunction · 0.90
setUpClassMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
__init__Method · 0.90
time_solver_initMethod · 0.90
setupMethod · 0.90

Calls

no outgoing calls

Tested by 7

get_structured_solverFunction · 0.72
setUpClassMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72
setUpMethod · 0.72