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

Method sample_bqm

dwave/cloud/solver.py:1306–1344  ·  view source on GitHub ↗

Sample from the specified :term:`BQM`. Args: bqm (:class:`~dimod.BinaryQuadraticModel`): A binary quadratic model. label (str, optional): Problem label you can optionally tag submissions with for ease of identification

(self, bqm, label=None, **params)

Source from the content-addressed store, hash-verified

1304 return self._sample('qubo', linear, quadratic, offset, params, label=label)
1305
1306 def sample_bqm(self, bqm, label=None, **params):
1307 """Sample from the specified :term:`BQM`.
1308
1309 Args:
1310 bqm (:class:`~dimod.BinaryQuadraticModel`):
1311 A binary quadratic model.
1312
1313 label (str, optional):
1314 Problem label you can optionally tag submissions with for ease
1315 of identification.
1316
1317 **params:
1318 Parameters for the sampling method, solver-specific.
1319
1320 Returns:
1321 :class:`~dwave.cloud.computation.Future`
1322
1323 Note:
1324 To use this method, dimod package has to be installed.
1325 """
1326 try:
1327 import dimod
1328 except ImportError: # pragma: no cover
1329 raise RuntimeError("Can't sample from 'bqm' without dimod. "
1330 "Re-install the library with 'bqm' support.")
1331
1332 if bqm.vartype is dimod.SPIN:
1333 problem_type = 'ising'
1334 elif bqm.vartype is dimod.BINARY:
1335 problem_type = 'qubo'
1336 else:
1337 raise TypeError("unknown/unsupported vartype")
1338
1339 # convert to dicts once, to save multiple conversions later on
1340 linear = dict(bqm.linear)
1341 quadratic = dict(bqm.quadratic)
1342
1343 return self._sample(problem_type, linear, quadratic, bqm.offset,
1344 params, label=label, undirected_biases=True)
1345
1346 @property
1347 def minimal_problem(self) -> tuple[tuple[dict, dict, float], dict]:

Callers

nothing calls this directly

Calls 1

_sampleMethod · 0.95

Tested by

no test coverage detected