--- sd_hide_title: true --- # D-Wave Systems (clients-DWaveSamplerClient)= ## D-Wave Sampler [D-Wave Systems](https://www.dwavesys.com/) offers a quantum annealing machine (quantum processing unit; QPU) that allows you to input QUBO or a combinatorial optimization problem expressed as a quadratic polynomial in Ising variables. ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**Solver specification**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.DWaveSamplerClient` * - [Execution parameters](amplify.DWaveSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution results](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["timing"]["qpu_access_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,real variable Objective function,2nd{sup}`*`,2nd{sup}`*`,\-,\- Equality constraint,\-,\-,\-,\- Inequality constraint,\-,\-,\-,\- ``` \*: Problems involving both binary and Ising variables at the same time are not handled. :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.DWaveSamplerClient.solver` - {py:class}`str` - Get and set the name of the D-Wave Sampler to use * - {py:attr}`~amplify.DWaveSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get a list of D-Wave Sampler names that can be specified with the set token. * - {py:attr}`~amplify.DWaveSamplerClient.properties` - {py:class}`dict` - Get the solver properties to use (returns the same as {py:attr}`dwave.system.samplers.DWaveSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import DWaveSamplerClient client = DWaveSamplerClient() # Set API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver to use # (Specify one of the client.solver_names) client.solver = "Advantage_system4.1" # Set the number of runs to 1000 client.parameters.num_reads = 1000 ``` ````{seealso} For the attribute you can set in {py:attr}`amplify.DWaveSamplerClient.parameters`, refer to [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.DWaveSamplerClient.properties` (the output will vary depending on the {py:attr}`~amplify.DWaveSamplerClient.solver`) as follows. ```python >>> client.properties["parameters"] {'anneal_offsets': 'Anneal offsets for each working qubit, formatted as a list, with NaN specified for unused qubits.', 'anneal_schedule': "Annealing schedule formatted as a piecewise linear list of floating-point pairs of 't' and 's'.", 'annealing_time': 'Quantum annealing duration, in microseconds, as a positive floating point number.', ...} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` To obtain the solver to use (if not specified, it will be determined automatically): ```python >>> client.solver 'Advantage_system4.1' ``` To obtain the list of solvers currently available: ```python >>> client.solver_names ['Advantage_system6.4', 'Advantage2_prototype2.3', 'Advantage_system4.1'] ``` (clients-LeapHybridSamplerClient)= ## Leap's Hybrid BQM Sampler This is a hybrid solver from [D-Wave Systems](https://www.dwavesys.com/) that works with quantum annealing machines (QPUs) and classical algorithms, allowing input of combinatorial optimization problems expressed as QUBOs or quadratic polynomials in Ising variables, and supporting input of larger problems than [D-Wave Sampler](#DWaveSamplerClient). ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**γ‚½γƒ«γƒγƒΌδ»•ζ§˜**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.LeapHybridSamplerClient` * - [Execution parameters](amplify.LeapHybridSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution result](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,Real variable Objective function,2nd,2nd,\-,\- Equality constraint,\-,\-,\-,\- Inequality constraint,\-,\-,\-,\- ``` :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.LeapHybridSamplerClient.solver` - {py:class}`str` - Get and set the name of Leap's Hybrid BQM Sampler. * - {py:attr}`~amplify.LeapHybridSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get a list of Leap's Hybrid BQM sampler names that can be specified with the set token. * - {py:attr}`~amplify.LeapHybridSamplerClient.properties` - {py:class}`dict` - Get the properties of the solver to use (returns the same result as {py:attr}`dwave.system.samplers.LeapHybridSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import LeapHybridSamplerClient client = LeapHybridSamplerClient() # Set API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Get the solver to use # (if not specified, it will be determined automatically) # print(client.solver) # Get a list of available solvers # print(client.solver_names) # Specify which solver ro use # (Specify one of the names in client.solver_names) client.solver = "hybrid_binary_quadratic_model_version2" # Set the execution time limit to 3 seconds client.parameters.time_limit = 3 ``` ````{seealso} Dor attributes you can set in {py:attr}`amplify.LeapHybridSamplerClient.parameters`, refer to [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.LeapHybridSamplerClient.properties` as follows (the output will vary depending on the {py:attr}`~amplify.LeapHybridSamplerClient.solver`) ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` To obtain the solver to use (if not specified, it will be determined automatically): ```python >>> client.solver 'hybrid_binary_quadratic_model_version2' ``` To obtain the list of currently available solvers:: ```python >>> client.solver_names ['hybrid_binary_quadratic_model_version2'] ``` (clients-LeapHybridCQMSamplerClient)= ## Leap's Hybrid CQM Sampler This is a hybrid solver from [D-Wave Systems](https://www.dwavesys.com/) that uses quantum annealing machines (QPUs) and classical algorithms to solve combinatorial optimization problems with QUBO or Ising, integer or real variable objective functions, and one or more constraints. ```{tip} You can [register as a Fixstars Amplify user](https://amplify.fixstars.com/register) to get a free trial API token for D-Wave Systems, or get an API token with your D-Wave Systems account. ``` :**Solver specification**: ```{list-table} :width: 100% :widths: 1 2 * - Client class - {py:class}`amplify.LeapHybridCQMSamplerClient` * - [Execution parameters](amplify.LeapHybridCQMSamplerClient.parameters) - {py:class}`amplify.DWaveClientParameters` * - [Execution result](amplify.Result.client_result) - {py:class}`dimod.sampleset.SampleSet` * - [Execution time](amplify.Result.execution_time) - `dimod.sampleset.SampleSet.info["run_time"]` * - API method - REST API ([SAPI](https://docs.dwavesys.com/docs/latest/doc_rest_api.html)) * - Execution parameter reference - [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html) ``` ```{csv-table} :header-rows: 1 :stub-columns: 1 :width: 100% :widths: 1 1 1 1 1 ,Binary variable,Ising variable,Integer variable,Real variable Objective function,2nd,2nd,2nd,1st Equality constraint,2nd,2nd,2nd,1st Inequality constraint,2nd,2nd,2nd,1st ``` :**Client class**: In addition to [the common interface](#client-common-interface), the client class has the following attributes. ```{list-table} :width: 100% :header-rows: 1 :widths: 1 1 3 * - Attribute - Data type - Details * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver` - {py:class}`str` - Get and set the name of Leap's Hybrid BQM Sampler. * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver_names` - {py:class}`list`[{py:class}`str`] - Get the list of Leap's Hybrid BQM Sampler names you can use with the set token. * - {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` - {py:class}`dict` - Get the properties of the solver to use (returns the same result as {py:attr}`dwave.system.samplers.LeapHybridCQMSampler.properties`) ``` :**Configuration example**: ```{testcode} from amplify import LeapHybridCQMSamplerClient client = LeapHybridCQMSamplerClient() # Set an API token client.token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Specify the solver to use # (Specify a name from client.solver_names) client.solver = "hybrid_constrained_quadratic_model_version1p" # Set an execution time limit to 3 seconds client.parameters.time_limit = 3 ``` ````{seealso} For attributes you can set in {py:attr}`amplify.LeapHybridCQMSamplerClient.parameters`, refer to [{bdg-info}`πŸ“– Parameters Reference`](https://docs.dwavesys.com/docs/latest/c_solver_parameters.html). You can also get them from {py:attr}`~amplify.LeapHybridCQMSamplerClient.properties` as follows (the output will vary depending on the {py:attr}`~amplify.LeapHybridCQMSamplerClient.solver`) ```python >>> client.properties["parameters"] {'time_limit': 'Maximum requested runtime in seconds.'} ``` ```` :**Execution example**: ```python from amplify import Model, VariableGenerator, solve # Create decision variables and the objective function g = VariableGenerator() q = g.array("Binary", 2) f = q[0] * q[1] + q[0] - q[1] + 1 # Create a model model = Model(f) # Run the solver result = solve(model, client) ``` To obtain the solver (if not specified it will be automatically set): ```python >>> client.solver 'hybrid_constrained_quadratic_model_version1p' ``` To obtain the list of the solvers currently available: ```python >>> client.solver_names ['hybrid_constrained_quadratic_model_version1p'] ``` To obtain the solver version: ```python >>> client.version '1.12' ```