Dwave Leap Hybrid CQM¶
JijLeapHybridCQMParameters
dataclass
¶
Manage Parameters for using Leap Hybrid CQM Sampler.
Attributes:
Name | Type | Description |
---|---|---|
time_limit | Optional[Union[int, float]] | the maximum run time, in seconds, the solver is allowed to work on the given problem. Must be at least the minimum required for the problem, which is calculated and set by default. It is deprecated to set this up due to high credit consumption. |
label | str | The problem label given to the dimod.SampelSet instance returned by the JijLeapHybridCQMSampler. Defaults to None. |
JijLeapHybridCQMSampler
¶
Bases: JijZeptBaseSampler
__init__(token=None, url=None, proxy=None, config=None, config_env='default', leap_token=None, leap_url=None)
¶
Sets token and url.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | Optional[str] | Token string for JijZept. | None |
url | Optional[str] | API URL for JijZept. | None |
proxy | Optional[str] | Proxy URL. Defaults to None. | None |
config | Optional[str] | Config file path for JijZept. | None |
token_leap | Optional[str] | Token string for Dwave Leap. | required |
url_leap | Optional[str] | API URL for Dwave Leap. | required |
sample_model(model, feed_dict, fixed_variables=None, relax_list=None, parameters=None, timeout=None, sync=True, queue_name=None, **kwargs)
¶
Converts the given problem to dimod.ConstrainedQuadraticModel and runs.
Dwave's LeapHybridCQMSampler. Note here that the supported type of decision variables is only Binary when using LeapHybridCQMSolver from Jijzept.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem | Problem | Optimization problem of JijModeling. | required |
feed_dict | Dict[str, Union[Number, List, np.ndarray]] | The actual values to be assigned to the placeholders. | required |
fixed_variables | Optional[Dict[str, Dict[Tuple[int, ...], Union[int, float]]]] | variables to fix. | None |
relax_list | Optional[List[str]] | variable labels for continuous relaxation. | None |
parameters | Optional[JijLeapHybridCQMParameters] | Parameters used in Dwave Leap Hybrid CQMSampler. If | None |
timeout | Optional[int] | The number of timeout [sec] for post request. If | None |
sync | bool | Synchronous mode. | True |
queue_name | Optional[str] | Queue name. | None |
kwargs | Dwave Leap parameters using **kwags. If both | {} |
Returns:
Name | Type | Description |
---|---|---|
JijModelingSampleset | JijModelingResponse | Stores samples and other information. |
Examples:
import jijmodeling as jm
from jijzept import JijLeapHybridCQMSampler, JijLeapHybridCQMParameters
w = jm.Placeholder("w", dim=1)
num_items = jm.Placeholder("num_items")
c = jm.Placeholder("c")
y = jm.Binary("y", shape=(num_items,))
x = jm.Binary("x", shape=(num_items, num_items))
i = jm.Element("i", num_items)
j = jm.Element("j", num_items)
problem = jm.Problem("bin_packing")
problem += y[:]
problem += jm.Constraint("onehot_constraint", jm.Sum(j, x[i, j]) - 1 == 0, forall=i)
problem += jm.Constraint("knapsack_constraint", jm.Sum(i, w[i] * x[i, j]) - y[j] * c <= 0, forall=j)
feed_dict = {"num_items": 2, "w": [9, 1], "c": 10}
sampler = JijLeapHybridCQMSampler(config="XX", token_leap="XX")
parameters = JijLeapHybridCQMParameters(label="bin_packing")
sampleset = sampler.sample_model(
problem, feed_dict, parameters=parameters
)