luna-quantum 1.0.8rc2__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of luna-quantum might be problematic. Click here for more details.

Files changed (264) hide show
  1. luna_quantum/__init__.py +121 -0
  2. luna_quantum/__init__.pyi +85 -0
  3. luna_quantum/_core.cp314-win_amd64.pyd +0 -0
  4. luna_quantum/_core.pyi +4185 -0
  5. luna_quantum/algorithms/__init__.py +1 -0
  6. luna_quantum/aqm_overwrites/__init__.py +3 -0
  7. luna_quantum/aqm_overwrites/model.py +184 -0
  8. luna_quantum/backends/__init__.py +1 -0
  9. luna_quantum/client/__init__.py +0 -0
  10. luna_quantum/client/controllers/__init__.py +4 -0
  11. luna_quantum/client/controllers/luna_http_client.py +37 -0
  12. luna_quantum/client/controllers/luna_platform_client.py +256 -0
  13. luna_quantum/client/controllers/luna_q.py +67 -0
  14. luna_quantum/client/controllers/luna_solve.py +129 -0
  15. luna_quantum/client/error/__init__.py +0 -0
  16. luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
  17. luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
  18. luna_quantum/client/error/luna_error.py +2 -0
  19. luna_quantum/client/error/luna_server_error.py +20 -0
  20. luna_quantum/client/error/timeout_error.py +12 -0
  21. luna_quantum/client/error/transformation_error.py +18 -0
  22. luna_quantum/client/error/utils/__init__.py +0 -0
  23. luna_quantum/client/error/utils/http_error_utils.py +112 -0
  24. luna_quantum/client/interfaces/__init__.py +4 -0
  25. luna_quantum/client/interfaces/clients/__init__.py +25 -0
  26. luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
  27. luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
  28. luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
  29. luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
  30. luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
  31. luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
  32. luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
  33. luna_quantum/client/interfaces/services/__init__.py +0 -0
  34. luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
  35. luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
  36. luna_quantum/client/interfaces/services/service_i.py +56 -0
  37. luna_quantum/client/rest_client/__init__.py +15 -0
  38. luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
  39. luna_quantum/client/rest_client/info_rest_client.py +74 -0
  40. luna_quantum/client/rest_client/model_rest_client.py +216 -0
  41. luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
  42. luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
  43. luna_quantum/client/rest_client/users_rest_client.py +35 -0
  44. luna_quantum/client/schemas/__init__.py +26 -0
  45. luna_quantum/client/schemas/circuit.py +48 -0
  46. luna_quantum/client/schemas/create/__init__.py +15 -0
  47. luna_quantum/client/schemas/create/circuit.py +30 -0
  48. luna_quantum/client/schemas/create/optimization.py +39 -0
  49. luna_quantum/client/schemas/create/qpu_token.py +22 -0
  50. luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
  51. luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
  52. luna_quantum/client/schemas/create/qubo.py +19 -0
  53. luna_quantum/client/schemas/create/solve_job_create.py +43 -0
  54. luna_quantum/client/schemas/enums/__init__.py +0 -0
  55. luna_quantum/client/schemas/enums/call_style.py +13 -0
  56. luna_quantum/client/schemas/enums/circuit.py +42 -0
  57. luna_quantum/client/schemas/enums/model_format.py +11 -0
  58. luna_quantum/client/schemas/enums/problem.py +50 -0
  59. luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
  60. luna_quantum/client/schemas/enums/sense.py +8 -0
  61. luna_quantum/client/schemas/enums/status.py +40 -0
  62. luna_quantum/client/schemas/enums/timeframe.py +11 -0
  63. luna_quantum/client/schemas/error_message.py +14 -0
  64. luna_quantum/client/schemas/model_metadata.py +35 -0
  65. luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
  66. luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
  67. luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
  68. luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
  69. luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
  70. luna_quantum/client/schemas/representation.py +19 -0
  71. luna_quantum/client/schemas/solution.py +106 -0
  72. luna_quantum/client/schemas/solve_job.py +50 -0
  73. luna_quantum/client/schemas/solver_info.py +11 -0
  74. luna_quantum/client/schemas/user.py +11 -0
  75. luna_quantum/client/schemas/wrappers/__init__.py +5 -0
  76. luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
  77. luna_quantum/client/utils/__init__.py +0 -0
  78. luna_quantum/client/utils/qpu_token_utils.py +147 -0
  79. luna_quantum/config.py +11 -0
  80. luna_quantum/decorators.py +248 -0
  81. luna_quantum/errors.py +34 -0
  82. luna_quantum/errors.pyi +287 -0
  83. luna_quantum/exceptions/__init__.py +0 -0
  84. luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
  85. luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
  86. luna_quantum/factories/__init__.py +4 -0
  87. luna_quantum/factories/luna_solve_client_factory.py +100 -0
  88. luna_quantum/factories/usecase_factory.py +457 -0
  89. luna_quantum/py.typed +0 -0
  90. luna_quantum/solve/__init__.py +13 -0
  91. luna_quantum/solve/default_token.py +304 -0
  92. luna_quantum/solve/domain/__init__.py +0 -0
  93. luna_quantum/solve/domain/abstract/__init__.py +4 -0
  94. luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
  95. luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
  96. luna_quantum/solve/domain/model_metadata.py +56 -0
  97. luna_quantum/solve/domain/solve_job.py +196 -0
  98. luna_quantum/solve/errors/__init__.py +0 -0
  99. luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
  100. luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
  101. luna_quantum/solve/errors/solve_base_error.py +5 -0
  102. luna_quantum/solve/errors/token_missing_error.py +11 -0
  103. luna_quantum/solve/interfaces/__init__.py +0 -0
  104. luna_quantum/solve/interfaces/algorithm_i.py +49 -0
  105. luna_quantum/solve/interfaces/backend_i.py +28 -0
  106. luna_quantum/solve/interfaces/usecases/__init__.py +55 -0
  107. luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
  108. luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
  109. luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
  110. luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
  111. luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
  112. luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
  113. luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
  114. luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
  115. luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
  116. luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
  117. luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
  118. luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
  119. luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
  120. luna_quantum/solve/parameters/__init__.py +0 -0
  121. luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
  122. luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
  123. luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
  124. luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
  125. luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
  126. luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
  127. luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
  128. luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
  129. luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
  130. luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
  131. luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
  132. luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
  133. luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
  134. luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
  135. luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
  136. luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
  137. luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
  138. luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
  139. luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
  140. luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
  141. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
  142. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
  143. luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
  144. luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
  145. luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
  146. luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
  147. luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
  148. luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
  149. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +26 -0
  150. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
  151. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
  152. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +99 -0
  153. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
  154. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +102 -0
  155. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
  156. luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
  157. luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
  158. luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
  159. luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
  160. luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
  161. luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
  162. luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
  163. luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
  164. luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
  165. luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
  166. luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
  167. luna_quantum/solve/parameters/backends/__init__.py +22 -0
  168. luna_quantum/solve/parameters/backends/aqarios.py +17 -0
  169. luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
  170. luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
  171. luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
  172. luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
  173. luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
  174. luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
  175. luna_quantum/solve/parameters/backends/dwave.py +17 -0
  176. luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
  177. luna_quantum/solve/parameters/backends/fda.py +17 -0
  178. luna_quantum/solve/parameters/backends/ibm.py +138 -0
  179. luna_quantum/solve/parameters/backends/qctrl.py +103 -0
  180. luna_quantum/solve/parameters/backends/zib.py +17 -0
  181. luna_quantum/solve/parameters/constants.py +11 -0
  182. luna_quantum/solve/parameters/mixins/__init__.py +0 -0
  183. luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
  184. luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
  185. luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
  186. luna_quantum/solve/use_cases/__init__.py +119 -0
  187. luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
  188. luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
  189. luna_quantum/solve/use_cases/base.py +7 -0
  190. luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
  191. luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
  192. luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
  193. luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
  194. luna_quantum/solve/use_cases/exact_cover.py +51 -0
  195. luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
  196. luna_quantum/solve/use_cases/graph_coloring.py +42 -0
  197. luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
  198. luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
  199. luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
  200. luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
  201. luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
  202. luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
  203. luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
  204. luna_quantum/solve/use_cases/linear_regression.py +60 -0
  205. luna_quantum/solve/use_cases/lmwcs.py +84 -0
  206. luna_quantum/solve/use_cases/longest_path.py +50 -0
  207. luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
  208. luna_quantum/solve/use_cases/max2sat.py +54 -0
  209. luna_quantum/solve/use_cases/max3sat.py +55 -0
  210. luna_quantum/solve/use_cases/max_clique.py +60 -0
  211. luna_quantum/solve/use_cases/max_cut.py +48 -0
  212. luna_quantum/solve/use_cases/max_independent_set.py +37 -0
  213. luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
  214. luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
  215. luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
  216. luna_quantum/solve/use_cases/number_partitioning.py +32 -0
  217. luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
  218. luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
  219. luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
  220. luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
  221. luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
  222. luna_quantum/solve/use_cases/sensor_placement.py +58 -0
  223. luna_quantum/solve/use_cases/set_cover.py +56 -0
  224. luna_quantum/solve/use_cases/set_packing.py +54 -0
  225. luna_quantum/solve/use_cases/set_partitioning.py +52 -0
  226. luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
  227. luna_quantum/solve/use_cases/subset_sum.py +37 -0
  228. luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
  229. luna_quantum/solve/use_cases/traffic_flow.py +35 -0
  230. luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
  231. luna_quantum/solve/use_cases/type_aliases.py +9 -0
  232. luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
  233. luna_quantum/solve/usecases/__init__.py +45 -0
  234. luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
  235. luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
  236. luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
  237. luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
  238. luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
  239. luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
  240. luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
  241. luna_quantum/solve/usecases/model_save_usecase.py +63 -0
  242. luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
  243. luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
  244. luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
  245. luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
  246. luna_quantum/solve/usecases/solve_job_get_result_usecase.py +95 -0
  247. luna_quantum/transformations.py +18 -0
  248. luna_quantum/transformations.pyi +371 -0
  249. luna_quantum/translator.py +23 -0
  250. luna_quantum/translator.pyi +869 -0
  251. luna_quantum/util/__init__.py +0 -0
  252. luna_quantum/util/active_waiting.py +79 -0
  253. luna_quantum/util/class_patcher.py +164 -0
  254. luna_quantum/util/debug_info.py +52 -0
  255. luna_quantum/util/log_utils.py +187 -0
  256. luna_quantum/util/pretty_base.py +67 -0
  257. luna_quantum/util/pydantic_utils.py +38 -0
  258. luna_quantum/utils.py +3 -0
  259. luna_quantum/utils.pyi +67 -0
  260. luna_quantum-1.0.8rc2.dist-info/METADATA +36 -0
  261. luna_quantum-1.0.8rc2.dist-info/RECORD +264 -0
  262. luna_quantum-1.0.8rc2.dist-info/WHEEL +4 -0
  263. luna_quantum-1.0.8rc2.dist-info/licenses/LICENSE +176 -0
  264. luna_quantum-1.0.8rc2.dist-info/licenses/NOTICE +13 -0
@@ -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,5 @@
1
+ from .dialectic_search import DialecticSearch
2
+ from .qbsolv_like_tabu_search import QBSolvLikeTabuSearch
3
+ from .tabu_search import TabuSearch
4
+
5
+ __all__ = ["DialecticSearch", "QBSolvLikeTabuSearch", "TabuSearch"]
@@ -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,)
@@ -0,0 +1,13 @@
1
+ from .parallel_tempering import ParallelTempering
2
+ from .population_annealing import PopulationAnnealing
3
+ from .qbsolv_like_simulated_annealing import QBSolvLikeSimulatedAnnealing
4
+ from .repeated_reverse_simulated_annealing import RepeatedReverseSimulatedAnnealing
5
+ from .simulated_annealing import SimulatedAnnealing
6
+
7
+ __all__ = [
8
+ "ParallelTempering",
9
+ "PopulationAnnealing",
10
+ "QBSolvLikeSimulatedAnnealing",
11
+ "RepeatedReverseSimulatedAnnealing",
12
+ "SimulatedAnnealing",
13
+ ]
@@ -0,0 +1,131 @@
1
+ from luna_quantum.solve.domain.abstract import LunaAlgorithm
2
+ from luna_quantum.solve.parameters.backends import DWave
3
+ from luna_quantum.solve.parameters.constants import DEFAULT_ATOL, DEFAULT_RTOL
4
+
5
+
6
+ class ParallelTempering(LunaAlgorithm[DWave]):
7
+ """
8
+ Parameters for the Parallel Tempering (replica exchange) optimization algorithm.
9
+
10
+ Parallel Tempering runs multiple copies ("replicas") of the system simultaneously
11
+ at different temperatures. Periodically, replicas at adjacent temperatures can swap
12
+ configurations, allowing high-temperature replicas to explore widely while
13
+ low-temperature replicas exploit promising regions.
14
+
15
+ This approach is particularly effective for problems with many local minima, as it
16
+ combines the exploration benefits of high temperature with the exploitation benefits
17
+ of low temperature.
18
+
19
+ Attributes
20
+ ----------
21
+ n_replicas: int
22
+ Number of system replicas to simulate at different temperatures. More replicas
23
+ provide better temperature coverage but increase computational cost.
24
+ Higher values allow for finer gradations between temperature levels, potentially
25
+ improving the exchange of configurations between adjacent replicas.
26
+ Default is 2, which is minimal but can still provide benefits over
27
+ single-temperature methods.
28
+ random_swaps_factor: int
29
+ Factor controlling how frequently random swap attempts occur between replicas.
30
+ Higher values increase mixing between replicas but add computational overhead.
31
+ More frequent swaps help configurations move more quickly between temperature
32
+ levels, allowing good solutions found at high temperatures to be refined at
33
+ lower temperatures. Default is 1, balancing mixing with efficiency.
34
+ max_iter: int | None
35
+ Maximum number of iterations (temperature cycles) to perform. Each iteration
36
+ involves sampling at all temperature levels and attempting exchanges between
37
+ replicas. Higher values allow more thorough exploration but increase runtime.
38
+ Default is 100.
39
+ max_time: int
40
+ Maximum time in seconds for the algorithm to run. Provides a hard time limit
41
+ regardless of convergence or iteration status. Useful for time-constrained
42
+ scenarios where some solution is needed within a specific timeframe.
43
+ Default is 5.
44
+ convergence: int
45
+ Number of consecutive iterations without improvement before declaring
46
+ convergence. Higher values ensure more stable solutions but may increase
47
+ computation time unnecessarily if the algorithm has already found the best
48
+ solution. Default is 3.
49
+ target: float | None
50
+ Target objective value that triggers termination if reached. Allows early
51
+ stopping when a sufficiently good solution is found. Default is None, which
52
+ means the algorithm will run until other stopping criteria are met.
53
+ rtol: float
54
+ Relative tolerance for convergence detection. Used when comparing objective
55
+ values between iterations to determine if significant improvement has occurred.
56
+ Default is DEFAULT_RTOL.
57
+ atol: float
58
+ Absolute tolerance for convergence detection. Used alongside rtol when comparing
59
+ objective values to determine if the algorithm has converged. Default is
60
+ DEFAULT_ATOL.
61
+ fixed_temp_sampler_num_sweeps: int
62
+ Number of Monte Carlo sweeps to perform at each temperature level, where one
63
+ sweep attempts to update all variables once. More sweeps produce better
64
+ equilibrated samples but increase computation time. This parameter controls
65
+ how thoroughly each replica explores its local solution space before exchange
66
+ attempts. Default is 10,000, which is suitable for thorough exploration of
67
+ moderate-sized problems.
68
+ fixed_temp_sampler_num_reads: int | None
69
+ Number of independent sampling runs to perform at each temperature level.
70
+ Each run produces one sample from the equilibrium distribution. Multiple reads
71
+ provide better statistical coverage of the solution space at each temperature.
72
+ Default is None, which typically defaults to 1 or matches the number of initial
73
+ states provided.
74
+ """
75
+
76
+ n_replicas: int = 2
77
+ random_swaps_factor: int = 1
78
+ max_iter: int | None = 100
79
+ max_time: int = 5
80
+ convergence: int = 3
81
+ target: float | None = None
82
+ rtol: float = DEFAULT_RTOL
83
+ atol: float = DEFAULT_ATOL
84
+
85
+ fixed_temp_sampler_num_sweeps: int = 10_000
86
+ fixed_temp_sampler_num_reads: int | None = None
87
+
88
+ @property
89
+ def algorithm_name(self) -> str:
90
+ """
91
+ Returns the name of the algorithm.
92
+
93
+ This abstract property method is intended to be overridden by subclasses.
94
+ It should provide the name of the algorithm being implemented.
95
+
96
+ Returns
97
+ -------
98
+ str
99
+ The name of the algorithm.
100
+ """
101
+ return "PT"
102
+
103
+ @classmethod
104
+ def get_default_backend(cls) -> DWave:
105
+ """
106
+ Return the default backend implementation.
107
+
108
+ This property must be implemented by subclasses to provide
109
+ the default backend instance to use when no specific backend
110
+ is specified.
111
+
112
+ Returns
113
+ -------
114
+ IBackend
115
+ An instance of a class implementing the IBackend interface that serves
116
+ as the default backend.
117
+ """
118
+ return DWave()
119
+
120
+ @classmethod
121
+ def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
122
+ """
123
+ Check at runtime if the used backend is compatible with the solver.
124
+
125
+ Returns
126
+ -------
127
+ tuple[type[IBackend], ...]
128
+ True if the backend is compatible with the solver, False otherwise.
129
+
130
+ """
131
+ return (DWave,)