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

Method sample_qubo

dwave/cloud/solver.py:1257–1304  ·  view source on GitHub ↗

Sample from the specified :term:`QUBO`. Args: qubo (dict[(int, int), float]): Coefficients of a quadratic unconstrained binary optimization (QUBO) problem. Should be a dict of the form `{(u, v): bias, ...}` where `u`, `v`, are bina

(self, qubo, offset=0, label=None, **params)

Source from the content-addressed store, hash-verified

1255 return self._sample('ising', linear, quadratic, offset, params, label=label)
1256
1257 def sample_qubo(self, qubo, offset=0, label=None, **params):
1258 """Sample from the specified :term:`QUBO`.
1259
1260 Args:
1261 qubo (dict[(int, int), float]):
1262 Coefficients of a quadratic unconstrained binary optimization
1263 (QUBO) problem. Should be a dict of the form `{(u, v): bias, ...}`
1264 where `u`, `v`, are binary-valued variables and `bias` is their
1265 associated coefficient.
1266
1267 offset (optional, default=0):
1268 Constant offset applied to the model.
1269
1270 label (str, optional):
1271 Problem label you can optionally tag submissions with for ease
1272 of identification.
1273
1274 **params:
1275 Parameters for the sampling method, solver-specific.
1276
1277 Returns:
1278 :class:`~dwave.cloud.computation.Future`
1279
1280 Examples:
1281 This example creates a client using the local system's default D-Wave
1282 Cloud Client configuration file, which is configured to access an
1283 Advantage QPU, submits a :term:`QUBO` problem (a Boolean NOT gate
1284 represented by a penalty model), and samples 5 times.
1285
1286 >>> from dwave.cloud import Client
1287 >>> with Client.from_config() as client: # doctest: +SKIP
1288 ... solver = client.get_solver()
1289 ... u, v = next(iter(solver.edges))
1290 ... Q = {(u, u): -1, (u, v): 0, (v, u): 2, (v, v): -1}
1291 ... computation = solver.sample_qubo(Q, num_reads=5)
1292 ... for i in range(5):
1293 ... print(computation.samples[i][u], computation.samples[i][v])
1294 ...
1295 ...
1296 (0, 1)
1297 (1, 0)
1298 (1, 0)
1299 (0, 1)
1300 (1, 0)
1301
1302 """
1303 linear, quadratic = reformat_qubo_as_ising(qubo)
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`.

Calls 2

_sampleMethod · 0.95
reformat_qubo_as_isingFunction · 0.90