LeapHybridCqm¶
Leap’s quantum-classical hybrid solvers are intended to solve arbitrary application problems formulated as quadratic models. This solver accepts arbitrarily structured problems formulated as CQMs, with any constraints represented natively.
Compatible Backends¶
The LeapHybridCqm algorithm supports the following backends:
DWaveQpuBy default,LeapHybridCqmuses theDWaveQpubackend.
Initialization¶
The following section outlines the default configurations of LeapHybridCqm. You can also specify
other compatible backends for the algorithm. When backend=None is specified, the default backend
will be initialized automatically. In this case, if the backend requires a token, it will be taken
from the environment variables.
from luna_quantum.algorithms import LeapHybridCqm
algorithm = LeapHybridCqm(
backend=None,
time_limit=None,
spin_variables=None
)
Parameter Details
For a complete overview of available parameters and their usage, see the LeapHybridCqm API Reference.
Usage¶
from luna_quantum import LunaSolve
LunaSolve.authenticate("<YOUR_LUNA_API_KEY>")
# Define your model and algorithm
model = ...
algorithm = ...
solve_job = algorithm.run(model, name="my-solve-job")
API Reference¶
Bases: LunaAlgorithm[DWaveQpu]
Parameters for D-Wave's Leap Hybrid Constrained Quadratic Model (CQM) solver.
The Leap Hybrid CQM solver extends hybrid quantum-classical optimization to handle constrained problems, allowing both linear and quadratic constraints alongside the quadratic objective function. This enables solving many practical optimization problems in their natural formulation without manual penalty conversion.
The solver is suitable for mixed binary, integer, and continuous problems with thousands of variables and constraints.
Attributes:
| Name | Type | Description |
|---|---|---|
time_limit |
float | int | None
|
Maximum running time in seconds. Longer limits generally yield better solutions but increase resource usage. Default is None, which uses the service's default time limit (typically problem-size dependent). |
spin_variables |
list[str] | None
|
Variables to represent as spins (-1/+1) rather than binary (0/1) values. Useful for problems naturally formulated in spin space. Default is None, which uses binary representation for all discrete variables. |
backend
class-attribute
instance-attribute
¶
model_config
class-attribute
instance-attribute
¶
get_compatible_backends
classmethod
¶
get_default_backend
classmethod
¶
get_default_backend() -> DWaveQpu
Return the default backend implementation.
This property must be implemented by subclasses to provide the default backend instance to use when no specific backend is specified.
Returns:
| Type | Description |
|---|---|
IBackend
|
An instance of a class implementing the IBackend interface that serves as the default backend. |
run ¶
run(
model: Model | str,
name: str | None = None,
backend: BACKEND_TYPE | None = None,
client: LunaSolve | str | None = None,
*args: Any,
**kwargs: Any,
) -> SolveJob
Run the configured solver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model or str
|
The model to be optimized or solved. It could be an Model instance or a string identifier representing the model id. |
required |
name
|
str | None
|
If provided, the name of the job. Defaults to None. |
None
|
backend
|
BACKEND_TYPE | None
|
Backend to use for the solver. If not provided, the default backend is used. |
None
|
client
|
LunaSolve or str
|
The client interface used to interact with the backend services. If not provided, a default client will be used. |
None
|
*args
|
Any
|
Additional arguments that will be passed to the solver or client. |
()
|
**kwargs
|
Any
|
Additional keyword parameters for configuration or customization. |
{}
|
Returns:
| Type | Description |
|---|---|
SolveJob
|
The job object containing the information about the solve process. |