luna-quantum 1.0.0__cp313-cp313-macosx_11_0_arm64.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 +96 -0
- luna_quantum/__init__.pyi +68 -0
- luna_quantum/_core.cpython-313-darwin.so +0 -0
- luna_quantum/_core.pyi +3017 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -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 +153 -0
- luna_quantum/client/controllers/luna_q.py +62 -0
- luna_quantum/client/controllers/luna_solve.py +125 -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 +36 -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 +76 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +504 -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 +49 -0
- luna_quantum/client/schemas/create/__init__.py +6 -0
- luna_quantum/client/schemas/create/circuit.py +31 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +25 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +29 -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 +161 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +28 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +135 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +47 -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/errors.py +1 -0
- luna_quantum/errors.pyi +202 -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 +75 -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 +203 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +54 -0
- luna_quantum/solve/domain/solve_job.py +187 -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 +47 -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 +49 -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 +78 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +120 -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/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 +105 -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 +97 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +104 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +109 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +152 -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 +20 -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 +164 -0
- luna_quantum/solve/parameters/backends/ibm.py +132 -0
- luna_quantum/solve/parameters/backends/qctrl.py +130 -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 +56 -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 +97 -0
- luna_quantum/translator.py +1 -0
- luna_quantum/translator.pyi +833 -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/log_utils.py +167 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +54 -0
- luna_quantum/utils.pyi +35 -0
- luna_quantum-1.0.0.dist-info/METADATA +37 -0
- luna_quantum-1.0.0.dist-info/RECORD +252 -0
- luna_quantum-1.0.0.dist-info/WHEEL +4 -0
- luna_quantum-1.0.0.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.0.0.dist-info/licenses/NOTICE +13 -0
|
@@ -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,)
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
)
|
|
8
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
9
|
+
from luna_quantum.solve.parameters.constants import DEFAULT_ATOL, DEFAULT_RTOL
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ParallelTemperingQpu(
|
|
13
|
+
LunaAlgorithm[DWaveQpu],
|
|
14
|
+
):
|
|
15
|
+
"""
|
|
16
|
+
Parameters for the Parallel Tempering QPU solver.
|
|
17
|
+
|
|
18
|
+
Parallel Tempering uses multiple model procedures per temperature.
|
|
19
|
+
During the cooling process, an exchange of replicas can take place between the
|
|
20
|
+
parallel procedures, thus enabling higher energy mountains to be overcome.
|
|
21
|
+
|
|
22
|
+
Attributes
|
|
23
|
+
----------
|
|
24
|
+
n_replicas: int
|
|
25
|
+
Number of system replicas to simulate at different temperatures. More replicas
|
|
26
|
+
provide better temperature coverage but increase computational cost.
|
|
27
|
+
Default is 2, which is minimal but can still provide benefits over
|
|
28
|
+
single-temperature methods.
|
|
29
|
+
random_swaps_factor: int
|
|
30
|
+
Factor controlling how frequently random swap attempts occur between replicas.
|
|
31
|
+
Higher values increase mixing between replicas but add overhead.
|
|
32
|
+
Default is 1, balancing mixing with efficiency.
|
|
33
|
+
max_iter: int | None
|
|
34
|
+
Maximum number of iterations. Controls how many rounds of replica exchange
|
|
35
|
+
are performed. Higher values allow more thorough exploration.
|
|
36
|
+
Default is 100.
|
|
37
|
+
max_time: int
|
|
38
|
+
Maximum time in seconds that the algorithm is allowed to run.
|
|
39
|
+
Default is 5.
|
|
40
|
+
convergence: int
|
|
41
|
+
Number of consecutive iterations with no improvement required to consider
|
|
42
|
+
the algorithm converged. Default is 3.
|
|
43
|
+
target: float | None
|
|
44
|
+
Target energy value. If reached, the algorithm will terminate.
|
|
45
|
+
Default is None, meaning no target is set.
|
|
46
|
+
rtol: float
|
|
47
|
+
Relative tolerance for convergence checking. Default is DEFAULT_RTOL.
|
|
48
|
+
atol: float
|
|
49
|
+
Absolute tolerance for convergence checking. Default is DEFAULT_ATOL.
|
|
50
|
+
num_reads: int
|
|
51
|
+
Number of annealing cycles to perform on the D-Wave QPU. Default is 100.
|
|
52
|
+
num_retries: int
|
|
53
|
+
Number of attempts to retry embedding the problem onto the quantum hardware.
|
|
54
|
+
Default is 0.
|
|
55
|
+
fixed_temp_sampler_num_sweeps: int
|
|
56
|
+
Number of Monte Carlo sweeps to perform, where one sweep attempts to update all
|
|
57
|
+
variables once. More sweeps produce better equilibrated samples but increase
|
|
58
|
+
computation time. Default is 10,000, which is suitable for thorough exploration
|
|
59
|
+
of moderate-sized problems.
|
|
60
|
+
fixed_temp_sampler_num_reads: int | None
|
|
61
|
+
Number of independent sampling runs to perform. Each run produces one sample
|
|
62
|
+
from the equilibrium distribution. Multiple reads provide better statistical
|
|
63
|
+
coverage of the solution space. Default is None, which typically defaults to 1
|
|
64
|
+
or matches the number of initial states provided.
|
|
65
|
+
quantum_annealing_params: QuantumAnnealingParams
|
|
66
|
+
Configuration for the quantum annealing process on D-Wave hardware.
|
|
67
|
+
Contains settings for anneal schedule, flux biases, and other QPU-specific
|
|
68
|
+
parameters. See QuantumAnnealingParams documentation for details.
|
|
69
|
+
decomposer: Decomposer
|
|
70
|
+
Decomposer: Breaks down problems into subproblems of manageable size
|
|
71
|
+
Default is a Decomposer instance with default settings.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
n_replicas: int = 2
|
|
75
|
+
random_swaps_factor: int = 1
|
|
76
|
+
max_iter: int | None = 100
|
|
77
|
+
max_time: int = 5
|
|
78
|
+
convergence: int = 3
|
|
79
|
+
target: float | None = None
|
|
80
|
+
rtol: float = DEFAULT_RTOL
|
|
81
|
+
atol: float = DEFAULT_ATOL
|
|
82
|
+
|
|
83
|
+
num_reads: int = 100
|
|
84
|
+
num_retries: int = 0
|
|
85
|
+
|
|
86
|
+
fixed_temp_sampler_num_sweeps: int = 10_000
|
|
87
|
+
fixed_temp_sampler_num_reads: int | None = None
|
|
88
|
+
|
|
89
|
+
quantum_annealing_params: QuantumAnnealingParams = Field(
|
|
90
|
+
default_factory=QuantumAnnealingParams
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
94
|
+
|
|
95
|
+
# does not support random_swaps_factor variable of parallel tempering parameters
|
|
96
|
+
@property
|
|
97
|
+
def algorithm_name(self) -> str:
|
|
98
|
+
"""
|
|
99
|
+
Returns the name of the algorithm.
|
|
100
|
+
|
|
101
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
102
|
+
It should provide the name of the algorithm being implemented.
|
|
103
|
+
|
|
104
|
+
Returns
|
|
105
|
+
-------
|
|
106
|
+
str
|
|
107
|
+
The name of the algorithm.
|
|
108
|
+
"""
|
|
109
|
+
return "PTQ"
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
113
|
+
"""
|
|
114
|
+
Return the default backend implementation.
|
|
115
|
+
|
|
116
|
+
This property must be implemented by subclasses to provide
|
|
117
|
+
the default backend instance to use when no specific backend
|
|
118
|
+
is specified.
|
|
119
|
+
|
|
120
|
+
Returns
|
|
121
|
+
-------
|
|
122
|
+
IBackend
|
|
123
|
+
An instance of a class implementing the IBackend interface that serves
|
|
124
|
+
as the default backend.
|
|
125
|
+
"""
|
|
126
|
+
return DWaveQpu()
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
130
|
+
"""
|
|
131
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
tuple[type[IBackend], ...]
|
|
136
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
return (DWaveQpu,)
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
)
|
|
8
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PopulationAnnealingQpu(LunaAlgorithm[DWaveQpu]):
|
|
12
|
+
"""
|
|
13
|
+
Parameters for the Population Annealing QPU algorithm.
|
|
14
|
+
|
|
15
|
+
Population Annealing uses a sequential Monte Carlo method to minimize the energy of
|
|
16
|
+
a population. The population consists of walkers that can explore their
|
|
17
|
+
neighborhood during the cooling process. Afterwards, walkers are removed and
|
|
18
|
+
duplicated using bias to lower energy. Eventually, a population collapse occurs
|
|
19
|
+
where all walkers are in the lowest energy state.
|
|
20
|
+
|
|
21
|
+
Attributes
|
|
22
|
+
----------
|
|
23
|
+
num_reads: int
|
|
24
|
+
Number of annealing cycles to perform on the D-Wave QPU. Default is 100.
|
|
25
|
+
num_retries: int
|
|
26
|
+
Number of attempts to retry embedding the problem onto the quantum hardware.
|
|
27
|
+
Default is 0.
|
|
28
|
+
max_iter: int
|
|
29
|
+
Maximum number of iterations. Controls how many rounds of annealing and
|
|
30
|
+
population adjustments are performed. Default is 20.
|
|
31
|
+
max_time: int
|
|
32
|
+
Maximum time in seconds that the algorithm is allowed to run. Serves as
|
|
33
|
+
a stopping criterion alongside max_iter. Default is 2.
|
|
34
|
+
fixed_temp_sampler_num_sweeps: int
|
|
35
|
+
Number of Monte Carlo sweeps to perform, where one sweep attempts to update all
|
|
36
|
+
variables once. More sweeps produce better equilibrated samples but increase
|
|
37
|
+
computation time. Default is 10,000, which is suitable for thorough exploration
|
|
38
|
+
of moderate-sized problems.
|
|
39
|
+
fixed_temp_sampler_num_reads: int | None
|
|
40
|
+
Number of independent sampling runs to perform. Each run produces one sample
|
|
41
|
+
from the equilibrium distribution. Multiple reads provide better statistical
|
|
42
|
+
coverage of the solution space. Default is None, which typically defaults to 1
|
|
43
|
+
or matches the number of initial states provided.
|
|
44
|
+
decomposer: Decomposer
|
|
45
|
+
Decomposer: Breaks down problems into subproblems of manageable size
|
|
46
|
+
Default is a Decomposer instance with default settings.
|
|
47
|
+
quantum_annealing_params: QuantumAnnealingParams
|
|
48
|
+
Parameters that control the quantum annealing process, including annealing
|
|
49
|
+
schedule, temperature settings, and other quantum-specific parameters. These
|
|
50
|
+
settings determine how the system transitions from quantum superposition to
|
|
51
|
+
classical states during the optimization process.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
num_reads: int = 100
|
|
55
|
+
num_retries: int = 0
|
|
56
|
+
max_iter: int = 20
|
|
57
|
+
max_time: int = 2
|
|
58
|
+
fixed_temp_sampler_num_sweeps: int = 10_000
|
|
59
|
+
fixed_temp_sampler_num_reads: int | None = None
|
|
60
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
61
|
+
|
|
62
|
+
quantum_annealing_params: QuantumAnnealingParams = Field(
|
|
63
|
+
default_factory=QuantumAnnealingParams
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def algorithm_name(self) -> str:
|
|
68
|
+
"""
|
|
69
|
+
Returns the name of the algorithm.
|
|
70
|
+
|
|
71
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
72
|
+
It should provide the name of the algorithm being implemented.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
str
|
|
77
|
+
The name of the algorithm.
|
|
78
|
+
"""
|
|
79
|
+
return "PAQ"
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
83
|
+
"""
|
|
84
|
+
Return the default backend implementation.
|
|
85
|
+
|
|
86
|
+
This property must be implemented by subclasses to provide
|
|
87
|
+
the default backend instance to use when no specific backend
|
|
88
|
+
is specified.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
IBackend
|
|
93
|
+
An instance of a class implementing the IBackend interface that serves
|
|
94
|
+
as the default backend.
|
|
95
|
+
"""
|
|
96
|
+
return DWaveQpu()
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
100
|
+
"""
|
|
101
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
tuple[type[IBackend], ...]
|
|
106
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
107
|
+
|
|
108
|
+
"""
|
|
109
|
+
return (DWaveQpu,)
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
)
|
|
8
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
9
|
+
from luna_quantum.solve.parameters.mixins.qbsolv_like_mixin import QBSolvLikeMixin
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class QBSolvLikeQpu(QBSolvLikeMixin, LunaAlgorithm[DWaveQpu]):
|
|
13
|
+
"""
|
|
14
|
+
QBSolv-like algorithm for QPU.
|
|
15
|
+
|
|
16
|
+
QBSolv QPU splits the problem into parts and solves them using the Tabu Search
|
|
17
|
+
algorithm. For this purpose, the DWaveSampler is used.
|
|
18
|
+
|
|
19
|
+
Attributes
|
|
20
|
+
----------
|
|
21
|
+
decomposer_size: int
|
|
22
|
+
Size for the decomposer. Determines the maximum subproblem size to be sent to
|
|
23
|
+
the quantum processor, with larger values potentially improving solution quality
|
|
24
|
+
at the cost of increased processing time.
|
|
25
|
+
rolling: bool
|
|
26
|
+
Whether to use rolling for the solver. When enabled, this allows for smoother
|
|
27
|
+
transitions between subproblems during the decomposition process.
|
|
28
|
+
rolling_history: float
|
|
29
|
+
Rolling history parameter for the solver. Controls how much previous iteration
|
|
30
|
+
information is considered when solving subsequent subproblems.
|
|
31
|
+
max_iter: int | None
|
|
32
|
+
Maximum number of iterations. Limits the total number of decomposition and
|
|
33
|
+
solving cycles performed by the algorithm.
|
|
34
|
+
max_time: int
|
|
35
|
+
Time in seconds after which the algorithm will stop. Provides a time-based
|
|
36
|
+
stopping criterion regardless of convergence status.
|
|
37
|
+
convergence: int
|
|
38
|
+
Number of iterations with unchanged output to terminate algorithm. Higher values
|
|
39
|
+
ensure more stable solutions but may increase computation time.
|
|
40
|
+
target: float | None
|
|
41
|
+
Energy level that the algorithm tries to reach. If this target energy is
|
|
42
|
+
achieved, the algorithm will terminate early.
|
|
43
|
+
rtol: float
|
|
44
|
+
Relative tolerance for convergence. Used when comparing energy values between
|
|
45
|
+
iterations to determine if convergence has been reached.
|
|
46
|
+
atol: float
|
|
47
|
+
Absolute tolerance for convergence. Used alongside rtol when comparing energy
|
|
48
|
+
values to determine convergence.
|
|
49
|
+
num_reads: int
|
|
50
|
+
Number of reads for the solver.
|
|
51
|
+
num_retries: int
|
|
52
|
+
Number of retries for the solver.
|
|
53
|
+
quantum_annealing_params: QuantumAnnealingParams
|
|
54
|
+
Quantum annealing parameters.
|
|
55
|
+
decomposer: Decomposer
|
|
56
|
+
Decomposer: Breaks down problems into subproblems of manageable size
|
|
57
|
+
Default is a Decomposer instance with default settings.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
num_reads: int = 100
|
|
61
|
+
num_retries: int = 0
|
|
62
|
+
|
|
63
|
+
quantum_annealing_params: QuantumAnnealingParams = Field(
|
|
64
|
+
default_factory=QuantumAnnealingParams
|
|
65
|
+
)
|
|
66
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def algorithm_name(self) -> str:
|
|
70
|
+
"""
|
|
71
|
+
Returns the name of the algorithm.
|
|
72
|
+
|
|
73
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
74
|
+
It should provide the name of the algorithm being implemented.
|
|
75
|
+
|
|
76
|
+
Returns
|
|
77
|
+
-------
|
|
78
|
+
str
|
|
79
|
+
The name of the algorithm.
|
|
80
|
+
"""
|
|
81
|
+
return "QLQ"
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
85
|
+
"""
|
|
86
|
+
Return the default backend implementation.
|
|
87
|
+
|
|
88
|
+
This property must be implemented by subclasses to provide
|
|
89
|
+
the default backend instance to use when no specific backend
|
|
90
|
+
is specified.
|
|
91
|
+
|
|
92
|
+
Returns
|
|
93
|
+
-------
|
|
94
|
+
IBackend
|
|
95
|
+
An instance of a class implementing the IBackend interface that serves
|
|
96
|
+
as the default backend.
|
|
97
|
+
"""
|
|
98
|
+
return DWaveQpu()
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
102
|
+
"""
|
|
103
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
tuple[type[IBackend], ...]
|
|
108
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
return (DWaveQpu,)
|