luna-quantum 1.0.0__cp312-cp312-musllinux_1_2_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 +96 -0
- luna_quantum/__init__.pyi +68 -0
- luna_quantum/_core.cpython-312-x86_64-linux-musl.so +0 -0
- luna_quantum/_core.pyi +3017 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -0
- luna_quantum/client/__init__.py +0 -0
- luna_quantum/client/controllers/__init__.py +4 -0
- luna_quantum/client/controllers/luna_http_client.py +37 -0
- luna_quantum/client/controllers/luna_platform_client.py +153 -0
- luna_quantum/client/controllers/luna_q.py +62 -0
- luna_quantum/client/controllers/luna_solve.py +125 -0
- luna_quantum/client/error/__init__.py +0 -0
- luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
- luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
- luna_quantum/client/error/luna_error.py +2 -0
- luna_quantum/client/error/luna_server_error.py +20 -0
- luna_quantum/client/error/timeout_error.py +12 -0
- luna_quantum/client/error/transformation_error.py +18 -0
- luna_quantum/client/error/utils/__init__.py +0 -0
- luna_quantum/client/error/utils/http_error_utils.py +112 -0
- luna_quantum/client/interfaces/__init__.py +4 -0
- luna_quantum/client/interfaces/clients/__init__.py +25 -0
- luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
- luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
- luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
- luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
- luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
- luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
- luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
- luna_quantum/client/interfaces/services/__init__.py +0 -0
- luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
- luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
- luna_quantum/client/interfaces/services/service_i.py +36 -0
- luna_quantum/client/rest_client/__init__.py +15 -0
- luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
- luna_quantum/client/rest_client/info_rest_client.py +76 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +504 -0
- luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
- luna_quantum/client/rest_client/users_rest_client.py +35 -0
- luna_quantum/client/schemas/__init__.py +26 -0
- luna_quantum/client/schemas/circuit.py +49 -0
- luna_quantum/client/schemas/create/__init__.py +6 -0
- luna_quantum/client/schemas/create/circuit.py +31 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +25 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +29 -0
- luna_quantum/client/schemas/create/qubo.py +19 -0
- luna_quantum/client/schemas/create/solve_job_create.py +43 -0
- luna_quantum/client/schemas/enums/__init__.py +0 -0
- luna_quantum/client/schemas/enums/call_style.py +13 -0
- luna_quantum/client/schemas/enums/circuit.py +42 -0
- luna_quantum/client/schemas/enums/model_format.py +11 -0
- luna_quantum/client/schemas/enums/problem.py +50 -0
- luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
- luna_quantum/client/schemas/enums/sense.py +8 -0
- luna_quantum/client/schemas/enums/status.py +40 -0
- luna_quantum/client/schemas/enums/timeframe.py +11 -0
- luna_quantum/client/schemas/error_message.py +14 -0
- luna_quantum/client/schemas/model_metadata.py +35 -0
- luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
- luna_quantum/client/schemas/qpu_token/qpu_token.py +161 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +28 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +135 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +47 -0
- luna_quantum/client/schemas/solver_info.py +11 -0
- luna_quantum/client/schemas/user.py +11 -0
- luna_quantum/client/schemas/wrappers/__init__.py +5 -0
- luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
- luna_quantum/client/utils/__init__.py +0 -0
- luna_quantum/client/utils/qpu_token_utils.py +147 -0
- luna_quantum/errors.py +1 -0
- luna_quantum/errors.pyi +202 -0
- luna_quantum/exceptions/__init__.py +0 -0
- luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
- luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
- luna_quantum/factories/__init__.py +4 -0
- luna_quantum/factories/luna_solve_client_factory.py +75 -0
- luna_quantum/factories/usecase_factory.py +457 -0
- luna_quantum/py.typed +0 -0
- luna_quantum/solve/__init__.py +13 -0
- luna_quantum/solve/default_token.py +304 -0
- luna_quantum/solve/domain/__init__.py +0 -0
- luna_quantum/solve/domain/abstract/__init__.py +4 -0
- luna_quantum/solve/domain/abstract/luna_algorithm.py +203 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +54 -0
- luna_quantum/solve/domain/solve_job.py +187 -0
- luna_quantum/solve/errors/__init__.py +0 -0
- luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
- luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
- luna_quantum/solve/errors/solve_base_error.py +5 -0
- luna_quantum/solve/errors/token_missing_error.py +11 -0
- luna_quantum/solve/interfaces/__init__.py +0 -0
- luna_quantum/solve/interfaces/algorithm_i.py +47 -0
- luna_quantum/solve/interfaces/backend_i.py +28 -0
- luna_quantum/solve/interfaces/usecases/__init__.py +55 -0
- luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
- luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
- luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
- luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
- luna_quantum/solve/parameters/__init__.py +0 -0
- luna_quantum/solve/parameters/algorithms/__init__.py +49 -0
- luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
- luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
- luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +78 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +120 -0
- luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
- luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +105 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +26 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +97 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +104 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +109 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +152 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
- luna_quantum/solve/parameters/backends/__init__.py +20 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
- luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
- luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
- luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
- luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
- luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
- luna_quantum/solve/parameters/backends/dwave.py +17 -0
- luna_quantum/solve/parameters/backends/dwave_qpu.py +164 -0
- luna_quantum/solve/parameters/backends/ibm.py +132 -0
- luna_quantum/solve/parameters/backends/qctrl.py +130 -0
- luna_quantum/solve/parameters/backends/zib.py +17 -0
- luna_quantum/solve/parameters/constants.py +11 -0
- luna_quantum/solve/parameters/mixins/__init__.py +0 -0
- luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
- luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
- luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
- luna_quantum/solve/use_cases/__init__.py +119 -0
- luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
- luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
- luna_quantum/solve/use_cases/base.py +7 -0
- luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
- luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
- luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
- luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
- luna_quantum/solve/use_cases/exact_cover.py +51 -0
- luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
- luna_quantum/solve/use_cases/graph_coloring.py +42 -0
- luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
- luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
- luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
- luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
- luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
- luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
- luna_quantum/solve/use_cases/linear_regression.py +60 -0
- luna_quantum/solve/use_cases/lmwcs.py +84 -0
- luna_quantum/solve/use_cases/longest_path.py +50 -0
- luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
- luna_quantum/solve/use_cases/max2sat.py +54 -0
- luna_quantum/solve/use_cases/max3sat.py +55 -0
- luna_quantum/solve/use_cases/max_clique.py +60 -0
- luna_quantum/solve/use_cases/max_cut.py +48 -0
- luna_quantum/solve/use_cases/max_independent_set.py +37 -0
- luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
- luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
- luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
- luna_quantum/solve/use_cases/number_partitioning.py +32 -0
- luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
- luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
- luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
- luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
- luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
- luna_quantum/solve/use_cases/sensor_placement.py +58 -0
- luna_quantum/solve/use_cases/set_cover.py +56 -0
- luna_quantum/solve/use_cases/set_packing.py +54 -0
- luna_quantum/solve/use_cases/set_partitioning.py +52 -0
- luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
- luna_quantum/solve/use_cases/subset_sum.py +37 -0
- luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
- luna_quantum/solve/use_cases/traffic_flow.py +35 -0
- luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
- luna_quantum/solve/use_cases/type_aliases.py +9 -0
- luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
- luna_quantum/solve/usecases/__init__.py +45 -0
- luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
- luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
- luna_quantum/solve/usecases/model_get_solution_usecase.py +56 -0
- luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
- luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
- luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
- luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
- luna_quantum/solve/usecases/model_save_usecase.py +63 -0
- luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
- luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
- luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
- luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +97 -0
- luna_quantum/translator.py +1 -0
- luna_quantum/translator.pyi +833 -0
- luna_quantum/util/__init__.py +0 -0
- luna_quantum/util/active_waiting.py +79 -0
- luna_quantum/util/class_patcher.py +164 -0
- luna_quantum/util/log_utils.py +167 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +54 -0
- luna_quantum/utils.pyi +35 -0
- luna_quantum-1.0.0.dist-info/METADATA +37 -0
- luna_quantum-1.0.0.dist-info/RECORD +253 -0
- luna_quantum-1.0.0.dist-info/WHEEL +4 -0
- luna_quantum-1.0.0.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.0.0.dist-info/licenses/NOTICE +13 -0
- luna_quantum.libs/libgcc_s-02f3f192.so.1 +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import (
|
|
6
|
+
ScipyOptimizerParams,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LinearOptimizerParams(ScipyOptimizerParams):
|
|
11
|
+
"""Optimizer for tuning a linear schedule of QAOA parameters.
|
|
12
|
+
|
|
13
|
+
Optimizes onyl two parameters: `delta_beta` and `delta_gamma` with the default
|
|
14
|
+
ScipyOptimizer.
|
|
15
|
+
|
|
16
|
+
Wrapper for scipy.optimize.minimize. See
|
|
17
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
|
|
18
|
+
for more information of the available methods and parameters.
|
|
19
|
+
|
|
20
|
+
Attributes
|
|
21
|
+
----------
|
|
22
|
+
method: ScipyOptimizerMethod
|
|
23
|
+
Type of solver. See
|
|
24
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
|
|
25
|
+
for supported methods.
|
|
26
|
+
tol: float | None
|
|
27
|
+
Tolerance for termination.
|
|
28
|
+
bounds: None | tuple[float, float] | list[tuple[float, float]]
|
|
29
|
+
Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell,
|
|
30
|
+
trust-constr, COBYLA, and COBYQA methods. None is used to specify no bounds,
|
|
31
|
+
`(min, max)` is used to specify bounds for all variables. A sequence of
|
|
32
|
+
`(min, max)` can be used to specify bounds for each parameter individually.
|
|
33
|
+
jac: None | Literal["2-point", "3-point", "cs"]
|
|
34
|
+
Method for computing the gradient vector. Only for CG, BFGS, Newton-CG,
|
|
35
|
+
L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and
|
|
36
|
+
trust-constr.
|
|
37
|
+
hess: None | Literal["2-point", "3-point", "cs"]
|
|
38
|
+
Method for computing the Hessian matrix. Only for Newton-CG, dogleg, trust-ncg,
|
|
39
|
+
trust-krylov, trust-exact and trust-constr.
|
|
40
|
+
maxiter: int
|
|
41
|
+
Maximum number of iterations to perform. Depending on the method
|
|
42
|
+
each iteration may use several function evaluations. Will be ignored for TNC
|
|
43
|
+
optimizer. Default: 100
|
|
44
|
+
options: dict[str, float]
|
|
45
|
+
A dictionary of solver options.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
optimizer_type: Literal["linear"] = "linear"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class CombinedOptimizerParams(BaseModel):
|
|
52
|
+
"""Combination of LinearOptimizer and ScipyOptimizer.
|
|
53
|
+
|
|
54
|
+
Optimizer that first performs an optimization of the linear schedule and then
|
|
55
|
+
fine tunes individual parameters.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Attributes
|
|
59
|
+
----------
|
|
60
|
+
linear: LinearOptimizerParams | Dict
|
|
61
|
+
Parameters of the linear optimizer.
|
|
62
|
+
fine_tune: ScipyOptimizerParams | Dict
|
|
63
|
+
Parameters of the fine tuning optimizer.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
optimizer_type: Literal["combined"] = "combined"
|
|
67
|
+
linear: LinearOptimizerParams = Field(
|
|
68
|
+
default_factory=lambda: LinearOptimizerParams()
|
|
69
|
+
)
|
|
70
|
+
fine_tune: ScipyOptimizerParams = Field(
|
|
71
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class InterpolateOptimizerParams(BaseModel):
|
|
76
|
+
"""Optimizer with sequentially increasing number of QAOA layers.
|
|
77
|
+
|
|
78
|
+
Optimizer that starts with `reps` iteration and interpolates sequentially in
|
|
79
|
+
`reps_step` steps to `reps_end`. In between it performs a full optimization routine
|
|
80
|
+
tunes individual parameters.
|
|
81
|
+
|
|
82
|
+
Attributes
|
|
83
|
+
----------
|
|
84
|
+
optimiezr: LinearOptimizerParams | ScipyOptimizerParams | Dict
|
|
85
|
+
Parameters of the optimizer.
|
|
86
|
+
reps_step: int
|
|
87
|
+
Number of QAOA layers added for one interpolation.
|
|
88
|
+
reps_end: int
|
|
89
|
+
Final number of QAOA layers to be reached.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
optimizer_type: Literal["interpolate"] = "interpolate"
|
|
93
|
+
optimizer: ScipyOptimizerParams | LinearOptimizerParams = Field(
|
|
94
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
95
|
+
)
|
|
96
|
+
reps_step: int = Field(default=1, ge=1)
|
|
97
|
+
reps_end: int = Field(default=10, ge=1)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class OneHotParams(BaseModel):
|
|
5
|
+
"""Implements one-hot constraints through XY-mixers."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IndicatorFunctionParams(BaseModel):
|
|
9
|
+
"""Implements inequality constraints via indicator functions.
|
|
10
|
+
|
|
11
|
+
Attributes
|
|
12
|
+
----------
|
|
13
|
+
penalty: float | None
|
|
14
|
+
Custom penalty factor for indicator functions. If none set, automatically
|
|
15
|
+
determined through upper and lower bounds.
|
|
16
|
+
penalty_scaling: float
|
|
17
|
+
Scaling of automatically determined penalty factor. Default: 2
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
penalty: float | None = Field(
|
|
21
|
+
default=None,
|
|
22
|
+
ge=0,
|
|
23
|
+
description="Custom penalty factor for indicator functions. If none set, "
|
|
24
|
+
"automatically determined through upper and lower bounds.",
|
|
25
|
+
)
|
|
26
|
+
penalty_scaling: float = Field(
|
|
27
|
+
default=2,
|
|
28
|
+
ge=0,
|
|
29
|
+
description="Scaling of automatically determined penalty factor. Default: 2",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class QuadraticPenaltyParams(BaseModel):
|
|
34
|
+
"""Implements all constraints through quadratic penalties.
|
|
35
|
+
|
|
36
|
+
Adds penalty terms to the objective. Adds slack variables for inequality constraints
|
|
37
|
+
if neccessaray.
|
|
38
|
+
|
|
39
|
+
Attributes
|
|
40
|
+
----------
|
|
41
|
+
penalty: float | None
|
|
42
|
+
Custom penalty factor for quadratic penalty terms. If none is set, it is
|
|
43
|
+
automatically determined by taking 10 times the maximum absolute initial bias.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
penalty: float | None = Field(
|
|
47
|
+
default=None,
|
|
48
|
+
ge=0,
|
|
49
|
+
description="Custom penalty factor for quadratic penalty terms. If none set, "
|
|
50
|
+
"automatically determined by taking 10 times the maximum absolute initial "
|
|
51
|
+
"bias.",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class PipelineParams(BaseModel):
|
|
56
|
+
"""Defines the modular Constrained QAOA Pipeline.
|
|
57
|
+
|
|
58
|
+
By default all features are enabled.
|
|
59
|
+
|
|
60
|
+
Attributes
|
|
61
|
+
----------
|
|
62
|
+
indicator_function: IndicatorFunctionParams | Dict | None
|
|
63
|
+
Whether to implement inequality constraints with indicator functions. Disable
|
|
64
|
+
with setting to `None`.
|
|
65
|
+
one_hot: OneHotParams | Dict | None
|
|
66
|
+
Whether to implement inequality constraints with indicator functions. Disable
|
|
67
|
+
with setting to `None`.
|
|
68
|
+
quadratic_penalty: QuadraticPenaltyParams | Dict | None
|
|
69
|
+
Whether to implement inequality constraints with indicator functions. Disable
|
|
70
|
+
with setting to `None`.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
indicator_function: IndicatorFunctionParams | None = Field(
|
|
74
|
+
default_factory=lambda: IndicatorFunctionParams(),
|
|
75
|
+
description="Whether to implement inequality constraints with indicator "
|
|
76
|
+
"functions. Disable with setting to `None`.",
|
|
77
|
+
)
|
|
78
|
+
one_hot: OneHotParams | None = Field(
|
|
79
|
+
default_factory=lambda: OneHotParams(),
|
|
80
|
+
description="Whether to implement inequality constraints with indicator "
|
|
81
|
+
"functions. Disable with setting to `None`.",
|
|
82
|
+
)
|
|
83
|
+
quadratic_penalty: QuadraticPenaltyParams | None = Field(
|
|
84
|
+
default_factory=lambda: QuadraticPenaltyParams(),
|
|
85
|
+
description="Whether to implement inequality constraints with indicator "
|
|
86
|
+
"functions. Disable with setting to `None`.",
|
|
87
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
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 AWS, IBM, IQM, IonQ, Rigetti
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class QAOA(LunaAlgorithm[AWS | IonQ | IQM | Rigetti | IBM]):
|
|
16
|
+
"""
|
|
17
|
+
Quantum Approximate Optimization Algorithm (QAOA).
|
|
18
|
+
|
|
19
|
+
QAOA is a hybrid quantum-classical algorithm for solving combinatorial optimization
|
|
20
|
+
problems. It works by preparing a quantum state through alternating applications of
|
|
21
|
+
problem-specific (cost) and mixing Hamiltonians, controlled by variational
|
|
22
|
+
parameters that are optimized classically to maximize the probability of measuring
|
|
23
|
+
the optimal solution.
|
|
24
|
+
|
|
25
|
+
QAOA is particularly suited for problems that can be encoded as quadratic
|
|
26
|
+
unconstrained binary optimization (QUBO) or Ising models, such as MaxCut, TSP, and
|
|
27
|
+
portfolio optimization.
|
|
28
|
+
|
|
29
|
+
Attributes
|
|
30
|
+
----------
|
|
31
|
+
reps : int
|
|
32
|
+
Number of QAOA layers (p). Each layer consists of applying both the cost and
|
|
33
|
+
mixing Hamiltonians with different variational parameters. Higher values
|
|
34
|
+
generally lead to better solutions but increase circuit depth and quantum
|
|
35
|
+
resources required. Default is 1.
|
|
36
|
+
shots : int
|
|
37
|
+
Number of measurement samples to collect per circuit execution. Higher values
|
|
38
|
+
reduce statistical noise but increase runtime. Default is 1024.
|
|
39
|
+
optimizer : ScipyOptimizerParams | Dict
|
|
40
|
+
Configuration for the classical optimization routine that updates the
|
|
41
|
+
variational parameters. Default is a ScipyOptimizer instance with default
|
|
42
|
+
settings. See ScipyOptimizer class or
|
|
43
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
|
|
44
|
+
for details of contained parameters.
|
|
45
|
+
initial_params: LinearQAOAParams | BasicQAOAParams | RandomQAOAParams | Dict
|
|
46
|
+
Custom QAOA variational circuit parameters. By default linear
|
|
47
|
+
increasing/decreasing parameters for the selected `reps` are generated.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
reps: int = Field(default=1, ge=1)
|
|
51
|
+
shots: int = Field(default=1024, ge=1)
|
|
52
|
+
optimizer: ScipyOptimizerParams = Field(
|
|
53
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
54
|
+
)
|
|
55
|
+
initial_params: RandomQAOAParams | BasicQAOAParams | LinearQAOAParams = Field(
|
|
56
|
+
default_factory=lambda: LinearQAOAParams(delta_beta=0.5, delta_gamma=0.5)
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def algorithm_name(self) -> str:
|
|
61
|
+
"""
|
|
62
|
+
Returns the name of the algorithm.
|
|
63
|
+
|
|
64
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
65
|
+
It should provide the name of the algorithm being implemented.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
str
|
|
70
|
+
The name of the algorithm.
|
|
71
|
+
"""
|
|
72
|
+
return "QAOA"
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def get_default_backend(cls) -> AWS | IonQ | IQM | Rigetti | IBM:
|
|
76
|
+
"""
|
|
77
|
+
Return the default backend implementation.
|
|
78
|
+
|
|
79
|
+
This property must be implemented by subclasses to provide
|
|
80
|
+
the default backend instance to use when no specific backend
|
|
81
|
+
is specified.
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
IBackend
|
|
86
|
+
An instance of a class implementing the IBackend interface that serves
|
|
87
|
+
as the default backend.
|
|
88
|
+
"""
|
|
89
|
+
return IBM()
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def get_compatible_backends(
|
|
93
|
+
cls,
|
|
94
|
+
) -> tuple[type[AWS | IonQ | IQM | Rigetti | IBM], ...]:
|
|
95
|
+
"""
|
|
96
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
tuple[type[IBackend], ...]
|
|
101
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
return AWS, IonQ, IQM, Rigetti, IBM
|
|
@@ -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,109 @@
|
|
|
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 class or
|
|
44
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
|
|
45
|
+
for details of contained parameters.
|
|
46
|
+
initial_params_seed: int | None
|
|
47
|
+
Seed for random number generator for intial params.
|
|
48
|
+
initial_params_range: tuple[float, float]
|
|
49
|
+
Range of initial parameter values.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
ansatz: Literal["NLocal", "EfficientSU2", "RealAmplitudes", "PauliTwoDesign"] = (
|
|
53
|
+
"EfficientSU2"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
ansatz_config: dict[str, Any] = Field(default_factory=dict)
|
|
57
|
+
shots: int | None = 1024 # Number of circuit executions
|
|
58
|
+
|
|
59
|
+
optimizer: ScipyOptimizerParams = Field(
|
|
60
|
+
default_factory=lambda: ScipyOptimizerParams()
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
initial_params_seed: int | None = None
|
|
64
|
+
initial_params_range: tuple[float, float] = Field(default=(0, 2 * math.pi))
|
|
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 "VQE"
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def get_default_backend(cls) -> IBM:
|
|
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 IBM()
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def get_compatible_backends(cls) -> tuple[type[IBM]]:
|
|
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 (IBM,)
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
Notes
|
|
77
|
+
-----
|
|
78
|
+
The Dialectic Search algorithm operates through two distinct phases:
|
|
79
|
+
|
|
80
|
+
1. Antithesis: Generates a complementary solution designed to explore different
|
|
81
|
+
regions of the solution space
|
|
82
|
+
2. Synthesis: Creates new solutions by exploring paths between thesis and antithesis
|
|
83
|
+
|
|
84
|
+
Each phase uses tabu search with potentially different parameter settings to
|
|
85
|
+
guide the exploration process. This approach is particularly effective for
|
|
86
|
+
problems with complex landscapes containing many local optima.
|
|
87
|
+
|
|
88
|
+
The algorithm uses D-Wave's backend technology to efficiently solve optimization
|
|
89
|
+
problems. For more details on D-Wave solvers, see:
|
|
90
|
+
https://docs.dwavesys.com/
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
antithesis_tabu_params: TabuSearchBaseParams = Field(
|
|
94
|
+
default_factory=TabuSearchBaseParams
|
|
95
|
+
)
|
|
96
|
+
synthesis_tabu_params: TabuSearchBaseParams = Field(
|
|
97
|
+
default_factory=TabuSearchBaseParams
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
decomposer: Decomposer = Field(default_factory=Decomposer)
|
|
101
|
+
max_iter: int | None = 100
|
|
102
|
+
max_time: int = 5
|
|
103
|
+
convergence: int = 3
|
|
104
|
+
target: float | None = None
|
|
105
|
+
rtol: float = DEFAULT_RTOL
|
|
106
|
+
atol: float = DEFAULT_ATOL
|
|
107
|
+
max_tries: int | None = Field(default=100, ge=1)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def algorithm_name(self) -> str:
|
|
111
|
+
"""
|
|
112
|
+
Returns the name of the algorithm.
|
|
113
|
+
|
|
114
|
+
This abstract property method is intended to be overridden by subclasses.
|
|
115
|
+
It should provide the name of the algorithm being implemented.
|
|
116
|
+
|
|
117
|
+
Returns
|
|
118
|
+
-------
|
|
119
|
+
str
|
|
120
|
+
The name of the algorithm.
|
|
121
|
+
"""
|
|
122
|
+
return "DS"
|
|
123
|
+
|
|
124
|
+
@classmethod
|
|
125
|
+
def get_default_backend(cls) -> DWave:
|
|
126
|
+
"""
|
|
127
|
+
Return the default backend implementation.
|
|
128
|
+
|
|
129
|
+
This property must be implemented by subclasses to provide
|
|
130
|
+
the default backend instance to use when no specific backend
|
|
131
|
+
is specified.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
IBackend
|
|
136
|
+
An instance of a class implementing the IBackend interface that serves
|
|
137
|
+
as the default backend.
|
|
138
|
+
"""
|
|
139
|
+
return DWave()
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
|
|
143
|
+
"""
|
|
144
|
+
Check at runtime if the used backend is compatible with the solver.
|
|
145
|
+
|
|
146
|
+
Returns
|
|
147
|
+
-------
|
|
148
|
+
tuple[type[IBackend], ...]
|
|
149
|
+
True if the backend is compatible with the solver, False otherwise.
|
|
150
|
+
|
|
151
|
+
"""
|
|
152
|
+
return (DWave,)
|