JijLeapHybridCQMSampler
Leap's hybrid solver, provided by D-Wave, excels at solving optimization problems with numerous variables, utilizing a hybrid algorithm that combines quantum annealing machines and classical computers. Its capability to process Constrained Quadratic Models (CQMs) allows it to tackle a broad spectrum of problems, especially those centered around constrained quadratic optimization. For more details, please refer to this document.
Usage
Update the
config.toml
by adding the[default.thirdparty-setting]
section. Include the following two items:leap_url
: Endpoint for the D-Wave API. For more details, please see here.leap_token
: Authentication token for the D-Wave API. For more specifics, refer to the "Configuring Access to Leap's Solvers" page.
[default]
url = "https://api.m.jijzept.com/"
token = "JIJ_ZEPT_API_KEY"
[default.thirdparty-setting]
leap_url = "D-Wave_API_ENDPOINT" # Optional: Basically works without it.
leap_token = "D-Wave_API_TOKEN"Use the two classes provided by the
jijzept
and run the methodsample_model
in theJijLeapHybridCQMSampler
class:JijLeapHybridCQMSampler
: a class to sample using the hybrid CQM solver.JijLeapHybridCQMParameters
: a class to set parameters specifically for the hybrid CQM solver.
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters
sampler = JijLeapHybridCQMSampler(config="./config.toml")
parameters = JijLeapHybridCQMParameters(time_limit=1)
response = sampler.sample_model(
model=problem,
feed_dict=instance_data,
parameters=parameters,
)
If you want to configure leap_url
and leap_token
without using the configuration file, you can do so as follows:
sampler = JijLeapHybridCQMSampler(
url="https://api.m.jijzept.com/",
token="JIJ_ZEPT_API_KEY",
leap_url="D-Wave_API_ENDPOINT",
leap_token="D-Wave_API_TOKEN",
)
Parameters
JijLeapHybridCQMParameters
name | type | default | description |
---|---|---|---|
time_limit | Optional[Union[int, float]] | None | Maximum run time, in seconds, to allow the solver to work on the problem. For more details, please refer to the description of the time_limit in the API reference. |
label | Optional[str] | None | If you set a value, it will be contained in the SampleSet.metadata.info returned by the JijLeapHybridCQMSampler. For more details, please refer to this document. |
JijLeapHybridCQMSampler.sample_model
name | type | default | description |
---|---|---|---|
fixed_variables | Optional[FixedVariables] | None | The dictionary of variables to be fixed. |
parameters | Optional[JijLeapHybridCQMParameters] | None | Parameters for JijLeapHybridCQMSampler. |
relax_list | Optional[list[str]] | None | Integer variables defined using JijModeling are added to a CQM as integer variables. If you want to add specific integer variables to CQM as real (or continuous) variables, add their names to the relax_list . |
max_wait_time | Optional[Union[int, float]] | None | The timeout duration (in seconds) for a post request. If None , 60 (one minute) will be set. |
sync | bool | True | If True , synchronous mode is enabled. |
queue_name | Optional[str] | None | Queue name |