luna-quantum 1.0.8rc2__cp314-cp314-manylinux_2_34_x86_64.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.cpython-314-x86_64-linux-gnu.so +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,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,)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.algorithms.base_params import (
|
|
3
|
+
QuantumAnnealingParams,
|
|
4
|
+
)
|
|
5
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QuantumAnnealing(QuantumAnnealingParams, LunaAlgorithm[DWaveQpu]):
|
|
9
|
+
"""
|
|
10
|
+
Quantum Annealing algorithm for physical quantum processors (QPUs).
|
|
11
|
+
|
|
12
|
+
Quantum Annealing is a metaheuristic that leverages quantum effects to find the
|
|
13
|
+
ground state of a system, corresponding to the optimal solution of an optimization
|
|
14
|
+
problem.
|
|
15
|
+
|
|
16
|
+
The process starts in a quantum superposition of all possible states, and gradually
|
|
17
|
+
evolves the system according to a time-dependent Hamiltonian, exploiting quantum
|
|
18
|
+
tunneling to potentially escape local minima more effectively than classical
|
|
19
|
+
methods.
|
|
20
|
+
|
|
21
|
+
This implementation is specifically for D-Wave quantum annealers or similar
|
|
22
|
+
hardware.
|
|
23
|
+
|
|
24
|
+
This class inherits all parameters from QuantumAnnealingParams, providing
|
|
25
|
+
a complete set of controls for the quantum annealing process on hardware devices.
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
anneal_offsets: list[float] | None
|
|
30
|
+
Per-qubit time offsets for the annealing path in normalized annealing time
|
|
31
|
+
units. List of floats with length equal to the number of qubits. Default is
|
|
32
|
+
None.
|
|
33
|
+
anneal_schedule: list[tuple[float, float]] | None
|
|
34
|
+
Custom schedule for the annealing process as a list of (time, s) pairs.
|
|
35
|
+
Time is in normalized units [0, 1] and s is the annealing parameter [0, 1].
|
|
36
|
+
Default is None.
|
|
37
|
+
annealing_time: float | None
|
|
38
|
+
Duration of the annealing process in microseconds. Must be within the range
|
|
39
|
+
supported by the QPU hardware. Default is None.
|
|
40
|
+
auto_scale: bool | None
|
|
41
|
+
Whether to automatically normalize the problem energy range to use the full
|
|
42
|
+
range of h and J values supported by the hardware. Default is None.
|
|
43
|
+
fast_anneal: bool
|
|
44
|
+
Use accelerated annealing protocol for shorter annealing times. Default is
|
|
45
|
+
False.
|
|
46
|
+
flux_biases: list[float] | None
|
|
47
|
+
Custom flux bias offsets for each qubit in units of Φ₀ (flux quantum).
|
|
48
|
+
List length must equal the number of qubits. Default is None.
|
|
49
|
+
flux_drift_compensation: bool
|
|
50
|
+
Whether to compensate for drift in qubit flux over time using real-time
|
|
51
|
+
calibration data. Default is True.
|
|
52
|
+
h_gain_schedule: list[tuple[float, float]] | None
|
|
53
|
+
Schedule for h-gain during annealing as a list of (time, gain) pairs.
|
|
54
|
+
Time is in normalized units [0, 1]. Default is None.
|
|
55
|
+
initial_state: list[int] | None
|
|
56
|
+
Starting state for the annealing process. List of {-1, +1} values with
|
|
57
|
+
length equal to the number of qubits. Default is None.
|
|
58
|
+
max_answers: int | None
|
|
59
|
+
Maximum number of unique answer states to return. Must be ≤ num_reads.
|
|
60
|
+
Default is None.
|
|
61
|
+
num_reads: int
|
|
62
|
+
Number of annealing cycles to perform. Must be positive integer.
|
|
63
|
+
Default is 1.
|
|
64
|
+
programming_thermalization: float | None
|
|
65
|
+
Wait time after programming the QPU in microseconds to allow the system
|
|
66
|
+
to thermalize. Default is None.
|
|
67
|
+
readout_thermalization: float | None
|
|
68
|
+
Wait time after each anneal before reading results in microseconds.
|
|
69
|
+
Default is None.
|
|
70
|
+
reduce_intersample_correlation: bool
|
|
71
|
+
Whether to add delay between samples to reduce correlation between
|
|
72
|
+
consecutive measurements. Default is False.
|
|
73
|
+
reinitialize_state: bool | None
|
|
74
|
+
Whether to reset to a new initial state between reads to reduce correlation.
|
|
75
|
+
Default is None.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def algorithm_name(self) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Returns the name of the algorithm.
|
|
82
|
+
|
|
83
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
84
|
+
It should provide the name of the algorithm being implemented.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
str
|
|
89
|
+
The name of the algorithm.
|
|
90
|
+
"""
|
|
91
|
+
return "QA"
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
95
|
+
"""
|
|
96
|
+
Return the default backend implementation.
|
|
97
|
+
|
|
98
|
+
This property must be implemented by subclasses to provide
|
|
99
|
+
the default backend instance to use when no specific backend
|
|
100
|
+
is specified.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
IBackend
|
|
105
|
+
An instance of a class implementing the IBackend interface that serves
|
|
106
|
+
as the default backend.
|
|
107
|
+
"""
|
|
108
|
+
return DWaveQpu()
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
112
|
+
"""
|
|
113
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
tuple[type[IBackend], ...]
|
|
118
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
return (DWaveQpu,)
|
luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
6
|
+
from luna_quantum.solve.parameters.backends import DWaveQpu
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RepeatedReverseQuantumAnnealing(LunaAlgorithm[DWaveQpu]):
|
|
10
|
+
"""
|
|
11
|
+
Parameters for the Repeated Reverse Quantum Annealing algorithm.
|
|
12
|
+
|
|
13
|
+
This approach combines reverse annealing (starting from a classical state) with
|
|
14
|
+
repetition to refine solutions iteratively. It's particularly useful for:
|
|
15
|
+
1. Local refinement of solutions found by classical methods
|
|
16
|
+
2. Escaping local minima by temporarily increasing quantum fluctuations
|
|
17
|
+
3. Improving solutions through multiple rounds of quantum optimization
|
|
18
|
+
|
|
19
|
+
The process involves:
|
|
20
|
+
- Starting with classical initial states
|
|
21
|
+
- Partially "unsolving" them by increasing quantum fluctuations
|
|
22
|
+
- Re-annealing to find potentially better nearby solutions
|
|
23
|
+
- Repeating with the best solutions found
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
anneal_offsets: Any | None
|
|
28
|
+
Per-qubit time offsets for the annealing path, allowing qubits to anneal at
|
|
29
|
+
different rates. Useful for problems with varying energy scales or when certain
|
|
30
|
+
qubits need different annealing trajectories. Default is None, which uses
|
|
31
|
+
standard annealing for all qubits.
|
|
32
|
+
annealing_time: Any | None
|
|
33
|
+
Duration of the annealing process in microseconds. Longer times can improve
|
|
34
|
+
solution quality for problems with small energy gaps but increase runtime.
|
|
35
|
+
Default is None, which uses the QPU's default annealing time.
|
|
36
|
+
auto_scale: Any | None
|
|
37
|
+
Whether to automatically normalize the problem energy range to match hardware
|
|
38
|
+
capabilities, preventing precision issues in the physical implementation.
|
|
39
|
+
Default is None, which uses the D-Wave system's default setting.
|
|
40
|
+
flux_biases: Any | None
|
|
41
|
+
Custom flux bias offsets for each qubit to compensate for manufacturing
|
|
42
|
+
variations in the QPU hardware or to intentionally bias certain qubits.
|
|
43
|
+
Default is None, using standard calibration values.
|
|
44
|
+
flux_drift_compensation: bool
|
|
45
|
+
Whether to compensate for drift in qubit flux over time, improving the
|
|
46
|
+
reliability and consistency of results across multiple runs.
|
|
47
|
+
Default is True, which is recommended for most applications.
|
|
48
|
+
h_gain_schedule: Any | None
|
|
49
|
+
Schedule for h-gain (linear coefficient strength) during annealing,
|
|
50
|
+
allowing dynamic adjustment of problem coefficients throughout the process.
|
|
51
|
+
Default is None, using standard gain settings.
|
|
52
|
+
max_answers: int | None
|
|
53
|
+
Maximum number of unique answer states to return from the quantum hardware.
|
|
54
|
+
Useful for collecting diverse solutions while filtering out duplicates.
|
|
55
|
+
Must be greater than or equal to 1 if specified. Default is None, which returns
|
|
56
|
+
all unique solutions found.
|
|
57
|
+
programming_thermalization: float | None
|
|
58
|
+
Wait time (in microseconds) after programming the QPU, allowing it to
|
|
59
|
+
reach thermal equilibrium before starting the annealing process.
|
|
60
|
+
Must be positive if specified. Default is None, using system default.
|
|
61
|
+
readout_thermalization: float | None
|
|
62
|
+
Wait time (in microseconds) after each anneal before reading results.
|
|
63
|
+
Helps ensure the qubits have settled into their final states before measurement.
|
|
64
|
+
Must be positive if specified. Default is None, using system default.
|
|
65
|
+
reduce_intersample_correlation: bool
|
|
66
|
+
Whether to add delay between samples to reduce temporal correlations
|
|
67
|
+
that might bias results across multiple runs. Default is False to minimize
|
|
68
|
+
runtime, but can be set to True when sample independence is critical.
|
|
69
|
+
initial_states: list[dict[str, int]] | None
|
|
70
|
+
Initial classical states to start the reverse annealing from, specified as
|
|
71
|
+
dictionaries mapping variable names to binary values (0 or 1). For each state,
|
|
72
|
+
one call to the sampler with parameter `initial_state=state` will be made
|
|
73
|
+
in the first iteration. Default is None, in which case random or specified
|
|
74
|
+
states are generated according to n_initial_states.
|
|
75
|
+
n_initial_states: int
|
|
76
|
+
Number of initial states to create when `initial_states` is None.
|
|
77
|
+
Controls the diversity of starting points for the algorithm.
|
|
78
|
+
Ignored if `initial_states` is provided. Default is 1. Must be ≥1.
|
|
79
|
+
samples_per_state: int
|
|
80
|
+
How many samples to create per state in each iteration after the first.
|
|
81
|
+
More samples increase the chance of finding improvements but use more QPU time.
|
|
82
|
+
Controls the breadth of exploration around each promising solution.
|
|
83
|
+
Default is 1. Must be ≥1.
|
|
84
|
+
beta_schedule: list[float]
|
|
85
|
+
Beta schedule controlling the quantum fluctuation strength during reverse
|
|
86
|
+
annealing. Beta is the inverse temperature (1/T), with lower values allowing
|
|
87
|
+
more thermal excitation to explore the energy landscape more widely.
|
|
88
|
+
Default [0.5, 3] provides moderate initial fluctuation followed by cooling,
|
|
89
|
+
balancing exploration and exploitation.
|
|
90
|
+
timeout: float
|
|
91
|
+
Maximum runtime in seconds before the solver stops, regardless of convergence.
|
|
92
|
+
Provides a hard time limit to ensure the algorithm completes within a reasonable
|
|
93
|
+
timeframe. Default is 300 seconds (5 minutes), balancing solution quality with
|
|
94
|
+
timeliness.
|
|
95
|
+
max_iter: int
|
|
96
|
+
Maximum number of iterations (reverse annealing cycles) to perform.
|
|
97
|
+
Each iteration refines the solutions from the previous round, potentially
|
|
98
|
+
discovering better solutions in the neighborhood of good candidates.
|
|
99
|
+
Default is 10, providing good refinement without excessive QPU usage.
|
|
100
|
+
target: Any | None
|
|
101
|
+
Target energy value that, if reached, causes the algorithm to terminate early.
|
|
102
|
+
Allows for early stopping when a sufficiently good solution is found.
|
|
103
|
+
Default is None (run until other stopping criteria are met).
|
|
104
|
+
check_trivial: bool
|
|
105
|
+
Whether to check for and handle trivial variables (those without interactions)
|
|
106
|
+
before sending the problem to the QPU. Adds some computational overhead but
|
|
107
|
+
prevents potential runtime errors and improves embedding efficiency.
|
|
108
|
+
Default is True, which is recommended for robust operation.
|
|
109
|
+
"""
|
|
110
|
+
|
|
111
|
+
anneal_offsets: Any | None = None
|
|
112
|
+
annealing_time: Any | None = None
|
|
113
|
+
auto_scale: Any | None = None
|
|
114
|
+
flux_biases: Any | None = None
|
|
115
|
+
flux_drift_compensation: bool = True
|
|
116
|
+
h_gain_schedule: Any | None = None
|
|
117
|
+
max_answers: int | None = Field(default=None, ge=1)
|
|
118
|
+
programming_thermalization: float | None = Field(default=None, gt=0)
|
|
119
|
+
readout_thermalization: float | None = Field(default=None, gt=0)
|
|
120
|
+
reduce_intersample_correlation: bool = False
|
|
121
|
+
|
|
122
|
+
initial_states: list[dict[str, int]] | None = None
|
|
123
|
+
n_initial_states: int = Field(default=1, ge=1)
|
|
124
|
+
samples_per_state: int = Field(default=1, ge=1)
|
|
125
|
+
beta_schedule: list[float] = Field(default_factory=lambda: [0.5, 3])
|
|
126
|
+
timeout: float = 300
|
|
127
|
+
max_iter: int = 10
|
|
128
|
+
target: Any | None = None
|
|
129
|
+
check_trivial: bool = True
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def algorithm_name(self) -> str:
|
|
133
|
+
"""
|
|
134
|
+
Returns the name of the algorithm.
|
|
135
|
+
|
|
136
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
137
|
+
It should provide the name of the algorithm being implemented.
|
|
138
|
+
|
|
139
|
+
Returns
|
|
140
|
+
-------
|
|
141
|
+
str
|
|
142
|
+
The name of the algorithm.
|
|
143
|
+
"""
|
|
144
|
+
return "RRQA"
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def get_default_backend(cls) -> DWaveQpu:
|
|
148
|
+
"""
|
|
149
|
+
Return the default backend implementation.
|
|
150
|
+
|
|
151
|
+
This property must be implemented by subclasses to provide
|
|
152
|
+
the default backend instance to use when no specific backend
|
|
153
|
+
is specified.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
IBackend
|
|
158
|
+
An instance of a class implementing the IBackend interface that serves
|
|
159
|
+
as the default backend.
|
|
160
|
+
"""
|
|
161
|
+
return DWaveQpu()
|
|
162
|
+
|
|
163
|
+
@classmethod
|
|
164
|
+
def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
|
|
165
|
+
"""
|
|
166
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
tuple[type[IBackend], ...]
|
|
171
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
return (DWaveQpu,)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .config import AdvancedConfig, XYMixer
|
|
2
|
+
from .flex_qaoa import FlexQAOA
|
|
3
|
+
from .optimizers import (
|
|
4
|
+
CombinedOptimizerParams,
|
|
5
|
+
InterpolateOptimizerParams,
|
|
6
|
+
LinearOptimizerParams,
|
|
7
|
+
)
|
|
8
|
+
from .pipeline import (
|
|
9
|
+
IndicatorFunctionParams,
|
|
10
|
+
OneHotParams,
|
|
11
|
+
PipelineParams,
|
|
12
|
+
QuadraticPenaltyParams,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"AdvancedConfig",
|
|
17
|
+
"CombinedOptimizerParams",
|
|
18
|
+
"FlexQAOA",
|
|
19
|
+
"IndicatorFunctionParams",
|
|
20
|
+
"InterpolateOptimizerParams",
|
|
21
|
+
"LinearOptimizerParams",
|
|
22
|
+
"OneHotParams",
|
|
23
|
+
"PipelineParams",
|
|
24
|
+
"QuadraticPenaltyParams",
|
|
25
|
+
"XYMixer",
|
|
26
|
+
]
|