D-Wave Sampler¶
<<<<<<< HEAD Class =====
Overview¶
-
class
DWaveSampler
(config_file=None, profile=None, endpoint=None, token=None, solver=None, proxy=None, permissive_ssl=False)[source]¶ A class for using the D-Wave system as a sampler.
Inherits from
dimod.Sampler
anddimod.Structured
.Enables quick incorporation of the D-Wave system as a sampler in the D-Wave Ocean software stack. Also enables optional customizing of input parameters to D-Wave Cloud Client (the stack’s communication-manager package).
Parameters: - config_file (str, optional) – Path to a D-Wave Cloud Client configuration file that identifies a D-Wave system and provides connection information.
- profile (str, optional) – Profile to select from a D-Wave Cloud Client configuration file.
- endpoint (str, optional) – D-Wave API endpoint URL. If specified, used instead of retrieving a value from a D-Wave Cloud Client configuration file.
- token (str, optional) – Authentication token for the D-Wave API to authenticate the client session. If specified, used instead of retrieving a value from a D-Wave Cloud Client configuration file.
- solver (str, optional) – Solver (a D-Wave system on which to run submitted problems). If specified, used instead of retrieving a value from a D-Wave Cloud Client configuration file.
- proxy (str, optional) – Proxy URL to be used for accessing the D-Wave API. If specified, used instead of retrieving a value from a D-Wave Cloud Client configuration file.
Examples
This example creates a
DWaveSampler
based on a fictive user’s D-Wave Cloud Client configuration file and submits a simple Ising problem of just two variables that map to qubits 0 and 1 on the example system. (The simplicity of this example obviates the need for an embedding composite—the presence of qubits 0 and 1 on the selected D-Wave system can be verified manually.)>>> # Example configuration file /home/susan/.config/dwave/dwave.conf: >>> # [defaults] >>> # endpoint = https://url.of.some.dwavesystem.com/sapi >>> # client = qpu >>> # >>> # [dw2000] >>> # solver = EXAMPLE_2000Q_SYSTEM >>> # token = ABC-123456789123456789123456789 >>> from dwave.system.samplers import DWaveSampler >>> sampler = DWaveSampler('/home/susan/.config/dwave/dwave.conf') >>> response = sampler.sample_ising({0: -1, 1: 1}, {}) >>> for sample in response.samples(): ... print(sample) ... {0: 1, 1: -1}
Sampler Properties¶
DWaveSampler.properties |
dict – D-Wave solver properties as returned by a SAPI query. |
DWaveSampler.parameters |
dict[str, list] – D-Wave solver parameters in the form of a dict, where keys are |
Structured Sampler Properties¶
DWaveSampler.nodelist |
list – List of active qubits for the D-Wave solver. |
DWaveSampler.edgelist |
list – List of active couplers for the D-Wave solver. |
DWaveSampler.adjacency |
dict[variable, set] – The adjacency structure. |
DWaveSampler.structure |
A namedtuple Structure(nodelist, edgelist, adjacency) |
Methods¶
DWaveSampler.sample (bqm, **parameters) |
Samples from the given bqm using the instantiated sample method. |
DWaveSampler.sample_ising (h, J, **kwargs) |
Sample from the provided Ising model. |
DWaveSampler.sample_qubo (Q, **kwargs) |
Sample from the provided QUBO. |