luna-quantum 1.0.0__cp312-cp312-manylinux_2_34_x86_64.whl

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

Potentially problematic release.


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

Files changed (252) hide show
  1. luna_quantum/__init__.py +96 -0
  2. luna_quantum/__init__.pyi +68 -0
  3. luna_quantum/_core.cpython-312-x86_64-linux-gnu.so +0 -0
  4. luna_quantum/_core.pyi +3017 -0
  5. luna_quantum/aqm_overwrites/__init__.py +3 -0
  6. luna_quantum/aqm_overwrites/model.py +184 -0
  7. luna_quantum/client/__init__.py +0 -0
  8. luna_quantum/client/controllers/__init__.py +4 -0
  9. luna_quantum/client/controllers/luna_http_client.py +37 -0
  10. luna_quantum/client/controllers/luna_platform_client.py +153 -0
  11. luna_quantum/client/controllers/luna_q.py +62 -0
  12. luna_quantum/client/controllers/luna_solve.py +125 -0
  13. luna_quantum/client/error/__init__.py +0 -0
  14. luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
  15. luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
  16. luna_quantum/client/error/luna_error.py +2 -0
  17. luna_quantum/client/error/luna_server_error.py +20 -0
  18. luna_quantum/client/error/timeout_error.py +12 -0
  19. luna_quantum/client/error/transformation_error.py +18 -0
  20. luna_quantum/client/error/utils/__init__.py +0 -0
  21. luna_quantum/client/error/utils/http_error_utils.py +112 -0
  22. luna_quantum/client/interfaces/__init__.py +4 -0
  23. luna_quantum/client/interfaces/clients/__init__.py +25 -0
  24. luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
  25. luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
  26. luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
  27. luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
  28. luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
  29. luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
  30. luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
  31. luna_quantum/client/interfaces/services/__init__.py +0 -0
  32. luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
  33. luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
  34. luna_quantum/client/interfaces/services/service_i.py +36 -0
  35. luna_quantum/client/rest_client/__init__.py +15 -0
  36. luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
  37. luna_quantum/client/rest_client/info_rest_client.py +76 -0
  38. luna_quantum/client/rest_client/model_rest_client.py +216 -0
  39. luna_quantum/client/rest_client/qpu_token_rest_client.py +504 -0
  40. luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
  41. luna_quantum/client/rest_client/users_rest_client.py +35 -0
  42. luna_quantum/client/schemas/__init__.py +26 -0
  43. luna_quantum/client/schemas/circuit.py +49 -0
  44. luna_quantum/client/schemas/create/__init__.py +6 -0
  45. luna_quantum/client/schemas/create/circuit.py +31 -0
  46. luna_quantum/client/schemas/create/optimization.py +39 -0
  47. luna_quantum/client/schemas/create/qpu_token.py +25 -0
  48. luna_quantum/client/schemas/create/qpu_token_time_quota.py +29 -0
  49. luna_quantum/client/schemas/create/qubo.py +19 -0
  50. luna_quantum/client/schemas/create/solve_job_create.py +43 -0
  51. luna_quantum/client/schemas/enums/__init__.py +0 -0
  52. luna_quantum/client/schemas/enums/call_style.py +13 -0
  53. luna_quantum/client/schemas/enums/circuit.py +42 -0
  54. luna_quantum/client/schemas/enums/model_format.py +11 -0
  55. luna_quantum/client/schemas/enums/problem.py +50 -0
  56. luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
  57. luna_quantum/client/schemas/enums/sense.py +8 -0
  58. luna_quantum/client/schemas/enums/status.py +40 -0
  59. luna_quantum/client/schemas/enums/timeframe.py +11 -0
  60. luna_quantum/client/schemas/error_message.py +14 -0
  61. luna_quantum/client/schemas/model_metadata.py +35 -0
  62. luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
  63. luna_quantum/client/schemas/qpu_token/qpu_token.py +161 -0
  64. luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
  65. luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +28 -0
  66. luna_quantum/client/schemas/qpu_token/token_provider.py +135 -0
  67. luna_quantum/client/schemas/representation.py +19 -0
  68. luna_quantum/client/schemas/solution.py +106 -0
  69. luna_quantum/client/schemas/solve_job.py +47 -0
  70. luna_quantum/client/schemas/solver_info.py +11 -0
  71. luna_quantum/client/schemas/user.py +11 -0
  72. luna_quantum/client/schemas/wrappers/__init__.py +5 -0
  73. luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
  74. luna_quantum/client/utils/__init__.py +0 -0
  75. luna_quantum/client/utils/qpu_token_utils.py +147 -0
  76. luna_quantum/errors.py +1 -0
  77. luna_quantum/errors.pyi +202 -0
  78. luna_quantum/exceptions/__init__.py +0 -0
  79. luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
  80. luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
  81. luna_quantum/factories/__init__.py +4 -0
  82. luna_quantum/factories/luna_solve_client_factory.py +75 -0
  83. luna_quantum/factories/usecase_factory.py +457 -0
  84. luna_quantum/py.typed +0 -0
  85. luna_quantum/solve/__init__.py +13 -0
  86. luna_quantum/solve/default_token.py +304 -0
  87. luna_quantum/solve/domain/__init__.py +0 -0
  88. luna_quantum/solve/domain/abstract/__init__.py +4 -0
  89. luna_quantum/solve/domain/abstract/luna_algorithm.py +203 -0
  90. luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
  91. luna_quantum/solve/domain/model_metadata.py +54 -0
  92. luna_quantum/solve/domain/solve_job.py +187 -0
  93. luna_quantum/solve/errors/__init__.py +0 -0
  94. luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
  95. luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
  96. luna_quantum/solve/errors/solve_base_error.py +5 -0
  97. luna_quantum/solve/errors/token_missing_error.py +11 -0
  98. luna_quantum/solve/interfaces/__init__.py +0 -0
  99. luna_quantum/solve/interfaces/algorithm_i.py +47 -0
  100. luna_quantum/solve/interfaces/backend_i.py +28 -0
  101. luna_quantum/solve/interfaces/usecases/__init__.py +55 -0
  102. luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
  103. luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
  104. luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
  105. luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
  106. luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
  107. luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
  108. luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
  109. luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
  110. luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
  111. luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
  112. luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
  113. luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
  114. luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
  115. luna_quantum/solve/parameters/__init__.py +0 -0
  116. luna_quantum/solve/parameters/algorithms/__init__.py +49 -0
  117. luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
  118. luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
  119. luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
  120. luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +78 -0
  121. luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +120 -0
  122. luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
  123. luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
  124. luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
  125. luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
  126. luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
  127. luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
  128. luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
  129. luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
  130. luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
  131. luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
  132. luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
  133. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
  134. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
  135. luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
  136. luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
  137. luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
  138. luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +105 -0
  139. luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
  140. luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
  141. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +26 -0
  142. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
  143. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
  144. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +97 -0
  145. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
  146. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +104 -0
  147. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
  148. luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +109 -0
  149. luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
  150. luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +152 -0
  151. luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
  152. luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
  153. luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
  154. luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
  155. luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
  156. luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
  157. luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
  158. luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
  159. luna_quantum/solve/parameters/backends/__init__.py +20 -0
  160. luna_quantum/solve/parameters/backends/aqarios.py +17 -0
  161. luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
  162. luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
  163. luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
  164. luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
  165. luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
  166. luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
  167. luna_quantum/solve/parameters/backends/dwave.py +17 -0
  168. luna_quantum/solve/parameters/backends/dwave_qpu.py +164 -0
  169. luna_quantum/solve/parameters/backends/ibm.py +132 -0
  170. luna_quantum/solve/parameters/backends/qctrl.py +130 -0
  171. luna_quantum/solve/parameters/backends/zib.py +17 -0
  172. luna_quantum/solve/parameters/constants.py +11 -0
  173. luna_quantum/solve/parameters/mixins/__init__.py +0 -0
  174. luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
  175. luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
  176. luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
  177. luna_quantum/solve/use_cases/__init__.py +119 -0
  178. luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
  179. luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
  180. luna_quantum/solve/use_cases/base.py +7 -0
  181. luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
  182. luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
  183. luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
  184. luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
  185. luna_quantum/solve/use_cases/exact_cover.py +51 -0
  186. luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
  187. luna_quantum/solve/use_cases/graph_coloring.py +42 -0
  188. luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
  189. luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
  190. luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
  191. luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
  192. luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
  193. luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
  194. luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
  195. luna_quantum/solve/use_cases/linear_regression.py +60 -0
  196. luna_quantum/solve/use_cases/lmwcs.py +84 -0
  197. luna_quantum/solve/use_cases/longest_path.py +50 -0
  198. luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
  199. luna_quantum/solve/use_cases/max2sat.py +54 -0
  200. luna_quantum/solve/use_cases/max3sat.py +55 -0
  201. luna_quantum/solve/use_cases/max_clique.py +60 -0
  202. luna_quantum/solve/use_cases/max_cut.py +48 -0
  203. luna_quantum/solve/use_cases/max_independent_set.py +37 -0
  204. luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
  205. luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
  206. luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
  207. luna_quantum/solve/use_cases/number_partitioning.py +32 -0
  208. luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
  209. luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
  210. luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
  211. luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
  212. luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
  213. luna_quantum/solve/use_cases/sensor_placement.py +58 -0
  214. luna_quantum/solve/use_cases/set_cover.py +56 -0
  215. luna_quantum/solve/use_cases/set_packing.py +54 -0
  216. luna_quantum/solve/use_cases/set_partitioning.py +52 -0
  217. luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
  218. luna_quantum/solve/use_cases/subset_sum.py +37 -0
  219. luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
  220. luna_quantum/solve/use_cases/traffic_flow.py +35 -0
  221. luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
  222. luna_quantum/solve/use_cases/type_aliases.py +9 -0
  223. luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
  224. luna_quantum/solve/usecases/__init__.py +45 -0
  225. luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
  226. luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
  227. luna_quantum/solve/usecases/model_get_solution_usecase.py +56 -0
  228. luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
  229. luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
  230. luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
  231. luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
  232. luna_quantum/solve/usecases/model_save_usecase.py +63 -0
  233. luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
  234. luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
  235. luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
  236. luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
  237. luna_quantum/solve/usecases/solve_job_get_result_usecase.py +97 -0
  238. luna_quantum/translator.py +1 -0
  239. luna_quantum/translator.pyi +833 -0
  240. luna_quantum/util/__init__.py +0 -0
  241. luna_quantum/util/active_waiting.py +79 -0
  242. luna_quantum/util/class_patcher.py +164 -0
  243. luna_quantum/util/log_utils.py +167 -0
  244. luna_quantum/util/pretty_base.py +67 -0
  245. luna_quantum/util/pydantic_utils.py +38 -0
  246. luna_quantum/utils.py +54 -0
  247. luna_quantum/utils.pyi +35 -0
  248. luna_quantum-1.0.0.dist-info/METADATA +37 -0
  249. luna_quantum-1.0.0.dist-info/RECORD +252 -0
  250. luna_quantum-1.0.0.dist-info/WHEEL +4 -0
  251. luna_quantum-1.0.0.dist-info/licenses/LICENSE +176 -0
  252. luna_quantum-1.0.0.dist-info/licenses/NOTICE +13 -0
@@ -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,)
@@ -0,0 +1,95 @@
1
+ from luna_quantum.solve.domain.abstract import LunaAlgorithm
2
+ from luna_quantum.solve.parameters.backends import DWave
3
+
4
+
5
+ class PopulationAnnealing(LunaAlgorithm[DWave]):
6
+ """
7
+ Parameters for the Population Annealing algorithm.
8
+
9
+ Population Annealing uses a sequential Monte Carlo method to minimize the energy of
10
+ a population. The population consists of walkers that can explore their neighborhood
11
+ during the cooling process. Afterwards, walkers are removed and duplicated using
12
+ bias to lower energy. Eventually, a population collapse occurs where all walkers are
13
+ in the lowest energy state.
14
+
15
+ Attributes
16
+ ----------
17
+ max_iter: int
18
+ Maximum number of annealing iterations (temperature steps) to perform. Each
19
+ iteration involves lowering the temperature, allowing walkers to explore
20
+ locally, and then resampling the population based on Boltzmann weights.
21
+ Higher values allow for a more gradual cooling schedule, potentially finding
22
+ better solutions but increasing computation time. Default is 20,
23
+ which provides a reasonable balance for most problems.
24
+ max_time: int
25
+ Maximum time in seconds that the algorithm is allowed to run. Provides a hard
26
+ time limit regardless of convergence or iteration status. Useful for
27
+ time-constrained scenarios where some solution is needed within a specific
28
+ timeframe. Default is 2, which is relatively aggressive and may need to be
29
+ increased for complex problems.
30
+ fixed_temp_sampler_num_sweeps: int
31
+ Number of Monte Carlo sweeps to perform at each temperature level, where one
32
+ sweep attempts to update all variables once. More sweeps allow walkers to
33
+ explore their local configuration space more thoroughly, producing better
34
+ equilibrated samples but increasing computation time. This parameter directly
35
+ affects how well each walker samples its local energy landscape before
36
+ resampling occurs. Default is 10,000, which is suitable for thorough exploration
37
+ of moderate-sized problems.
38
+ fixed_temp_sampler_num_reads: int | None
39
+ Number of independent sampling runs to perform at each temperature level.
40
+ Each run effectively initializes a separate walker in the population. Multiple
41
+ reads provide better coverage of the solution space, increasing the diversity
42
+ of the initial population and improving the chances of finding the global
43
+ optimum. Default is None, which typically defaults to 1 or matches the number
44
+ """
45
+
46
+ max_iter: int = 20
47
+ max_time: int = 2
48
+
49
+ fixed_temp_sampler_num_sweeps: int = 10_000
50
+ fixed_temp_sampler_num_reads: int | None = None
51
+
52
+ @property
53
+ def algorithm_name(self) -> str:
54
+ """
55
+ Returns the name of the algorithm.
56
+
57
+ This abstract property method is intended to be overridden by subclasses.
58
+ It should provide the name of the algorithm being implemented.
59
+
60
+ Returns
61
+ -------
62
+ str
63
+ The name of the algorithm.
64
+ """
65
+ return "PA"
66
+
67
+ @classmethod
68
+ def get_default_backend(cls) -> DWave:
69
+ """
70
+ Return the default backend implementation.
71
+
72
+ This property must be implemented by subclasses to provide
73
+ the default backend instance to use when no specific backend
74
+ is specified.
75
+
76
+ Returns
77
+ -------
78
+ IBackend
79
+ An instance of a class implementing the IBackend interface that serves
80
+ as the default backend.
81
+ """
82
+ return DWave()
83
+
84
+ @classmethod
85
+ def get_compatible_backends(cls) -> tuple[type[DWave], ...]:
86
+ """
87
+ Check at runtime if the used backend is compatible with the solver.
88
+
89
+ Returns
90
+ -------
91
+ tuple[type[IBackend], ...]
92
+ True if the backend is compatible with the solver, False otherwise.
93
+
94
+ """
95
+ return (DWave,)
@@ -0,0 +1,141 @@
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
+ SimulatedAnnealingBaseParams,
8
+ )
9
+ from luna_quantum.solve.parameters.backends import DWave
10
+ from luna_quantum.solve.parameters.mixins.qbsolv_like_mixin import QBSolvLikeMixin
11
+
12
+
13
+ class QBSolvLikeSimulatedAnnealing(LunaAlgorithm[DWave], QBSolvLikeMixin):
14
+ """
15
+ QBSolv Like Simulated Annealing solver.
16
+
17
+ QBSolv Like Simulated Annealing breaks down the problem and solves the parts
18
+ individually using a classic solver that uses Simulated Annealing.
19
+ This particular implementation uses hybrid.SimulatedAnnealingSubproblemSampler
20
+ (https://docs.ocean.dwavesys.com/projects/hybrid/en/stable/reference/samplers.html#simulatedannealingsubproblemsampler)
21
+ as a sampler for the subproblems to achieve a QBSolv like behaviour.
22
+
23
+ This class combines parameters from multiple sources:
24
+ - QBSolvLikeMixin: Provides parameters for the QBSolv-like decomposition approach
25
+ - SimulatedAnnealingParams: Provides parameters specific to simulated annealing
26
+
27
+ Attributes
28
+ ----------
29
+ decomposer_size: int
30
+ Size for the decomposer, which determines the maximum subproblem size to be
31
+ handled in each iteration. Larger values may produce better solutions but
32
+ increase computational complexity exponentially. Default is 50, which balances
33
+ solution quality with reasonable runtime.
34
+ rolling: bool
35
+ Whether to use rolling window decomposition for the solver. When enabled,
36
+ this allows for overlapping subproblems with shared variables, which can
37
+ improve solution quality by better handling interactions across subproblem
38
+ boundaries. Default is True.
39
+ rolling_history: float
40
+ Rolling history factor controlling how much of previous subproblem solutions
41
+ are considered when solving subsequent subproblems. Higher values incorporate
42
+ more historical information but may slow convergence to new solutions.
43
+ Default is 0.15 (15% retention).
44
+ max_iter: int | None
45
+ Maximum number of iterations (decomposition and solving cycles) to perform.
46
+ Higher values allow for more thorough optimization but increase runtime.
47
+ Default is 100.
48
+ max_time: int
49
+ Time in seconds after which the algorithm will stop, regardless of convergence
50
+ status. Provides a hard time limit for time-constrained applications.
51
+ Default is 5.
52
+ convergence: int
53
+ Number of iterations with unchanged output to terminate algorithm. Higher values
54
+ ensure more stable solutions but may increase computation time unnecessarily
55
+ if the algorithm has already found the best solution. Default is 3.
56
+ target: float | None
57
+ Energy level that the algorithm tries to reach. If this target energy is
58
+ achieved, the algorithm will terminate early. Default is None, meaning the
59
+ algorithm will run until other stopping criteria are met.
60
+ rtol: float
61
+ Relative tolerance for convergence. Used when comparing energy values between
62
+ iterations to determine if significant improvement has occurred. Default uses
63
+ DEFAULT_RTOL.
64
+ atol: float
65
+ Absolute tolerance for convergence. Used alongside rtol when comparing energy
66
+ values to determine if the algorithm has converged. Default uses DEFAULT_ATOL.
67
+ num_reads : Union[int, None]
68
+ Number of independent runs of the algorithm, each producing one solution sample.
69
+ Multiple reads with different random starting points increase the chance of
70
+ finding the global optimum. Default is None, which matches the number of initial
71
+ states (or just one read if no initial states are provided).
72
+ num_sweeps : Union[int, None]
73
+ Number of iterations/sweeps per run, where each sweep updates all variables
74
+ once. More sweeps allow more thorough exploration but increase runtime.
75
+ Default is 1,000, suitable for small to medium problems.
76
+ beta_range : Union[List[float], Tuple[float, float], None]
77
+ The inverse temperature (β=1/T) schedule endpoints, specified as [start, end].
78
+ A wider range allows more exploration. Default is calculated based on the
79
+ problem's energy scale to ensure appropriate acceptance probabilities.
80
+ beta_schedule_type : Literal["linear", "geometric"]
81
+ How beta values change between endpoints:
82
+ - "linear": Equal steps (β₁, β₂, ...) - smoother transitions
83
+ - "geometric": Multiplicative steps (β₁, r·β₁, r²·β₁, ...) - spends more time at
84
+ lower temperatures for fine-tuning
85
+ Default is "geometric", which often performs better for optimization problems.
86
+ initial_states_generator : Literal["none", "tile", "random"]
87
+ How to handle cases with fewer initial states than num_reads:
88
+ - "none": Raises error if insufficient initial states
89
+ - "tile": Reuses provided states by cycling through them
90
+ - "random": Generates additional random states as needed
91
+ Default is "random", which maximizes exploration.
92
+ """
93
+
94
+ simulated_annealing: SimulatedAnnealingBaseParams = Field(
95
+ default_factory=SimulatedAnnealingBaseParams
96
+ )
97
+
98
+ @property
99
+ def algorithm_name(self) -> str:
100
+ """
101
+ Returns the name of the algorithm.
102
+
103
+ This abstract property method is intended to be overridden by subclasses.
104
+ It should provide the name of the algorithm being implemented.
105
+
106
+ Returns
107
+ -------
108
+ str
109
+ The name of the algorithm.
110
+ """
111
+ return "QLSA"
112
+
113
+ @classmethod
114
+ def get_default_backend(cls) -> DWave:
115
+ """
116
+ Return the default backend implementation.
117
+
118
+ This property must be implemented by subclasses to provide
119
+ the default backend instance to use when no specific backend
120
+ is specified.
121
+
122
+ Returns
123
+ -------
124
+ IBackend
125
+ An instance of a class implementing the IBackend interface that serves
126
+ as the default backend.
127
+ """
128
+ return DWave()
129
+
130
+ @classmethod
131
+ def get_compatible_backends(cls) -> tuple[type[DWave]]:
132
+ """
133
+ Check at runtime if the used backend is compatible with the solver.
134
+
135
+ Returns
136
+ -------
137
+ tuple[type[IBackend], ...]
138
+ True if the backend is compatible with the solver, False otherwise.
139
+
140
+ """
141
+ return (DWave,)