luna-quantum 1.0.8rc2__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of luna-quantum might be problematic. Click here for more details.
- luna_quantum/__init__.py +121 -0
- luna_quantum/__init__.pyi +85 -0
- luna_quantum/_core.cp314-win_amd64.pyd +0 -0
- luna_quantum/_core.pyi +4185 -0
- luna_quantum/algorithms/__init__.py +1 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -0
- luna_quantum/backends/__init__.py +1 -0
- luna_quantum/client/__init__.py +0 -0
- luna_quantum/client/controllers/__init__.py +4 -0
- luna_quantum/client/controllers/luna_http_client.py +37 -0
- luna_quantum/client/controllers/luna_platform_client.py +256 -0
- luna_quantum/client/controllers/luna_q.py +67 -0
- luna_quantum/client/controllers/luna_solve.py +129 -0
- luna_quantum/client/error/__init__.py +0 -0
- luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
- luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
- luna_quantum/client/error/luna_error.py +2 -0
- luna_quantum/client/error/luna_server_error.py +20 -0
- luna_quantum/client/error/timeout_error.py +12 -0
- luna_quantum/client/error/transformation_error.py +18 -0
- luna_quantum/client/error/utils/__init__.py +0 -0
- luna_quantum/client/error/utils/http_error_utils.py +112 -0
- luna_quantum/client/interfaces/__init__.py +4 -0
- luna_quantum/client/interfaces/clients/__init__.py +25 -0
- luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
- luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
- luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
- luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
- luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
- luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
- luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
- luna_quantum/client/interfaces/services/__init__.py +0 -0
- luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
- luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
- luna_quantum/client/interfaces/services/service_i.py +56 -0
- luna_quantum/client/rest_client/__init__.py +15 -0
- luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
- luna_quantum/client/rest_client/info_rest_client.py +74 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
- luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
- luna_quantum/client/rest_client/users_rest_client.py +35 -0
- luna_quantum/client/schemas/__init__.py +26 -0
- luna_quantum/client/schemas/circuit.py +48 -0
- luna_quantum/client/schemas/create/__init__.py +15 -0
- luna_quantum/client/schemas/create/circuit.py +30 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +22 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
- luna_quantum/client/schemas/create/qubo.py +19 -0
- luna_quantum/client/schemas/create/solve_job_create.py +43 -0
- luna_quantum/client/schemas/enums/__init__.py +0 -0
- luna_quantum/client/schemas/enums/call_style.py +13 -0
- luna_quantum/client/schemas/enums/circuit.py +42 -0
- luna_quantum/client/schemas/enums/model_format.py +11 -0
- luna_quantum/client/schemas/enums/problem.py +50 -0
- luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
- luna_quantum/client/schemas/enums/sense.py +8 -0
- luna_quantum/client/schemas/enums/status.py +40 -0
- luna_quantum/client/schemas/enums/timeframe.py +11 -0
- luna_quantum/client/schemas/error_message.py +14 -0
- luna_quantum/client/schemas/model_metadata.py +35 -0
- luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
- luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +50 -0
- luna_quantum/client/schemas/solver_info.py +11 -0
- luna_quantum/client/schemas/user.py +11 -0
- luna_quantum/client/schemas/wrappers/__init__.py +5 -0
- luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
- luna_quantum/client/utils/__init__.py +0 -0
- luna_quantum/client/utils/qpu_token_utils.py +147 -0
- luna_quantum/config.py +11 -0
- luna_quantum/decorators.py +248 -0
- luna_quantum/errors.py +34 -0
- luna_quantum/errors.pyi +287 -0
- luna_quantum/exceptions/__init__.py +0 -0
- luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
- luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
- luna_quantum/factories/__init__.py +4 -0
- luna_quantum/factories/luna_solve_client_factory.py +100 -0
- luna_quantum/factories/usecase_factory.py +457 -0
- luna_quantum/py.typed +0 -0
- luna_quantum/solve/__init__.py +13 -0
- luna_quantum/solve/default_token.py +304 -0
- luna_quantum/solve/domain/__init__.py +0 -0
- luna_quantum/solve/domain/abstract/__init__.py +4 -0
- luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +56 -0
- luna_quantum/solve/domain/solve_job.py +196 -0
- luna_quantum/solve/errors/__init__.py +0 -0
- luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
- luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
- luna_quantum/solve/errors/solve_base_error.py +5 -0
- luna_quantum/solve/errors/token_missing_error.py +11 -0
- luna_quantum/solve/interfaces/__init__.py +0 -0
- luna_quantum/solve/interfaces/algorithm_i.py +49 -0
- luna_quantum/solve/interfaces/backend_i.py +28 -0
- luna_quantum/solve/interfaces/usecases/__init__.py +55 -0
- luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
- luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
- luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
- luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
- luna_quantum/solve/parameters/__init__.py +0 -0
- luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
- luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
- luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
- luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
- luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
- luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +26 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +99 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +102 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
- luna_quantum/solve/parameters/backends/__init__.py +22 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
- luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
- luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
- luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
- luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
- luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
- luna_quantum/solve/parameters/backends/dwave.py +17 -0
- luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
- luna_quantum/solve/parameters/backends/fda.py +17 -0
- luna_quantum/solve/parameters/backends/ibm.py +138 -0
- luna_quantum/solve/parameters/backends/qctrl.py +103 -0
- luna_quantum/solve/parameters/backends/zib.py +17 -0
- luna_quantum/solve/parameters/constants.py +11 -0
- luna_quantum/solve/parameters/mixins/__init__.py +0 -0
- luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
- luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
- luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
- luna_quantum/solve/use_cases/__init__.py +119 -0
- luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
- luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
- luna_quantum/solve/use_cases/base.py +7 -0
- luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
- luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
- luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
- luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
- luna_quantum/solve/use_cases/exact_cover.py +51 -0
- luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
- luna_quantum/solve/use_cases/graph_coloring.py +42 -0
- luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
- luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
- luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
- luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
- luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
- luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
- luna_quantum/solve/use_cases/linear_regression.py +60 -0
- luna_quantum/solve/use_cases/lmwcs.py +84 -0
- luna_quantum/solve/use_cases/longest_path.py +50 -0
- luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
- luna_quantum/solve/use_cases/max2sat.py +54 -0
- luna_quantum/solve/use_cases/max3sat.py +55 -0
- luna_quantum/solve/use_cases/max_clique.py +60 -0
- luna_quantum/solve/use_cases/max_cut.py +48 -0
- luna_quantum/solve/use_cases/max_independent_set.py +37 -0
- luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
- luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
- luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
- luna_quantum/solve/use_cases/number_partitioning.py +32 -0
- luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
- luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
- luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
- luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
- luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
- luna_quantum/solve/use_cases/sensor_placement.py +58 -0
- luna_quantum/solve/use_cases/set_cover.py +56 -0
- luna_quantum/solve/use_cases/set_packing.py +54 -0
- luna_quantum/solve/use_cases/set_partitioning.py +52 -0
- luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
- luna_quantum/solve/use_cases/subset_sum.py +37 -0
- luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
- luna_quantum/solve/use_cases/traffic_flow.py +35 -0
- luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
- luna_quantum/solve/use_cases/type_aliases.py +9 -0
- luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
- luna_quantum/solve/usecases/__init__.py +45 -0
- luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
- luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
- luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
- luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
- luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
- luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
- luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
- luna_quantum/solve/usecases/model_save_usecase.py +63 -0
- luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
- luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
- luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
- luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +95 -0
- luna_quantum/transformations.py +18 -0
- luna_quantum/transformations.pyi +371 -0
- luna_quantum/translator.py +23 -0
- luna_quantum/translator.pyi +869 -0
- luna_quantum/util/__init__.py +0 -0
- luna_quantum/util/active_waiting.py +79 -0
- luna_quantum/util/class_patcher.py +164 -0
- luna_quantum/util/debug_info.py +52 -0
- luna_quantum/util/log_utils.py +187 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +3 -0
- luna_quantum/utils.pyi +67 -0
- luna_quantum-1.0.8rc2.dist-info/METADATA +36 -0
- luna_quantum-1.0.8rc2.dist-info/RECORD +264 -0
- luna_quantum-1.0.8rc2.dist-info/WHEEL +4 -0
- luna_quantum-1.0.8rc2.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.0.8rc2.dist-info/licenses/NOTICE +13 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
8
|
+
from luna_quantum.solve.parameters.backends import Fujitsu
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FujitsuDABase(LunaAlgorithm[Fujitsu]):
|
|
12
|
+
"""Fujitsu Digital Annealer base parameters.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
scaling_action: Literal["NOTHING", "SCALING", "AUTO_SCALING"]
|
|
17
|
+
Method for scaling ``qubo`` and determining temperatures:
|
|
18
|
+
- "NOTHING": No action (use parameters exactly as specified)
|
|
19
|
+
- "SCALING": ``scaling_factor`` is multiplied to ``qubo``,
|
|
20
|
+
``temperature_start``, ``temperature_end`` and ``offset_increase_rate``.
|
|
21
|
+
- "AUTO_SCALING": A maximum scaling factor w.r.t. ``scaling_bit_precision``
|
|
22
|
+
is multiplied to ``qubo``, ``temperature_start``, ``temperature_end`` and
|
|
23
|
+
``offset_increase_rate``.
|
|
24
|
+
scaling_factor: int | float
|
|
25
|
+
Multiplicative factor applied to model coefficients, temperatures, and other
|
|
26
|
+
parameters: the ``scaling_factor`` for ``qubo``, ``temperature_start``,
|
|
27
|
+
``temperature_end`` and ``offset_increase_rate``.
|
|
28
|
+
Higher values can improve numerical precision but may lead to overflow.
|
|
29
|
+
Default is 1.0 (no scaling).
|
|
30
|
+
scaling_bit_precision: int
|
|
31
|
+
Maximum bit precision to use when scaling. Determines the maximum allowable
|
|
32
|
+
coefficient magnitude. Default is 64, using full double precision.
|
|
33
|
+
random_seed: Union[int, None]
|
|
34
|
+
Seed for random number generation to ensure reproducible results.
|
|
35
|
+
Must be between 0 and 9_999. Default is None (random seed).
|
|
36
|
+
penalty_factor: float
|
|
37
|
+
Penalty factor used to scale the equality constraint penalty function,
|
|
38
|
+
default 1.0.
|
|
39
|
+
inequality_factor: int
|
|
40
|
+
Penalty factor used to scale the inequality constraints, default 1.
|
|
41
|
+
remove_ohg_from_penalty: bool
|
|
42
|
+
If equality constraints, identified to be One-Hot constraints are only
|
|
43
|
+
considered within one-hot groups (`remove_ohg_from_penalty=True`), i.e.,
|
|
44
|
+
identified one-hot constraints are not added to the penalty function,
|
|
45
|
+
default True.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
scaling_action: Literal["NOTHING", "SCALING", "AUTO_SCALING"] = "NOTHING"
|
|
49
|
+
scaling_factor: int | float = 1.0
|
|
50
|
+
scaling_bit_precision: int = 64
|
|
51
|
+
random_seed: int | None = Field(default=None, ge=0, le=9_999)
|
|
52
|
+
|
|
53
|
+
penalty_factor: float = 1.0
|
|
54
|
+
inequality_factor: int = 1
|
|
55
|
+
remove_ohg_from_penalty: bool = True
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def get_default_backend(cls) -> Fujitsu:
|
|
59
|
+
"""
|
|
60
|
+
Return the default backend implementation.
|
|
61
|
+
|
|
62
|
+
This property must be implemented by subclasses to provide
|
|
63
|
+
the default backend instance to use when no specific backend
|
|
64
|
+
is specified.
|
|
65
|
+
|
|
66
|
+
Returns
|
|
67
|
+
-------
|
|
68
|
+
IBackend
|
|
69
|
+
An instance of a class implementing the IBackend interface that serves
|
|
70
|
+
as the default backend.
|
|
71
|
+
"""
|
|
72
|
+
return Fujitsu()
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def get_compatible_backends(cls) -> tuple[type[Fujitsu], ...]:
|
|
76
|
+
"""
|
|
77
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
tuple[type[IBackend], ...]
|
|
82
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
return (Fujitsu,)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from .fujits_da_base import FujitsuDABase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FujitsuDA(FujitsuDABase):
|
|
7
|
+
"""
|
|
8
|
+
Parameters for the Fujitsu Digital Annealer (v3c).
|
|
9
|
+
|
|
10
|
+
Attributes
|
|
11
|
+
----------
|
|
12
|
+
time_limit_sec: int | None
|
|
13
|
+
Maximum running time of DA in seconds. Specifies the upper limit of running
|
|
14
|
+
time of DA. Time_limit_sec should be selected according to problem hardness
|
|
15
|
+
and size (number of bits). Min: 1, Max: 3600
|
|
16
|
+
target_energy: int | None
|
|
17
|
+
Threshold energy for fast exit. This may not work correctly if the specified
|
|
18
|
+
value is larger than its max value or lower than its min value.
|
|
19
|
+
Min: -99_999_999_999, Max: 99_999_999_999
|
|
20
|
+
num_group: int
|
|
21
|
+
Number of independent optimization processes. Increasing the number of
|
|
22
|
+
independent optimization processes leads to better coverage of the search
|
|
23
|
+
space. Note: Increasing this number requires to also increase time_limit_sec
|
|
24
|
+
such that the search time for each process is sufficient.
|
|
25
|
+
Default: 1, Min: 1, Max: 16
|
|
26
|
+
num_solution: int
|
|
27
|
+
Number of solutions maintained and updated by each optimization process.
|
|
28
|
+
Default: 16, Min: 1, Max: 1024
|
|
29
|
+
num_output_solution: int
|
|
30
|
+
Maximal number of the best solutions returned by each optimization.
|
|
31
|
+
Total number of results is ``num_solution`` * ``num_group``.
|
|
32
|
+
Default: 5, Min: 1, Max: 1024
|
|
33
|
+
gs_num_iteration_factor: int
|
|
34
|
+
Maximal number of iterations in one epoch of the global search in each
|
|
35
|
+
optimization is ``gs_num_iteration_factor`` * *number of bits*.
|
|
36
|
+
Default: 5, Min: 0, Max: 100
|
|
37
|
+
gs_num_iteration_cl: int
|
|
38
|
+
Maximal number of iterations without improvement in one epoch of the global
|
|
39
|
+
search in each optimization before terminating and continuing with the next
|
|
40
|
+
epoch. For problems with very deep local minima having a very low value is
|
|
41
|
+
helpful. Default: 800, Min: 0, Max: 1000000
|
|
42
|
+
gs_ohs_xw1h_num_iteration_factor: int
|
|
43
|
+
Maximal number of iterations in one epoch of the global search in each
|
|
44
|
+
optimization is ``gs_ohs_xw1h_num_iteration_factor`` * *number of bits*.
|
|
45
|
+
Only used when 1Hot search is defined. Default: 3, Min: 0, Max: 100
|
|
46
|
+
gs_ohs_xw1h_num_iteration_cl: int
|
|
47
|
+
Maximal number of iterations without improvement in one epoch of the global
|
|
48
|
+
search in each optimization before terminating and continuing with the next
|
|
49
|
+
epoch. For problems with very deep local minima having a very low value is
|
|
50
|
+
helpful. Only used when 1Hot search is defined.
|
|
51
|
+
Default: 100, Min: 0, Max: 1000000
|
|
52
|
+
ohs_xw1h_internal_penalty: int | str
|
|
53
|
+
Mode of 1hot penalty constraint generation.
|
|
54
|
+
- 0: internal penalty generation off: 1hot constraint as part of penalty
|
|
55
|
+
polynomial required
|
|
56
|
+
- 1: internal penalty generation on: 1hot constraint not as part of penalty
|
|
57
|
+
polynomial required
|
|
58
|
+
If 1way 1hot constraint or a 2way 1hot constraint is specified,
|
|
59
|
+
``ohs_xw1h_internal_penalty`` = 1 is recommended.
|
|
60
|
+
Default: 0, Min: 0, Max: 1
|
|
61
|
+
gs_penalty_auto_mode: int
|
|
62
|
+
Parameter to choose whether to automatically incrementally adapt
|
|
63
|
+
``gs_penalty_coef`` to the optimal value.
|
|
64
|
+
- 0: Use ``gs_penalty_coef`` as the fixed factor to weight the penalty
|
|
65
|
+
polynomial during optimization.
|
|
66
|
+
- 1: Start with ``gs_penalty_coef`` as weight factor for penalty polynomial
|
|
67
|
+
and automatically and incrementally increase this factor during
|
|
68
|
+
optimization by multiplying ``gs_penalty_inc_rate`` / 100 repeatedly
|
|
69
|
+
until ``gs_max_penalty_coef`` is reached or the penalty energy iszero.
|
|
70
|
+
Default: 1, Min: 0, Max: 1
|
|
71
|
+
gs_penalty_coef: int
|
|
72
|
+
Factor to weight the penalty polynomial. If ``gs_penalty_auto_mode`` is 0,
|
|
73
|
+
this value does not change. If ``gs_penalty_auto_mode`` is 1, this initial
|
|
74
|
+
weight factor is repeatedly increased by ``gs_penalty_inc_rate`` until
|
|
75
|
+
``gs_max_penalty_coef`` is reached or the penalty energy is zero.
|
|
76
|
+
Default: 1, Min: 1, Max: 9_223_372_036_854_775_807
|
|
77
|
+
gs_penalty_inc_rate: int
|
|
78
|
+
Only used if ``gs_penalty_auto_mode`` is 1. In this case, the initial weight
|
|
79
|
+
factor ``gs_penalty_coef`` for the penalty polynomial is repeatedly
|
|
80
|
+
increased by multiplying ``gs_penalty_inc_rate`` / 100 until
|
|
81
|
+
``gs_max_penalty_coef`` is reached or the penalty energy is zero.
|
|
82
|
+
Default: 150, Min: 100, Max: 200
|
|
83
|
+
gs_max_penalty_coef: int
|
|
84
|
+
Maximal value for the penalty coefficient. If ``gs_penalty_auto_mode`` is 0,
|
|
85
|
+
this is the maximal value for ``gs_penalty_coef``.
|
|
86
|
+
If ``gs_penalty_auto_mode`` is 1, this is the maximal value to which
|
|
87
|
+
``gs_penalty_coef`` can be increased during the automatic adjustment.
|
|
88
|
+
If ``gs_max_penalty_coef`` is set to 0, then the maximal penalty coefficient
|
|
89
|
+
is 2^63 - 1.
|
|
90
|
+
Default: 0, Min: 0, Max: 9_223_372_036_854_775_807
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
scaling_action: Literal["NOTHING", "SCALING", "AUTO_SCALING"]
|
|
94
|
+
Method for scaling ``qubo`` and determining temperatures:
|
|
95
|
+
- "NOTHING": No action (use parameters exactly as specified)
|
|
96
|
+
- "SCALING": ``scaling_factor`` is multiplied to ``qubo``,
|
|
97
|
+
``temperature_start``, ``temperature_end`` and ``offset_increase_rate``.
|
|
98
|
+
- "AUTO_SCALING": A maximum scaling factor w.r.t. ``scaling_bit_precision``
|
|
99
|
+
is multiplied to ``qubo``, ``temperature_start``, ``temperature_end`` and
|
|
100
|
+
``offset_increase_rate``.
|
|
101
|
+
scaling_factor: int | float
|
|
102
|
+
Multiplicative factor applied to model coefficients, temperatures, and other
|
|
103
|
+
parameters: the ``scaling_factor`` for ``qubo``, ``temperature_start``,
|
|
104
|
+
``temperature_end`` and ``offset_increase_rate``.
|
|
105
|
+
Higher values can improve numerical precision but may lead to overflow.
|
|
106
|
+
Default is 1.0 (no scaling).
|
|
107
|
+
scaling_bit_precision: int
|
|
108
|
+
Maximum bit precision to use when scaling. Determines the maximum allowable
|
|
109
|
+
coefficient magnitude. Default is 64, using full double precision.
|
|
110
|
+
random_seed: Union[int, None]
|
|
111
|
+
Seed for random number generation to ensure reproducible results.
|
|
112
|
+
Must be between 0 and 9_999. Default is None (random seed).
|
|
113
|
+
penalty_factor: float
|
|
114
|
+
Penalty factor used to scale the equality constraint penalty function,
|
|
115
|
+
default 1.0.
|
|
116
|
+
inequality_factor: int
|
|
117
|
+
Penalty factor used to scale the inequality constraints, default 1.
|
|
118
|
+
remove_ohg_from_penalty: bool
|
|
119
|
+
If equality constraints, identified to be One-Hot constraints are only
|
|
120
|
+
considered within one-hot groups (`remove_ohg_from_penalty=True`),
|
|
121
|
+
i.e., identified one-hot constraints are not added to the penalty function,
|
|
122
|
+
default True.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
time_limit_sec: int | None = Field(default=None, ge=1, le=3600)
|
|
126
|
+
target_energy: int | None = Field(
|
|
127
|
+
default=None, ge=-99_999_999_999, le=99_999_999_999
|
|
128
|
+
)
|
|
129
|
+
num_group: int = Field(default=1, ge=1, le=16)
|
|
130
|
+
num_solution: int = Field(default=16, ge=1, le=1024)
|
|
131
|
+
num_output_solution: int = Field(default=5, ge=1, le=1024)
|
|
132
|
+
gs_num_iteration_factor: int = Field(default=5, ge=0, le=100)
|
|
133
|
+
gs_num_iteration_cl: int = Field(default=800, ge=0, le=1_000_000)
|
|
134
|
+
gs_ohs_xw1h_num_iteration_factor: int = Field(default=3, ge=0, le=100)
|
|
135
|
+
gs_ohs_xw1h_num_iteration_cl: int = Field(default=100, ge=0, le=1_000_000)
|
|
136
|
+
ohs_xw1h_internal_penalty: int = Field(default=0, ge=0, le=1)
|
|
137
|
+
gs_penalty_auto_mode: int = Field(default=1, ge=0, le=1)
|
|
138
|
+
gs_penalty_coef: int = Field(default=1, ge=1, le=2**63 - 1)
|
|
139
|
+
gs_penalty_inc_rate: int = Field(default=150, ge=100, le=200)
|
|
140
|
+
gs_max_penalty_coef: int = Field(default=0, ge=0, le=2**63 - 1)
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def algorithm_name(self) -> str:
|
|
144
|
+
"""
|
|
145
|
+
Returns the name of the algorithm.
|
|
146
|
+
|
|
147
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
148
|
+
It should provide the name of the algorithm being implemented.
|
|
149
|
+
|
|
150
|
+
Returns
|
|
151
|
+
-------
|
|
152
|
+
str
|
|
153
|
+
The name of the algorithm.
|
|
154
|
+
"""
|
|
155
|
+
return "FDAV3C"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.backends.zib import ZIB
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class SCIP(LunaAlgorithm[ZIB]):
|
|
6
|
+
"""Parameters for the "Solve Constraint Integer Programming" (SCIP) solver."""
|
|
7
|
+
|
|
8
|
+
@property
|
|
9
|
+
def algorithm_name(self) -> str:
|
|
10
|
+
"""
|
|
11
|
+
Returns the name of the algorithm.
|
|
12
|
+
|
|
13
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
14
|
+
It should provide the name of the algorithm being implemented.
|
|
15
|
+
|
|
16
|
+
Returns
|
|
17
|
+
-------
|
|
18
|
+
str
|
|
19
|
+
The name of the algorithm.
|
|
20
|
+
"""
|
|
21
|
+
return "SCIP"
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def get_default_backend(cls) -> ZIB:
|
|
25
|
+
"""
|
|
26
|
+
Return the default backend implementation.
|
|
27
|
+
|
|
28
|
+
This property must be implemented by subclasses to provide
|
|
29
|
+
the default backend instance to use when no specific backend
|
|
30
|
+
is specified.
|
|
31
|
+
|
|
32
|
+
Returns
|
|
33
|
+
-------
|
|
34
|
+
BACKEND_TYPE
|
|
35
|
+
An instance of a class implementing the IBackend interface that serves
|
|
36
|
+
as the default backend.
|
|
37
|
+
"""
|
|
38
|
+
return ZIB()
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def get_compatible_backends(cls) -> tuple[type[ZIB], ...]:
|
|
42
|
+
"""
|
|
43
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
tuple[type[IBackend], ...]
|
|
48
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
return (ZIB,)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .kerberos import Kerberos
|
|
2
|
+
from .leap_hybrid_bqm import LeapHybridBqm
|
|
3
|
+
from .leap_hybrid_cqm import LeapHybridCqm
|
|
4
|
+
from .parallel_tempering_qpu import ParallelTemperingQpu
|
|
5
|
+
from .population_annealing_qpu import PopulationAnnealingQpu
|
|
6
|
+
from .qbsolv_like_qpu import QBSolvLikeQpu
|
|
7
|
+
from .quantum_annealing import QuantumAnnealing
|
|
8
|
+
from .repeated_reverse_quantum_annealing import RepeatedReverseQuantumAnnealing
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Kerberos",
|
|
12
|
+
"LeapHybridBqm",
|
|
13
|
+
"LeapHybridCqm",
|
|
14
|
+
"ParallelTemperingQpu",
|
|
15
|
+
"PopulationAnnealingQpu",
|
|
16
|
+
"QBSolvLikeQpu",
|
|
17
|
+
"QuantumAnnealing",
|
|
18
|
+
"RepeatedReverseQuantumAnnealing",
|
|
19
|
+
]
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
4
|
+
from luna_quantum.solve.parameters.algorithms.base_params import (
|
|
5
|
+
Decomposer,
|
|
6
|
+
QuantumAnnealingParams,
|
|
7
|
+
SimulatedAnnealingBaseParams,
|
|
8
|
+
TabuKerberosParams,
|
|
9
|
+
)
|
|
10
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
11
|
+
from luna_quantum.solve.parameters.constants import (
|
|
12
|
+
DEFAULT_ATOL,
|
|
13
|
+
DEFAULT_RTOL,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Kerberos(
|
|
18
|
+
LunaAlgorithm[DWaveQpu],
|
|
19
|
+
):
|
|
20
|
+
"""
|
|
21
|
+
Kerberos hybrid quantum-classical optimization solver.
|
|
22
|
+
|
|
23
|
+
Kerberos is a sophisticated hybrid solver that decomposes an optimization problem
|
|
24
|
+
into subproblems and solves them using multiple techniques in parallel: Tabu Search,
|
|
25
|
+
Simulated Annealing, and QPU (Quantum Processing Unit) sampling. It then combines
|
|
26
|
+
the results and iteratively refines the solution.
|
|
27
|
+
|
|
28
|
+
This approach leverages both classical and quantum resources efficiently, making it
|
|
29
|
+
effective for large and complex optimization problems beyond the capacity of pure
|
|
30
|
+
quantum approaches.
|
|
31
|
+
|
|
32
|
+
Attributes
|
|
33
|
+
----------
|
|
34
|
+
num_reads: int
|
|
35
|
+
Number of output solutions to generate. Higher values provide better statistical
|
|
36
|
+
coverage of the solution space but increase computational resources required.
|
|
37
|
+
This parameter determines how many distinct solutions the algorithm will return
|
|
38
|
+
after completion. Default is 100.
|
|
39
|
+
num_retries: int
|
|
40
|
+
Number of attempts to retry embedding the problem onto the quantum hardware
|
|
41
|
+
if initial attempts fail. Useful for complex problems that may be challenging
|
|
42
|
+
to map to the quantum processor's topology. Each retry attempts a different
|
|
43
|
+
embedding strategy. Default is 0 (no retries).
|
|
44
|
+
max_iter: int | None
|
|
45
|
+
Maximum number of iterations for the solver. Each iteration involves running
|
|
46
|
+
the three solvers (Tabu, SA, QPU) in parallel, combining their results, and
|
|
47
|
+
refining the solution for the next iteration. Higher values allow more thorough
|
|
48
|
+
exploration and refinement but increase runtime. Default is 100.
|
|
49
|
+
max_time: int
|
|
50
|
+
Maximum time in seconds for the solver to run. Provides a hard time limit
|
|
51
|
+
regardless of convergence or iteration status. Once this time is reached,
|
|
52
|
+
the solver returns the best solution found so far. Default is 5, which may
|
|
53
|
+
need to be increased for large problems.
|
|
54
|
+
convergence: int
|
|
55
|
+
Number of consecutive iterations without improvement before declaring
|
|
56
|
+
convergence. Higher values ensure more stable solutions by requiring consistent
|
|
57
|
+
results across multiple iterations. Default is 3, which balances thoroughness
|
|
58
|
+
with efficiency.
|
|
59
|
+
target: float | None
|
|
60
|
+
Target objective value that triggers termination if reached. Allows early
|
|
61
|
+
stopping when a solution of sufficient quality is found. Default is None,
|
|
62
|
+
which means the algorithm will run until other stopping criteria are met.
|
|
63
|
+
rtol: float
|
|
64
|
+
Relative tolerance for convergence detection. Used when comparing objective
|
|
65
|
+
values between iterations to determine if significant improvement has occurred.
|
|
66
|
+
Smaller values require more substantial improvements to continue. Default is
|
|
67
|
+
DEFAULT_RTOL.
|
|
68
|
+
atol: float
|
|
69
|
+
Absolute tolerance for convergence detection. Used alongside rtol when
|
|
70
|
+
comparing objective values to determine if the algorithm has converged.
|
|
71
|
+
Smaller values enforce stricter convergence criteria. Default is DEFAULT_ATOL.
|
|
72
|
+
quantum_annealing_params: QuantumAnnealingParams
|
|
73
|
+
Nested configuration for quantum annealing parameters used by the QPU component
|
|
74
|
+
of the hybrid solver. Controls aspects like annealing schedule, chain strength,
|
|
75
|
+
and programming thermalization time. These parameters can significantly impact
|
|
76
|
+
the quality of solutions found by the quantum component. Default is a
|
|
77
|
+
QuantumAnnealingParams instance with default settings.
|
|
78
|
+
tabu_kerberos_params: TabuKerberosParams
|
|
79
|
+
Nested configuration for tabu search parameters used by the Tabu component of
|
|
80
|
+
the hybrid solver. Controls aspects like tabu tenure, number of iterations,
|
|
81
|
+
and neighborhood exploration strategy. The Tabu component helps the algorithm
|
|
82
|
+
systematically explore promising regions while avoiding cycles. Default is a
|
|
83
|
+
TabuKerberosParams instance with default settings.
|
|
84
|
+
decomposer: Decomposer
|
|
85
|
+
Decomposer: Breaks down problems into subproblems of manageable size
|
|
86
|
+
Default is a Decomposer instance with default settings.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
num_reads: int = 100
|
|
90
|
+
num_retries: int = 0
|
|
91
|
+
max_iter: int | None = 100
|
|
92
|
+
max_time: int = 5
|
|
93
|
+
convergence: int = 3
|
|
94
|
+
target: float | None = None
|
|
95
|
+
rtol: float = DEFAULT_RTOL
|
|
96
|
+
atol: float = DEFAULT_ATOL
|
|
97
|
+
simulated_annealing_params: SimulatedAnnealingBaseParams = Field(
|
|
98
|
+
default_factory=SimulatedAnnealingBaseParams
|
|
99
|
+
)
|
|
100
|
+
quantum_annealing_params: QuantumAnnealingParams = Field(
|
|
101
|
+
default_factory=QuantumAnnealingParams
|
|
102
|
+
)
|
|
103
|
+
tabu_kerberos_params: TabuKerberosParams = Field(default_factory=TabuKerberosParams)
|
|
104
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def algorithm_name(self) -> str:
|
|
108
|
+
"""
|
|
109
|
+
Returns the name of the algorithm.
|
|
110
|
+
|
|
111
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
112
|
+
It should provide the name of the algorithm being implemented.
|
|
113
|
+
|
|
114
|
+
Returns
|
|
115
|
+
-------
|
|
116
|
+
str
|
|
117
|
+
The name of the algorithm.
|
|
118
|
+
"""
|
|
119
|
+
return "K"
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
123
|
+
"""
|
|
124
|
+
Return the default backend implementation.
|
|
125
|
+
|
|
126
|
+
This property must be implemented by subclasses to provide
|
|
127
|
+
the default backend instance to use when no specific backend
|
|
128
|
+
is specified.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
IBackend
|
|
133
|
+
An instance of a class implementing the IBackend interface that serves
|
|
134
|
+
as the default backend.
|
|
135
|
+
"""
|
|
136
|
+
return DWaveQpu()
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
140
|
+
"""
|
|
141
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
tuple[type[IBackend], ...]
|
|
146
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
147
|
+
|
|
148
|
+
"""
|
|
149
|
+
return (DWaveQpu,)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LeapHybridBqm(LunaAlgorithm[DWaveQpu]):
|
|
6
|
+
"""
|
|
7
|
+
D-Wave's Leap Hybrid Binary Quadratic Model (BQM) solver.
|
|
8
|
+
|
|
9
|
+
Leap's hybrid BQM solver is a cloud-based service that combines quantum and
|
|
10
|
+
classical resources to solve unconstrained binary optimization problems that are
|
|
11
|
+
larger than what can fit directly on a quantum processor. It automatically handles
|
|
12
|
+
decomposition, quantum processing, and solution reconstruction.
|
|
13
|
+
|
|
14
|
+
The hybrid solver is particularly useful for problems with thousands of variables,
|
|
15
|
+
offering better scaling than classical solvers for many problem types.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
time_limit: float | int | None
|
|
20
|
+
Maximum running time in seconds. Longer time limits generally produce better
|
|
21
|
+
solutions but increase resource usage and cost. Default is None, which uses
|
|
22
|
+
the service's default time limit (typically problem-size dependent).
|
|
23
|
+
|
|
24
|
+
Note
|
|
25
|
+
------
|
|
26
|
+
For a D-Wave backend, this will ignore the decompose parameters as the hybrid
|
|
27
|
+
solver handles decomposition internally.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
time_limit: float | int | None = None
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def algorithm_name(self) -> str:
|
|
34
|
+
"""
|
|
35
|
+
Returns the name of the algorithm.
|
|
36
|
+
|
|
37
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
38
|
+
It should provide the name of the algorithm being implemented.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
str
|
|
43
|
+
The name of the algorithm.
|
|
44
|
+
"""
|
|
45
|
+
return "LBQM"
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
49
|
+
"""
|
|
50
|
+
Return the default backend implementation.
|
|
51
|
+
|
|
52
|
+
This property must be implemented by subclasses to provide
|
|
53
|
+
the default backend instance to use when no specific backend
|
|
54
|
+
is specified.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
IBackend
|
|
59
|
+
An instance of a class implementing the IBackend interface that serves
|
|
60
|
+
as the default backend.
|
|
61
|
+
"""
|
|
62
|
+
return DWaveQpu()
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
66
|
+
"""
|
|
67
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
tuple[type[IBackend], ...]
|
|
72
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
73
|
+
|
|
74
|
+
"""
|
|
75
|
+
return (DWaveQpu,)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LeapHybridCqm(LunaAlgorithm[DWaveQpu]):
|
|
6
|
+
"""
|
|
7
|
+
Parameters for D-Wave's Leap Hybrid Constrained Quadratic Model (CQM) solver.
|
|
8
|
+
|
|
9
|
+
The Leap Hybrid CQM solver extends hybrid quantum-classical optimization to handle
|
|
10
|
+
constrained problems, allowing both linear and quadratic constraints alongside
|
|
11
|
+
the quadratic objective function. This enables solving many practical optimization
|
|
12
|
+
problems in their natural formulation without manual penalty conversion.
|
|
13
|
+
|
|
14
|
+
The solver is suitable for mixed binary, integer, and continuous problems with
|
|
15
|
+
thousands of variables and constraints.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
time_limit: float | int | None
|
|
20
|
+
Maximum running time in seconds. Longer limits generally yield better solutions
|
|
21
|
+
but increase resource usage. Default is None, which uses the service's default
|
|
22
|
+
time limit (typically problem-size dependent).
|
|
23
|
+
spin_variables: list[str] | None
|
|
24
|
+
Variables to represent as spins (-1/+1) rather than binary (0/1) values.
|
|
25
|
+
Useful for problems naturally formulated in spin space. Default is None,
|
|
26
|
+
which uses binary representation for all discrete variables.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
time_limit: float | int | None = None
|
|
30
|
+
spin_variables: list[str] | None = None
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def algorithm_name(self) -> str:
|
|
34
|
+
"""
|
|
35
|
+
Returns the name of the algorithm.
|
|
36
|
+
|
|
37
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
38
|
+
It should provide the name of the algorithm being implemented.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
str
|
|
43
|
+
The name of the algorithm.
|
|
44
|
+
"""
|
|
45
|
+
return "LCQM"
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
49
|
+
"""
|
|
50
|
+
Return the default backend implementation.
|
|
51
|
+
|
|
52
|
+
This property must be implemented by subclasses to provide
|
|
53
|
+
the default backend instance to use when no specific backend
|
|
54
|
+
is specified.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
IBackend
|
|
59
|
+
An instance of a class implementing the IBackend interface that serves
|
|
60
|
+
as the default backend.
|
|
61
|
+
"""
|
|
62
|
+
return DWaveQpu()
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
66
|
+
"""
|
|
67
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
tuple[type[IBackend], ...]
|
|
72
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
73
|
+
|
|
74
|
+
"""
|
|
75
|
+
return (DWaveQpu,)
|