luna-quantum 1.1.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- luna_quantum/__init__.py +139 -0
- luna_quantum/__init__.pyi +98 -0
- luna_quantum/_core.cp312-win_amd64.pyd +0 -0
- luna_quantum/_core.pyi +4286 -0
- luna_quantum/_utility.py +148 -0
- luna_quantum/_utility.pyi +20 -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/luna_quantum_call_type_error.py +9 -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 +489 -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 +230 -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 +59 -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_by_id_usecase_i.py +27 -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 +10 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/__init__.py +29 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/config.py +58 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/flexqaoa.py +188 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/optimizers.py +53 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/pipeline.py +164 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +112 -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 +27 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aqarios_gpu.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/cudaq/__init__.py +5 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_base.py +16 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_cpu.py +30 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_gpu.py +32 -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/errors.py +30 -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_by_id_usecase.py +44 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +105 -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.1.0.dist-info/METADATA +36 -0
- luna_quantum-1.1.0.dist-info/RECORD +276 -0
- luna_quantum-1.1.0.dist-info/WHEEL +4 -0
- luna_quantum-1.1.0.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.1.0.dist-info/licenses/NOTICE +13 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
4
|
+
from luna_quantum.solve.parameters.algorithms.base_params.qaoa_circuit_params import (
|
|
5
|
+
BasicQAOAParams,
|
|
6
|
+
LinearQAOAParams,
|
|
7
|
+
RandomQAOAParams,
|
|
8
|
+
)
|
|
9
|
+
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import (
|
|
10
|
+
ScipyOptimizerParams,
|
|
11
|
+
)
|
|
12
|
+
from luna_quantum.solve.parameters.backends import (
|
|
13
|
+
AWS,
|
|
14
|
+
IBM,
|
|
15
|
+
IQM,
|
|
16
|
+
CudaqCpu,
|
|
17
|
+
CudaqGpu,
|
|
18
|
+
IonQ,
|
|
19
|
+
Rigetti,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class QAOA(LunaAlgorithm[AWS | IonQ | IQM | Rigetti | IBM | CudaqCpu | CudaqGpu]):
|
|
24
|
+
"""
|
|
25
|
+
Quantum Approximate Optimization Algorithm (QAOA).
|
|
26
|
+
|
|
27
|
+
QAOA is a hybrid quantum-classical algorithm for solving combinatorial optimization
|
|
28
|
+
problems. It works by preparing a quantum state through alternating applications of
|
|
29
|
+
problem-specific (cost) and mixing Hamiltonians, controlled by variational
|
|
30
|
+
parameters that are optimized classically to maximize the probability of measuring
|
|
31
|
+
the optimal solution.
|
|
32
|
+
|
|
33
|
+
QAOA is particularly suited for problems that can be encoded as quadratic
|
|
34
|
+
unconstrained binary optimization (QUBO) or Ising models, such as MaxCut, TSP, and
|
|
35
|
+
portfolio optimization.
|
|
36
|
+
|
|
37
|
+
Attributes
|
|
38
|
+
----------
|
|
39
|
+
reps : int
|
|
40
|
+
Number of QAOA layers (p). Each layer consists of applying both the cost and
|
|
41
|
+
mixing Hamiltonians with different variational parameters. Higher values
|
|
42
|
+
generally lead to better solutions but increase circuit depth and quantum
|
|
43
|
+
resources required. Default is 1.
|
|
44
|
+
shots : int
|
|
45
|
+
Number of measurement samples to collect per circuit execution. Higher values
|
|
46
|
+
reduce statistical noise but increase runtime. Default is 1024.
|
|
47
|
+
optimizer : ScipyOptimizerParams
|
|
48
|
+
Configuration for the classical optimization routine that updates the
|
|
49
|
+
variational parameters. Default is a ScipyOptimizer instance with default
|
|
50
|
+
settings. See ScipyOptimizerParams class for details of contained parameters.
|
|
51
|
+
initial_params: LinearQAOAParams | BasicQAOAParams | RandomQAOAParams
|
|
52
|
+
Custom QAOA variational circuit parameters. By default linear
|
|
53
|
+
increasing/decreasing parameters for the selected `reps` are generated.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
reps: int = Field(default=1, ge=1)
|
|
57
|
+
shots: int = Field(default=1024, ge=1)
|
|
58
|
+
optimizer: ScipyOptimizerParams = Field(
|
|
59
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
60
|
+
)
|
|
61
|
+
initial_params: RandomQAOAParams | BasicQAOAParams | LinearQAOAParams = Field(
|
|
62
|
+
default_factory=lambda: LinearQAOAParams(delta_beta=0.5, delta_gamma=0.5)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def algorithm_name(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Returns the name of the algorithm.
|
|
69
|
+
|
|
70
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
71
|
+
It should provide the name of the algorithm being implemented.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
str
|
|
76
|
+
The name of the algorithm.
|
|
77
|
+
"""
|
|
78
|
+
return "QAOA"
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def get_default_backend(
|
|
82
|
+
cls,
|
|
83
|
+
) -> AWS | IonQ | IQM | Rigetti | IBM | CudaqCpu | CudaqGpu:
|
|
84
|
+
"""
|
|
85
|
+
Return the default backend implementation.
|
|
86
|
+
|
|
87
|
+
This property must be implemented by subclasses to provide
|
|
88
|
+
the default backend instance to use when no specific backend
|
|
89
|
+
is specified.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
IBackend
|
|
94
|
+
An instance of a class implementing the IBackend interface that serves
|
|
95
|
+
as the default backend.
|
|
96
|
+
"""
|
|
97
|
+
return IBM()
|
|
98
|
+
|
|
99
|
+
@classmethod
|
|
100
|
+
def get_compatible_backends(
|
|
101
|
+
cls,
|
|
102
|
+
) -> tuple[type[AWS | IonQ | IQM | Rigetti | IBM | CudaqCpu | CudaqGpu], ...]:
|
|
103
|
+
"""
|
|
104
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
tuple[type[IBackend], ...]
|
|
109
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
return AWS, IonQ, IQM, Rigetti, IBM, CudaqCpu, CudaqGpu
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.backends import Qctrl
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class QAOA_FO(LunaAlgorithm[Qctrl]): # noqa: N801
|
|
6
|
+
"""
|
|
7
|
+
Quantum Approximate Optimization Algorithm via Fire Opal (QAOA_FO).
|
|
8
|
+
|
|
9
|
+
QAOA_FO is Q-CTRL's implementation of the Quantum Approximate Optimization Algorithm
|
|
10
|
+
(QAOA) through their Fire Opal framework. It is a hybrid quantum-classical algorithm
|
|
11
|
+
for solving combinatorial optimization problems with enhanced performance through
|
|
12
|
+
Q-CTRL's error mitigation and control techniques. For more details, please refer
|
|
13
|
+
to the `Fire Opal QAOA documentation <https://docs.q-ctrl.com/fire-opal/execute/run-algorithms/solve-optimization-problems/fire-opals-qaoa-solver>`_.
|
|
14
|
+
|
|
15
|
+
The algorithm works by preparing a quantum state through alternating applications of
|
|
16
|
+
problem-specific (cost) and mixing Hamiltonians, controlled by variational
|
|
17
|
+
parameters that are optimized classically to maximize the probability of measuring
|
|
18
|
+
the optimal solution.
|
|
19
|
+
|
|
20
|
+
QAOA_FO leverages Q-CTRL's expertise in quantum control to improve circuit fidelity
|
|
21
|
+
and optimization performance. It is particularly suited for problems that can be
|
|
22
|
+
encoded as quadratic unconstrained binary optimization (QUBO) or Ising models,
|
|
23
|
+
such as MaxCut, TSP, and portfolio optimization.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def algorithm_name(self) -> str:
|
|
28
|
+
"""
|
|
29
|
+
Returns the name of the algorithm.
|
|
30
|
+
|
|
31
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
32
|
+
It should provide the name of the algorithm being implemented.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
str
|
|
37
|
+
The name of the algorithm.
|
|
38
|
+
"""
|
|
39
|
+
return "QAOA_FO"
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def get_default_backend(cls) -> Qctrl:
|
|
43
|
+
"""
|
|
44
|
+
Return the default backend implementation.
|
|
45
|
+
|
|
46
|
+
This property must be implemented by subclasses to provide
|
|
47
|
+
the default backend instance to use when no specific backend
|
|
48
|
+
is specified.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
IBackend
|
|
53
|
+
An instance of a class implementing the IBackend interface that serves
|
|
54
|
+
as the default backend.
|
|
55
|
+
"""
|
|
56
|
+
return Qctrl()
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def get_compatible_backends(cls) -> tuple[type[Qctrl]]:
|
|
60
|
+
"""
|
|
61
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
tuple[type[IBackend], ...]
|
|
66
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
return (Qctrl,)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import math
|
|
2
|
+
from typing import Any, Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
7
|
+
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import (
|
|
8
|
+
ScipyOptimizerParams,
|
|
9
|
+
)
|
|
10
|
+
from luna_quantum.solve.parameters.backends import IBM
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class VQE(LunaAlgorithm[IBM]):
|
|
14
|
+
"""
|
|
15
|
+
Parameters for the Variational Quantum Eigensolver (VQE) algorithm.
|
|
16
|
+
|
|
17
|
+
VQE is a hybrid quantum-classical algorithm designed to find the ground state energy
|
|
18
|
+
of a Hamiltonian by variationally optimizing a parameterized quantum circuit.
|
|
19
|
+
It's widely used in quantum chemistry to compute molecular ground state energies
|
|
20
|
+
and electronic structure properties.
|
|
21
|
+
|
|
22
|
+
Attributes
|
|
23
|
+
----------
|
|
24
|
+
ansatz : Literal["NLocal", "EfficientSU2", "RealAmplitudes", "PauliTwoDesign"]
|
|
25
|
+
The variational form (parameterized circuit) to use. Default is "EfficientSU2",
|
|
26
|
+
a hardware-efficient ansatz using SU(2) rotation gates that works well on NISQ
|
|
27
|
+
devices due to its shallow depth and flexibility.
|
|
28
|
+
ansatz_config : dict[str, Any]
|
|
29
|
+
Configuration options for the selected ansatz, such as:
|
|
30
|
+
|
|
31
|
+
- entanglement: Pattern of entangling gates ("linear", "full", etc.)
|
|
32
|
+
- reps: Number of repetitions of the ansatz structure
|
|
33
|
+
- rotation_blocks: Types of rotation gates to use
|
|
34
|
+
|
|
35
|
+
Default is an empty dictionary, using the ansatz's default settings.
|
|
36
|
+
shots : int | None
|
|
37
|
+
Number of measurement samples per circuit execution. Higher values improve
|
|
38
|
+
accuracy by reducing statistical noise at the cost of longer runtime.
|
|
39
|
+
Default is 1024, which balances accuracy with execution time.
|
|
40
|
+
optimizer : ScipyOptimizerParams | Dict
|
|
41
|
+
Configuration for the classical optimization routine that updates the
|
|
42
|
+
variational parameters. Default is a ScipyOptimizer instance with default
|
|
43
|
+
settings. See ScipyOptimizer Params class or for details
|
|
44
|
+
of contained parameters.
|
|
45
|
+
initial_params_seed: int | None
|
|
46
|
+
Seed for random number generator for intial params.
|
|
47
|
+
initial_params_range: tuple[float, float]
|
|
48
|
+
Range of initial parameter values.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
ansatz: Literal["NLocal", "EfficientSU2", "RealAmplitudes", "PauliTwoDesign"] = (
|
|
52
|
+
"EfficientSU2"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
ansatz_config: dict[str, Any] = Field(default_factory=dict)
|
|
56
|
+
shots: int | None = 1024 # Number of circuit executions
|
|
57
|
+
|
|
58
|
+
optimizer: ScipyOptimizerParams = Field(
|
|
59
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
initial_params_seed: int | None = None
|
|
63
|
+
initial_params_range: tuple[float, float] = Field(default=(0, 2 * math.pi))
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def algorithm_name(self) -> str:
|
|
67
|
+
"""
|
|
68
|
+
Returns the name of the algorithm.
|
|
69
|
+
|
|
70
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
71
|
+
It should provide the name of the algorithm being implemented.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
str
|
|
76
|
+
The name of the algorithm.
|
|
77
|
+
"""
|
|
78
|
+
return "VQE"
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def get_default_backend(cls) -> IBM:
|
|
82
|
+
"""
|
|
83
|
+
Return the default backend implementation.
|
|
84
|
+
|
|
85
|
+
This property must be implemented by subclasses to provide
|
|
86
|
+
the default backend instance to use when no specific backend
|
|
87
|
+
is specified.
|
|
88
|
+
|
|
89
|
+
Returns
|
|
90
|
+
-------
|
|
91
|
+
IBackend
|
|
92
|
+
An instance of a class implementing the IBackend interface that serves
|
|
93
|
+
as the default backend.
|
|
94
|
+
"""
|
|
95
|
+
return IBM()
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def get_compatible_backends(cls) -> tuple[type[IBM]]:
|
|
99
|
+
"""
|
|
100
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
tuple[type[IBackend], ...]
|
|
105
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
return (IBM,)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
6
|
+
from luna_quantum.solve.parameters.algorithms.base_params import (
|
|
7
|
+
Decomposer,
|
|
8
|
+
TabuSearchBaseParams,
|
|
9
|
+
)
|
|
10
|
+
from luna_quantum.solve.parameters.backends import DWave
|
|
11
|
+
from luna_quantum.solve.parameters.constants import DEFAULT_ATOL, DEFAULT_RTOL
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DialecticSearch(LunaAlgorithm[DWave]):
|
|
15
|
+
"""
|
|
16
|
+
Parameters for the Dialectic Search optimization algorithm.
|
|
17
|
+
|
|
18
|
+
Dialectic Search is an iterative metaheuristic that uses a
|
|
19
|
+
thesis-antithesis-synthesis approach to explore the solution space. It starts with
|
|
20
|
+
a thesis (initial solution) and generates an antithesis (complementary solution).
|
|
21
|
+
Then it performs a path search between them to synthesize improved solutions, using
|
|
22
|
+
tabu search for all three phases.
|
|
23
|
+
|
|
24
|
+
Attributes
|
|
25
|
+
----------
|
|
26
|
+
antithesis_tabu_params: TabuSearchParams
|
|
27
|
+
Parameters for the antithesis phase of the search process. The antithesis
|
|
28
|
+
deliberately explores contrasting regions of the solution space to ensure
|
|
29
|
+
diversity and avoid getting trapped in local optima. This phase often uses
|
|
30
|
+
different tabu parameters to promote exploration over exploitation.
|
|
31
|
+
Default is a TabuSearchParams instance with default settings.
|
|
32
|
+
synthesis_tabu_params: TabuSearchParams
|
|
33
|
+
Parameters for the synthesis phase of the search process. The synthesis combines
|
|
34
|
+
aspects of both thesis and antithesis to generate new candidate solutions,
|
|
35
|
+
exploring the path between these solutions to find potentially better optima.
|
|
36
|
+
This phase is critical for discovering high-quality solutions that neither
|
|
37
|
+
thesis nor antithesis alone would find.
|
|
38
|
+
Default is a TabuSearchParams instance with default settings.
|
|
39
|
+
max_iter: int | None
|
|
40
|
+
Maximum number of iterations for the solver. This limits the total number of
|
|
41
|
+
dialectic cycles (thesis-antithesis-synthesis) that will be performed.
|
|
42
|
+
Higher values allow for more thorough exploration but increase runtime.
|
|
43
|
+
Default is 100.
|
|
44
|
+
max_time: int
|
|
45
|
+
Maximum time in seconds for the solver to run. Provides a hard time limit
|
|
46
|
+
regardless of convergence or iteration status. Useful for time-constrained
|
|
47
|
+
scenarios where some solution is needed within a specific timeframe.
|
|
48
|
+
Default is 5.
|
|
49
|
+
convergence: int
|
|
50
|
+
Number of consecutive iterations without improvement before declaring
|
|
51
|
+
convergence. Higher values ensure more stable solutions but may increase
|
|
52
|
+
computation time unnecessarily if the algorithm has already found the best
|
|
53
|
+
solution. Default is 3.
|
|
54
|
+
target: float | None
|
|
55
|
+
Target objective value that triggers termination if reached. Allows early
|
|
56
|
+
stopping when a sufficiently good solution is found. Default is None, which
|
|
57
|
+
means the algorithm will run until other stopping criteria are met.
|
|
58
|
+
rtol: float
|
|
59
|
+
Relative tolerance for convergence detection. Used when comparing objective
|
|
60
|
+
values between iterations to determine if significant improvement has occurred.
|
|
61
|
+
Default is DEFAULT_RTOL.
|
|
62
|
+
atol: float
|
|
63
|
+
Absolute tolerance for convergence detection. Used alongside rtol when comparing
|
|
64
|
+
objective values to determine if the algorithm has converged. Default is
|
|
65
|
+
DEFAULT_ATOL.
|
|
66
|
+
max_tries: int | None
|
|
67
|
+
Maximum number of synthesis attempts for each input state before moving to a new
|
|
68
|
+
thesis. Controls how persistently the algorithm explores the path between
|
|
69
|
+
thesis and antithesis before generating new starting points. Higher values
|
|
70
|
+
allow for more thorough path exploration but may slow progress if paths are
|
|
71
|
+
unproductive. Default is 100. Must be ≥1.
|
|
72
|
+
decomposer: Decomposer
|
|
73
|
+
Decomposer: Breaks down problems into subproblems of manageable size
|
|
74
|
+
Default is a Decomposer instance with default settings.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
antithesis_tabu_params: TabuSearchBaseParams = Field(
|
|
78
|
+
default_factory=TabuSearchBaseParams
|
|
79
|
+
)
|
|
80
|
+
synthesis_tabu_params: TabuSearchBaseParams = Field(
|
|
81
|
+
default_factory=TabuSearchBaseParams
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
85
|
+
max_iter: int | None = 100
|
|
86
|
+
max_time: int = 5
|
|
87
|
+
convergence: int = 3
|
|
88
|
+
target: float | None = None
|
|
89
|
+
rtol: float = DEFAULT_RTOL
|
|
90
|
+
atol: float = DEFAULT_ATOL
|
|
91
|
+
max_tries: int | None = Field(default=100, ge=1)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def algorithm_name(self) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Returns the name of the algorithm.
|
|
97
|
+
|
|
98
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
99
|
+
It should provide the name of the algorithm being implemented.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
str
|
|
104
|
+
The name of the algorithm.
|
|
105
|
+
"""
|
|
106
|
+
return "DS"
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def get_default_backend(cls) -> DWave:
|
|
110
|
+
"""
|
|
111
|
+
Return the default backend implementation.
|
|
112
|
+
|
|
113
|
+
This property must be implemented by subclasses to provide
|
|
114
|
+
the default backend instance to use when no specific backend
|
|
115
|
+
is specified.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
IBackend
|
|
120
|
+
An instance of a class implementing the IBackend interface that serves
|
|
121
|
+
as the default backend.
|
|
122
|
+
"""
|
|
123
|
+
return DWave()
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
|
|
127
|
+
"""
|
|
128
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
tuple[type[IBackend], ...]
|
|
133
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
134
|
+
|
|
135
|
+
"""
|
|
136
|
+
return (DWave,)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
4
|
+
from luna_quantum.solve.parameters.algorithms.base_params.tabu_search_params import (
|
|
5
|
+
TabuSearchBaseParams,
|
|
6
|
+
)
|
|
7
|
+
from luna_quantum.solve.parameters.backends import DWave
|
|
8
|
+
from luna_quantum.solve.parameters.mixins.qbsolv_like_mixin import QBSolvLikeMixin
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class QBSolvLikeTabuSearch(QBSolvLikeMixin, LunaAlgorithm[DWave]):
|
|
12
|
+
"""QbSolvLikeTabuSearch Parameters.
|
|
13
|
+
|
|
14
|
+
QBSolv Like Tabu Search breaks down the problem and solves the parts individually
|
|
15
|
+
using a classic solver that uses Tabu Search. This particular implementation uses
|
|
16
|
+
hybrid.TabuSubproblemSampler (https://docs.ocean.dwavesys.com/projects/hybrid/en/stable/reference/samplers.html#tabusubproblemsampler)
|
|
17
|
+
as a sampler for the subproblems to achieve a QBSolv like behaviour.
|
|
18
|
+
|
|
19
|
+
This class combines parameters from two sources:
|
|
20
|
+
- QBSolvLikeMixin: Provides parameters for the QBSolv-like decomposition approach
|
|
21
|
+
- tabu_search_params: Nested parameter object for Tabu Search configuration
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
decomposer_size: int
|
|
26
|
+
Size for the decomposer, which determines the maximum subproblem size to be
|
|
27
|
+
handled in each iteration. Larger values may produce better solutions but
|
|
28
|
+
increase computational complexity exponentially. Default is 50, which balances
|
|
29
|
+
solution quality with reasonable runtime.
|
|
30
|
+
rolling: bool
|
|
31
|
+
Whether to use rolling window decomposition for the solver. When enabled,
|
|
32
|
+
this allows for overlapping subproblems with shared variables, which can
|
|
33
|
+
improve solution quality by better handling interactions across subproblem
|
|
34
|
+
boundaries. Default is True.
|
|
35
|
+
rolling_history: float
|
|
36
|
+
Rolling history factor controlling how much of previous subproblem solutions
|
|
37
|
+
are considered when solving subsequent subproblems. Higher values incorporate
|
|
38
|
+
more historical information but may slow convergence to new solutions.
|
|
39
|
+
Default is 0.15 (15% retention).
|
|
40
|
+
max_iter: int | None
|
|
41
|
+
Maximum number of iterations (decomposition and solving cycles) to perform.
|
|
42
|
+
Higher values allow for more thorough optimization but increase runtime.
|
|
43
|
+
Default is 100.
|
|
44
|
+
max_time: int
|
|
45
|
+
Time in seconds after which the algorithm will stop, regardless of convergence
|
|
46
|
+
status. Provides a hard time limit for time-constrained applications.
|
|
47
|
+
Default is 5.
|
|
48
|
+
convergence: int
|
|
49
|
+
Number of iterations with unchanged output to terminate algorithm. Higher values
|
|
50
|
+
ensure more stable solutions but may increase computation time unnecessarily
|
|
51
|
+
if the algorithm has already found the best solution. Default is 3.
|
|
52
|
+
target: float | None
|
|
53
|
+
Energy level that the algorithm tries to reach. If this target energy is
|
|
54
|
+
achieved, the algorithm will terminate early. Default is None, meaning the
|
|
55
|
+
algorithm will run until other stopping criteria are met.
|
|
56
|
+
rtol: float
|
|
57
|
+
Relative tolerance for convergence. Used when comparing energy values between
|
|
58
|
+
iterations to determine if significant improvement has occurred. Default uses
|
|
59
|
+
DEFAULT_RTOL.
|
|
60
|
+
atol: float
|
|
61
|
+
Absolute tolerance for convergence. Used alongside rtol when comparing energy
|
|
62
|
+
values to determine if the algorithm has converged. Default uses DEFAULT_ATOL.
|
|
63
|
+
tabu_search_params: TabuSearchBaseParams
|
|
64
|
+
Nested configuration for Tabu Search algorithm parameters. Controls the
|
|
65
|
+
behavior of the Tabu Search used to solve each subproblem, including
|
|
66
|
+
parameters like tabu tenure, number of restarts, and timeout conditions.
|
|
67
|
+
See TabuSearchParams class for details of contained parameters.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
tabu_search_params: TabuSearchBaseParams = Field(
|
|
71
|
+
default_factory=TabuSearchBaseParams
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def algorithm_name(self) -> str:
|
|
76
|
+
"""
|
|
77
|
+
Returns the name of the algorithm.
|
|
78
|
+
|
|
79
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
80
|
+
It should provide the name of the algorithm being implemented.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
str
|
|
85
|
+
The name of the algorithm.
|
|
86
|
+
"""
|
|
87
|
+
return "QLTS"
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def get_default_backend(cls) -> DWave:
|
|
91
|
+
"""
|
|
92
|
+
Return the default backend implementation.
|
|
93
|
+
|
|
94
|
+
This property must be implemented by subclasses to provide
|
|
95
|
+
the default backend instance to use when no specific backend
|
|
96
|
+
is specified.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
IBackend
|
|
101
|
+
An instance of a class implementing the IBackend interface that serves
|
|
102
|
+
as the default backend.
|
|
103
|
+
"""
|
|
104
|
+
return DWave()
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
|
|
108
|
+
"""
|
|
109
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
110
|
+
|
|
111
|
+
Returns
|
|
112
|
+
-------
|
|
113
|
+
tuple[type[IBackend], ...]
|
|
114
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
return (DWave,)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from luna_quantum.solve.domain.abstract import LunaAlgorithm
|
|
2
|
+
from luna_quantum.solve.parameters.algorithms.base_params.tabu_search_params import (
|
|
3
|
+
TabuSearchParams,
|
|
4
|
+
)
|
|
5
|
+
from luna_quantum.solve.parameters.backends import DWave
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TabuSearch(TabuSearchParams, LunaAlgorithm[DWave]):
|
|
9
|
+
"""
|
|
10
|
+
Extended parameters for the Tabu Search optimization algorithm.
|
|
11
|
+
|
|
12
|
+
Tabu Search is a metaheuristic that enhances local search by maintaining a
|
|
13
|
+
"tabu list" of recently visited solutions to avoid cycling. It systematically
|
|
14
|
+
explores the solution space by allowing non-improving moves when no improving moves
|
|
15
|
+
exist, while preventing revisiting recent solutions.
|
|
16
|
+
|
|
17
|
+
This class extends the basic TabuSearch with additional parameters for fine-tuning
|
|
18
|
+
the search process, including restart strategies and early termination conditions.
|
|
19
|
+
|
|
20
|
+
Attributes
|
|
21
|
+
----------
|
|
22
|
+
initial_states: Any | None
|
|
23
|
+
Starting states for the search. Allows the algorithm to begin from promising
|
|
24
|
+
regions rather than random points. If fewer states than num_reads are provided,
|
|
25
|
+
additional states are generated according to initial_states_generator.
|
|
26
|
+
Default is None (random starting states).
|
|
27
|
+
seed: int | None
|
|
28
|
+
Random seed for reproducible results. With identical parameters and seed,
|
|
29
|
+
results will be identical (unless timeout limits are reached, as finite
|
|
30
|
+
clock resolution can affect execution). Default is None (random seed).
|
|
31
|
+
num_restarts: int
|
|
32
|
+
Maximum number of tabu search restarts per read. Restarts help escape deep
|
|
33
|
+
local minima by starting fresh from new points after the initial search stalls.
|
|
34
|
+
Setting to zero results in a simple tabu search without restarts.
|
|
35
|
+
Default is 1,000,000, allowing many restarts if needed.
|
|
36
|
+
energy_threshold: float | None
|
|
37
|
+
Target energy value that triggers termination if found. Allows early stopping
|
|
38
|
+
when a sufficiently good solution is discovered. Default is None (run until
|
|
39
|
+
other stopping criteria are met).
|
|
40
|
+
coefficient_z_first: int | None
|
|
41
|
+
Controls the number of variable updates in the first simple tabu search (STS).
|
|
42
|
+
The actual limit is max(variables*coefficient_z_first, lower_bound_z).
|
|
43
|
+
Defaults to 10,000 for small problems (≤500 variables) and 25,000 for larger
|
|
44
|
+
ones. Higher values allow more thorough exploration of the initial solution
|
|
45
|
+
neighborhood.
|
|
46
|
+
coefficient_z_restart: int | None
|
|
47
|
+
Controls the number of variable updates in restarted tabu searches.
|
|
48
|
+
Similar to coefficient_z_first but for restart phases. Default is
|
|
49
|
+
coefficient_z_first/4, allowing faster exploration during restarts. This
|
|
50
|
+
typically results in broader but less deep searches after restarts.
|
|
51
|
+
lower_bound_z: int | None
|
|
52
|
+
Minimum number of variable updates for all tabu searches. Ensures a thorough
|
|
53
|
+
search even for small problems. Default is 500,000. Setting too low may
|
|
54
|
+
result in premature termination before finding good solutions.
|
|
55
|
+
num_reads: int | None
|
|
56
|
+
Number of independent runs of the tabu algorithm, each producing one solution.
|
|
57
|
+
Multiple reads increase the chance of finding the global optimum by starting
|
|
58
|
+
from different initial states. If None, matches the number of initial states
|
|
59
|
+
provided (or performs just one read if no initial states are given).
|
|
60
|
+
tenure: int | None
|
|
61
|
+
Length of the tabu list - the number of recently visited solutions that are
|
|
62
|
+
forbidden. Larger values help escape deeper local minima but may slow
|
|
63
|
+
exploration. Default is 1/4 of the number of variables up to a maximum of 20.
|
|
64
|
+
A good tenure balances diversification (exploring new regions) with
|
|
65
|
+
intensification (focusing on promising areas).
|
|
66
|
+
timeout: float
|
|
67
|
+
Maximum running time in milliseconds per read before the algorithm stops,
|
|
68
|
+
regardless of convergence. Default is 100, which is suitable for small to
|
|
69
|
+
medium-sized problems. For larger problems, consider increasing this value
|
|
70
|
+
to allow sufficient exploration time.
|
|
71
|
+
initial_states_generator: Literal["none", "tile", "random"]
|
|
72
|
+
Controls how to handle situations where fewer initial states are provided
|
|
73
|
+
than num_reads:
|
|
74
|
+
|
|
75
|
+
- "none": Raises an error if insufficient initial states
|
|
76
|
+
- "tile": Reuses provided states by cycling through them
|
|
77
|
+
- "random": Generates additional random states as needed
|
|
78
|
+
|
|
79
|
+
Default is "random", which maximizes search space coverage when the number
|
|
80
|
+
of provided initial states is insufficient.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def algorithm_name(self) -> str:
|
|
85
|
+
"""
|
|
86
|
+
Returns the name of the algorithm.
|
|
87
|
+
|
|
88
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
89
|
+
It should provide the name of the algorithm being implemented.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
str
|
|
94
|
+
The name of the algorithm.
|
|
95
|
+
"""
|
|
96
|
+
return "TS"
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def get_default_backend(cls) -> DWave:
|
|
100
|
+
"""
|
|
101
|
+
Return the default backend implementation.
|
|
102
|
+
|
|
103
|
+
This property must be implemented by subclasses to provide
|
|
104
|
+
the default backend instance to use when no specific backend
|
|
105
|
+
is specified.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
IBackend
|
|
110
|
+
An instance of a class implementing the IBackend interface that serves
|
|
111
|
+
as the default backend.
|
|
112
|
+
"""
|
|
113
|
+
return DWave()
|
|
114
|
+
|
|
115
|
+
@classmethod
|
|
116
|
+
def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
|
|
117
|
+
"""
|
|
118
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
119
|
+
|
|
120
|
+
Returns
|
|
121
|
+
-------
|
|
122
|
+
tuple[type[IBackend], ...]
|
|
123
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
124
|
+
|
|
125
|
+
"""
|
|
126
|
+
return (DWave,)
|