dwave.system.samplers.DWaveSampler.sample_qubo¶
-
DWaveSampler.
sample_qubo
(Q, **kwargs)[source]¶ Sample from the provided QUBO.
Parameters: - Q (dict) – Coefficients of a quadratic unconstrained binary optimization (QUBO) model.
- **kwargs – Optional keyword arguments for the sampling method, specified per solver in
DWaveSampler.parameters
Returns: Examples
This example creates a
DWaveSampler
based on a D-Wave solver selected by the user’s default D-Wave Cloud Client configuration file and submits a simple QUBO problem of just two variables that map to coupled qubits 0 and 4 on the example system. (The simplicity of this example obviates the need for an embedding composite—the presence of qubits 0 and 4, and their coupling, on the selected D-Wave system can be verified manually.)>>> from dwave.system.samplers import DWaveSampler >>> sampler = DWaveSampler() >>> Q = {(0, 0): -1, (4, 4): -1, (0, 4): 2} >>> response = sampler.sample_qubo(Q) >>> for sample in response.samples(): ... print(sample) ... {0: 0, 4: 1}