luna-quantum 1.1.0__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. luna_quantum/__init__.py +139 -0
  2. luna_quantum/__init__.pyi +98 -0
  3. luna_quantum/_core.cp312-win_amd64.pyd +0 -0
  4. luna_quantum/_core.pyi +4286 -0
  5. luna_quantum/_utility.py +148 -0
  6. luna_quantum/_utility.pyi +20 -0
  7. luna_quantum/algorithms/__init__.py +1 -0
  8. luna_quantum/aqm_overwrites/__init__.py +3 -0
  9. luna_quantum/aqm_overwrites/model.py +184 -0
  10. luna_quantum/backends/__init__.py +1 -0
  11. luna_quantum/client/__init__.py +0 -0
  12. luna_quantum/client/controllers/__init__.py +4 -0
  13. luna_quantum/client/controllers/luna_http_client.py +37 -0
  14. luna_quantum/client/controllers/luna_platform_client.py +256 -0
  15. luna_quantum/client/controllers/luna_q.py +67 -0
  16. luna_quantum/client/controllers/luna_solve.py +129 -0
  17. luna_quantum/client/error/__init__.py +0 -0
  18. luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
  19. luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
  20. luna_quantum/client/error/luna_error.py +2 -0
  21. luna_quantum/client/error/luna_server_error.py +20 -0
  22. luna_quantum/client/error/timeout_error.py +12 -0
  23. luna_quantum/client/error/transformation_error.py +18 -0
  24. luna_quantum/client/error/utils/__init__.py +0 -0
  25. luna_quantum/client/error/utils/http_error_utils.py +112 -0
  26. luna_quantum/client/interfaces/__init__.py +4 -0
  27. luna_quantum/client/interfaces/clients/__init__.py +25 -0
  28. luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
  29. luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
  30. luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
  31. luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
  32. luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
  33. luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
  34. luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
  35. luna_quantum/client/interfaces/services/__init__.py +0 -0
  36. luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
  37. luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
  38. luna_quantum/client/interfaces/services/service_i.py +56 -0
  39. luna_quantum/client/rest_client/__init__.py +15 -0
  40. luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
  41. luna_quantum/client/rest_client/info_rest_client.py +74 -0
  42. luna_quantum/client/rest_client/model_rest_client.py +216 -0
  43. luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
  44. luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
  45. luna_quantum/client/rest_client/users_rest_client.py +35 -0
  46. luna_quantum/client/schemas/__init__.py +26 -0
  47. luna_quantum/client/schemas/circuit.py +48 -0
  48. luna_quantum/client/schemas/create/__init__.py +15 -0
  49. luna_quantum/client/schemas/create/circuit.py +30 -0
  50. luna_quantum/client/schemas/create/optimization.py +39 -0
  51. luna_quantum/client/schemas/create/qpu_token.py +22 -0
  52. luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
  53. luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
  54. luna_quantum/client/schemas/create/qubo.py +19 -0
  55. luna_quantum/client/schemas/create/solve_job_create.py +43 -0
  56. luna_quantum/client/schemas/enums/__init__.py +0 -0
  57. luna_quantum/client/schemas/enums/call_style.py +13 -0
  58. luna_quantum/client/schemas/enums/circuit.py +42 -0
  59. luna_quantum/client/schemas/enums/model_format.py +11 -0
  60. luna_quantum/client/schemas/enums/problem.py +50 -0
  61. luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
  62. luna_quantum/client/schemas/enums/sense.py +8 -0
  63. luna_quantum/client/schemas/enums/status.py +40 -0
  64. luna_quantum/client/schemas/enums/timeframe.py +11 -0
  65. luna_quantum/client/schemas/error_message.py +14 -0
  66. luna_quantum/client/schemas/model_metadata.py +35 -0
  67. luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
  68. luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
  69. luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
  70. luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
  71. luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
  72. luna_quantum/client/schemas/representation.py +19 -0
  73. luna_quantum/client/schemas/solution.py +106 -0
  74. luna_quantum/client/schemas/solve_job.py +50 -0
  75. luna_quantum/client/schemas/solver_info.py +11 -0
  76. luna_quantum/client/schemas/user.py +11 -0
  77. luna_quantum/client/schemas/wrappers/__init__.py +5 -0
  78. luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
  79. luna_quantum/client/utils/__init__.py +0 -0
  80. luna_quantum/client/utils/qpu_token_utils.py +147 -0
  81. luna_quantum/config.py +11 -0
  82. luna_quantum/decorators.py +248 -0
  83. luna_quantum/errors.py +34 -0
  84. luna_quantum/errors.pyi +287 -0
  85. luna_quantum/exceptions/__init__.py +0 -0
  86. luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
  87. luna_quantum/exceptions/luna_quantum_call_type_error.py +9 -0
  88. luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
  89. luna_quantum/factories/__init__.py +4 -0
  90. luna_quantum/factories/luna_solve_client_factory.py +100 -0
  91. luna_quantum/factories/usecase_factory.py +489 -0
  92. luna_quantum/py.typed +0 -0
  93. luna_quantum/solve/__init__.py +13 -0
  94. luna_quantum/solve/default_token.py +304 -0
  95. luna_quantum/solve/domain/__init__.py +0 -0
  96. luna_quantum/solve/domain/abstract/__init__.py +4 -0
  97. luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
  98. luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
  99. luna_quantum/solve/domain/model_metadata.py +56 -0
  100. luna_quantum/solve/domain/solve_job.py +230 -0
  101. luna_quantum/solve/errors/__init__.py +0 -0
  102. luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
  103. luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
  104. luna_quantum/solve/errors/solve_base_error.py +5 -0
  105. luna_quantum/solve/errors/token_missing_error.py +11 -0
  106. luna_quantum/solve/interfaces/__init__.py +0 -0
  107. luna_quantum/solve/interfaces/algorithm_i.py +49 -0
  108. luna_quantum/solve/interfaces/backend_i.py +28 -0
  109. luna_quantum/solve/interfaces/usecases/__init__.py +59 -0
  110. luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
  111. luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
  112. luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
  113. luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
  114. luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
  115. luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
  116. luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
  117. luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
  118. luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
  119. luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
  120. luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
  121. luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
  122. luna_quantum/solve/interfaces/usecases/solve_job_get_by_id_usecase_i.py +27 -0
  123. luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
  124. luna_quantum/solve/parameters/__init__.py +0 -0
  125. luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
  126. luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
  127. luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
  128. luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
  129. luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
  130. luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
  131. luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
  132. luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
  133. luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
  134. luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
  135. luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
  136. luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
  137. luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
  138. luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
  139. luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
  140. luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
  141. luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
  142. luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
  143. luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
  144. luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
  145. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
  146. luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
  147. luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
  148. luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
  149. luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
  150. luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
  151. luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
  152. luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
  153. luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +10 -0
  154. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/__init__.py +29 -0
  155. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/config.py +58 -0
  156. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/flexqaoa.py +188 -0
  157. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/optimizers.py +53 -0
  158. luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/pipeline.py +164 -0
  159. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +112 -0
  160. luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
  161. luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
  162. luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
  163. luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
  164. luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
  165. luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
  166. luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
  167. luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
  168. luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
  169. luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
  170. luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
  171. luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
  172. luna_quantum/solve/parameters/backends/__init__.py +27 -0
  173. luna_quantum/solve/parameters/backends/aqarios.py +17 -0
  174. luna_quantum/solve/parameters/backends/aqarios_gpu.py +17 -0
  175. luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
  176. luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
  177. luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
  178. luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
  179. luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
  180. luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
  181. luna_quantum/solve/parameters/backends/cudaq/__init__.py +5 -0
  182. luna_quantum/solve/parameters/backends/cudaq/cudaq_base.py +16 -0
  183. luna_quantum/solve/parameters/backends/cudaq/cudaq_cpu.py +30 -0
  184. luna_quantum/solve/parameters/backends/cudaq/cudaq_gpu.py +32 -0
  185. luna_quantum/solve/parameters/backends/dwave.py +17 -0
  186. luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
  187. luna_quantum/solve/parameters/backends/fda.py +17 -0
  188. luna_quantum/solve/parameters/backends/ibm.py +138 -0
  189. luna_quantum/solve/parameters/backends/qctrl.py +103 -0
  190. luna_quantum/solve/parameters/backends/zib.py +17 -0
  191. luna_quantum/solve/parameters/constants.py +11 -0
  192. luna_quantum/solve/parameters/errors.py +30 -0
  193. luna_quantum/solve/parameters/mixins/__init__.py +0 -0
  194. luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
  195. luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
  196. luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
  197. luna_quantum/solve/use_cases/__init__.py +119 -0
  198. luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
  199. luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
  200. luna_quantum/solve/use_cases/base.py +7 -0
  201. luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
  202. luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
  203. luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
  204. luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
  205. luna_quantum/solve/use_cases/exact_cover.py +51 -0
  206. luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
  207. luna_quantum/solve/use_cases/graph_coloring.py +42 -0
  208. luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
  209. luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
  210. luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
  211. luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
  212. luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
  213. luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
  214. luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
  215. luna_quantum/solve/use_cases/linear_regression.py +60 -0
  216. luna_quantum/solve/use_cases/lmwcs.py +84 -0
  217. luna_quantum/solve/use_cases/longest_path.py +50 -0
  218. luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
  219. luna_quantum/solve/use_cases/max2sat.py +54 -0
  220. luna_quantum/solve/use_cases/max3sat.py +55 -0
  221. luna_quantum/solve/use_cases/max_clique.py +60 -0
  222. luna_quantum/solve/use_cases/max_cut.py +48 -0
  223. luna_quantum/solve/use_cases/max_independent_set.py +37 -0
  224. luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
  225. luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
  226. luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
  227. luna_quantum/solve/use_cases/number_partitioning.py +32 -0
  228. luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
  229. luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
  230. luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
  231. luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
  232. luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
  233. luna_quantum/solve/use_cases/sensor_placement.py +58 -0
  234. luna_quantum/solve/use_cases/set_cover.py +56 -0
  235. luna_quantum/solve/use_cases/set_packing.py +54 -0
  236. luna_quantum/solve/use_cases/set_partitioning.py +52 -0
  237. luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
  238. luna_quantum/solve/use_cases/subset_sum.py +37 -0
  239. luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
  240. luna_quantum/solve/use_cases/traffic_flow.py +35 -0
  241. luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
  242. luna_quantum/solve/use_cases/type_aliases.py +9 -0
  243. luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
  244. luna_quantum/solve/usecases/__init__.py +45 -0
  245. luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
  246. luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
  247. luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
  248. luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
  249. luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
  250. luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
  251. luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
  252. luna_quantum/solve/usecases/model_save_usecase.py +63 -0
  253. luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
  254. luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
  255. luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
  256. luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
  257. luna_quantum/solve/usecases/solve_job_get_by_id_usecase.py +44 -0
  258. luna_quantum/solve/usecases/solve_job_get_result_usecase.py +105 -0
  259. luna_quantum/transformations.py +18 -0
  260. luna_quantum/transformations.pyi +371 -0
  261. luna_quantum/translator.py +23 -0
  262. luna_quantum/translator.pyi +869 -0
  263. luna_quantum/util/__init__.py +0 -0
  264. luna_quantum/util/active_waiting.py +79 -0
  265. luna_quantum/util/class_patcher.py +164 -0
  266. luna_quantum/util/debug_info.py +52 -0
  267. luna_quantum/util/log_utils.py +187 -0
  268. luna_quantum/util/pretty_base.py +67 -0
  269. luna_quantum/util/pydantic_utils.py +38 -0
  270. luna_quantum/utils.py +3 -0
  271. luna_quantum/utils.pyi +67 -0
  272. luna_quantum-1.1.0.dist-info/METADATA +36 -0
  273. luna_quantum-1.1.0.dist-info/RECORD +276 -0
  274. luna_quantum-1.1.0.dist-info/WHEEL +4 -0
  275. luna_quantum-1.1.0.dist-info/licenses/LICENSE +176 -0
  276. luna_quantum-1.1.0.dist-info/licenses/NOTICE +13 -0
@@ -0,0 +1,122 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import BaseModel, Field, field_validator
4
+
5
+ ScipyOptimizerMethod = Literal[
6
+ "nelder-mead",
7
+ "powell",
8
+ "cg",
9
+ "bfgs",
10
+ "newton-cg",
11
+ "l-bfgs-b",
12
+ "tnc",
13
+ "cobyla",
14
+ "cobyqa",
15
+ "slsqp",
16
+ "trust-constr",
17
+ "dogleg",
18
+ "trust-ncg",
19
+ "trust-exact",
20
+ "trust-krylov",
21
+ "NELDER-MEAD",
22
+ "POWELL",
23
+ "CG",
24
+ "BFGS",
25
+ "NEWTON-CG",
26
+ "L-BFGS-B",
27
+ "TNC",
28
+ "COBYLA",
29
+ "COBYQA",
30
+ "SLSQP",
31
+ "TRUST-CONSTR",
32
+ "DOGLEG",
33
+ "TRUST-NCG",
34
+ "TRUST-EXACT",
35
+ "TRUST-KRYLOV",
36
+ "Nelder-Mead",
37
+ "Newton-CG",
38
+ ]
39
+
40
+
41
+ class ScipyOptimizerParams(BaseModel):
42
+ """Wrapper for scipy.optimize.minimize.
43
+
44
+ See [SciPy minimize documentation](
45
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
46
+ for more information of the available methods and parameters.
47
+
48
+ Attributes
49
+ ----------
50
+ method: ScipyOptimizerMethod
51
+ Type of solver. See
52
+ [SciPy minimize documentation](
53
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html)
54
+ for supported methods.
55
+ tol: float | None
56
+ Tolerance for termination.
57
+ bounds: None | list[tuple[float, float]]
58
+ Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell,
59
+ trust-constr, COBYLA, and COBYQA methods. `None` is used to specify no bounds.
60
+ A sequence of `(min, max)` can be used to specify bounds for each parameter
61
+ individually.
62
+ jac: None | Literal["2-point", "3-point", "cs"]
63
+ Method for computing the gradient vector. Only for CG, BFGS, Newton-CG,
64
+ L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact and
65
+ trust-constr.
66
+ hess: None | Literal["2-point", "3-point", "cs"]
67
+ Method for computing the Hessian matrix. Only for Newton-CG, dogleg, trust-ncg,
68
+ trust-krylov, trust-exact and trust-constr.
69
+ maxiter: int
70
+ Maximum number of iterations to perform. Depending on the method
71
+ each iteration may use several function evaluations. Will be ignored for TNC
72
+ optimizer. Default: 100
73
+ options: dict[str, float]
74
+ A dictionary of solver options.
75
+ """
76
+
77
+ method: ScipyOptimizerMethod = Field(
78
+ default="cobyla",
79
+ description="Type of solver. See "
80
+ "https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html"
81
+ "for supported methods.",
82
+ )
83
+ tol: float | None = Field(
84
+ default=None, ge=0, description="Tolerance for termination."
85
+ )
86
+ bounds: None | list[tuple[float, float]] = Field(
87
+ default=None,
88
+ description="Bounds on variables for Nelder-Mead, L-BFGS-B, TNC, SLSQP, Powell,"
89
+ "trust-constr, COBYLA, and COBYQA methods. None is used to specify no bounds. "
90
+ "A sequence of `(min, max)` can be used to specify bounds for each parameter "
91
+ "individually.",
92
+ )
93
+ jac: None | Literal["2-point", "3-point", "cs"] = Field(
94
+ default=None,
95
+ description="Method for computing the gradient vector. Only for CG, BFGS, "
96
+ "Newton-CG, L-BFGS-B, TNC, SLSQP, dogleg, trust-ncg, trust-krylov, trust-exact "
97
+ "and trust-constr.",
98
+ )
99
+ hess: None | Literal["2-point", "3-point", "cs"] = Field(
100
+ default=None,
101
+ description="Method for computing the Hessian matrix. Only for Newton-CG, "
102
+ "dogleg, trust-ncg, trust-krylov, trust-exact and trust-constr.",
103
+ )
104
+ maxiter: int = Field(
105
+ default=100,
106
+ ge=1,
107
+ le=10000,
108
+ description="Maximum number of iterations to perform. Depending on the method "
109
+ "each iteration may use several function evaluations. Will be ignored for TNC "
110
+ "optimizer.",
111
+ )
112
+ options: dict[str, float] = Field(
113
+ default_factory=dict, description="A dictionary of solver options."
114
+ )
115
+
116
+ @field_validator("options", mode="after")
117
+ @classmethod
118
+ def _ensure_no_maxiter(cls, v: dict[str, float]) -> dict[str, float]:
119
+ if "maxiter" in v:
120
+ msg = "Please do not specify `maxiter` in options dict."
121
+ raise ValueError(msg)
122
+ return v
@@ -0,0 +1,106 @@
1
+ from collections.abc import Sequence
2
+ from typing import Any, Literal
3
+
4
+ from pydantic import BaseModel
5
+
6
+
7
+ class SimulatedAnnealingBaseParams(BaseModel):
8
+ """
9
+ Parameters for the Simulated Annealing optimization algorithm.
10
+
11
+ This class extends the basic SimulatedAnnealing parameters with additional controls
12
+ for more fine-grained customization of the annealing process, allowing advanced
13
+ users to tune the algorithm for specific problem characteristics.
14
+
15
+ Simulated Annealing mimics the physical annealing process where a material is heated
16
+ and then slowly cooled to remove defects. In optimization, this translates to
17
+ initially accepting many non-improving moves (high temperature) and gradually
18
+ becoming more selective (cooling) to converge to an optimum.
19
+
20
+ Attributes
21
+ ----------
22
+ num_reads : Union[int, None]
23
+ Number of independent runs of the algorithm, each producing one solution sample.
24
+ Multiple reads with different random starting points increase the chance of
25
+ finding the global optimum. Default is None, which matches the number of initial
26
+ states (or just one read if no initial states are provided).
27
+ num_sweeps : Union[int, None]
28
+ Number of iterations/sweeps per run, where each sweep updates all variables
29
+ once. More sweeps allow more thorough exploration but increase runtime.
30
+ Default is 1,000, suitable for small to medium problems.
31
+ beta_range : Union[List[float], Tuple[float, float], None]
32
+ The inverse temperature (β=1/T) schedule endpoints, specified as [start, end].
33
+ A wider range allows more exploration. Default is calculated based on the
34
+ problem's energy scale to ensure appropriate acceptance probabilities.
35
+ beta_schedule_type : Literal["linear", "geometric"]
36
+ How beta values change between endpoints:
37
+ - "linear": Equal steps (β₁, β₂, ...) - smoother transitions
38
+ - "geometric": Multiplicative steps (β₁, r·β₁, r²·β₁, ...) - spends more time at
39
+ lower temperatures for fine-tuning
40
+ Default is "geometric", which often performs better for optimization problems.
41
+ initial_states_generator : Literal["none", "tile", "random"]
42
+ How to handle cases with fewer initial states than num_reads:
43
+ - "none": Raises error if insufficient initial states
44
+ - "tile": Reuses provided states by cycling through them
45
+ - "random": Generates additional random states as needed
46
+ Default is "random", which maximizes exploration.
47
+ """
48
+
49
+ num_reads: int | None = None
50
+ num_sweeps: int | None = 1_000
51
+ beta_range: list[float] | tuple[float, float] | None = None
52
+ beta_schedule_type: Literal["linear", "geometric"] = "geometric"
53
+ initial_states_generator: Literal["none", "tile", "random"] = "random"
54
+
55
+
56
+ class SimulatedAnnealingParams(SimulatedAnnealingBaseParams):
57
+ """
58
+ Extended parameters for the Simulated Annealing optimization algorithm.
59
+
60
+ This class extends the basic SimulatedAnnealing parameters with additional controls
61
+ for more fine-grained customization of the annealing process, allowing advanced
62
+ users to tune the algorithm for specific problem characteristics.
63
+
64
+ Simulated Annealing mimics the physical annealing process where a material is heated
65
+ and then slowly cooled to remove defects. In optimization, this translates to
66
+ initially accepting many non-improving moves (high temperature) and gradually
67
+ becoming more selective (cooling) to converge to an optimum.
68
+
69
+ Attributes
70
+ ----------
71
+ num_sweeps_per_beta: int
72
+ Number of sweeps to perform at each temperature before cooling. More sweeps
73
+ per temperature allow better exploration at each temperature level.
74
+ Default is 1, which works well for many problems.
75
+ seed: Optional[int]
76
+ Random seed for reproducible results. Using the same seed with identical
77
+ parameters produces identical results. Default is None (random seed).
78
+ beta_schedule: Sequence[float] | None
79
+ Explicit sequence of beta (inverse temperature) values to use. Provides complete
80
+ control over the cooling schedule. Format must be compatible with numpy.array.
81
+ Default is None, which generates a schedule based on beta_range and
82
+ beta_schedule_type.
83
+ initial_states: Optional[Any]
84
+ One or more starting states, each defining values for all problem variables.
85
+ This allows the algorithm to start from promising regions rather than random
86
+ points.
87
+ Default is None (random starting states).
88
+ randomize_order: bool
89
+ When True, variables are updated in random order during each sweep.
90
+ When False, variables are updated sequentially. Random updates preserve
91
+ symmetry of the model but are slightly slower. Default is False for efficiency.
92
+ proposal_acceptance_criteria: Literal["Gibbs", "Metropolis"]
93
+ Method for accepting or rejecting proposed moves:
94
+ - "Gibbs": Samples directly from conditional probability distribution
95
+ - "Metropolis": Uses Metropolis-Hastings rule (accept if improving, otherwise
96
+ accept with probability based on energy difference and temperature)
97
+ Default is "Metropolis", which is typically faster and works well for most
98
+ problems.
99
+ """
100
+
101
+ num_sweeps_per_beta: int = 1
102
+ seed: int | None = None
103
+ beta_schedule: Sequence[float] | None = None
104
+ initial_states: Any | None = None
105
+ randomize_order: bool = False
106
+ proposal_acceptance_criteria: Literal["Gibbs", "Metropolis"] = "Metropolis"
@@ -0,0 +1,39 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class TabuKerberosParams(BaseModel):
7
+ """
8
+ Mixin class that provides parameters for TabuKerberos algorithm.
9
+
10
+ TabuKerberos implements a specialized version of TabuSearch with time-based
11
+ constraints. This mixin provides the parameters needed to configure the
12
+ tabu search component.
13
+
14
+ Attributes
15
+ ----------
16
+ num_reads: Optional[int]
17
+ Number of reads. Each read is generated by one run of the tabu algorithm.
18
+ Default is None, which matches the number of initial states or uses one
19
+ if no initial states are provided.
20
+ tenure: Optional[int]
21
+ Tabu tenure, which is the length of the tabu list, or number of recently
22
+ explored solutions kept in memory. Default is None (a quarter of the
23
+ number of problem variables up to a maximum value of 20).
24
+ timeout: float
25
+ Maximum running time per read in milliseconds. Default is 100.
26
+ initial_states_generator: Literal['none', 'tile', 'random']
27
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
28
+ specified. Default is "random".
29
+ max_time: float | None
30
+ Overall maximum duration in seconds for the entire tabu search algorithm.
31
+ Default is None (run until convergence criteria are met).
32
+ """
33
+
34
+ num_reads: int | None = None
35
+ tenure: int | None = Field(default=None, le=20)
36
+ timeout: float = 100
37
+ initial_states_generator: Literal["none", "tile", "random"] = "random"
38
+
39
+ max_time: float | None = None
@@ -0,0 +1,129 @@
1
+ from typing import Any, Literal
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class TabuSearchBaseParams(BaseModel):
7
+ """
8
+ Parameters for the Tabu Problem optimization algorithm.
9
+
10
+ Tabu Search is a metaheuristic that enhances local search by maintaining a
11
+ "tabu list" of recently visited solutions to avoid cycling. It systematically
12
+ explores the solution space by allowing non-improving moves when no improving moves
13
+ exist, while preventing revisiting recent solutions.
14
+
15
+ This class extends the basic TabuSearch with additional parameters for fine-tuning
16
+ the search process, including restart strategies and early termination conditions.
17
+
18
+ Attributes
19
+ ----------
20
+ num_reads: int | None
21
+ Number of independent runs of the tabu algorithm, each producing one solution.
22
+ Multiple reads increase the chance of finding the global optimum by starting
23
+ from different initial states. If None, matches the number of initial states
24
+ provided (or performs just one read if no initial states are given).
25
+ tenure: int | None
26
+ Length of the tabu list - the number of recently visited solutions that are
27
+ forbidden. Larger values help escape deeper local minima but may slow
28
+ exploration. Default is 1/4 of the number of variables up to a maximum of 20.
29
+ A good tenure balances diversification (exploring new regions) with
30
+ intensification (focusing on promising areas).
31
+ timeout: float
32
+ Maximum running time in milliseconds per read before the algorithm stops,
33
+ regardless of convergence. Default is 100, which is suitable for small to
34
+ medium-sized problems. For larger problems, consider increasing this value
35
+ to allow sufficient exploration time.
36
+ """
37
+
38
+ num_reads: int | None = None
39
+ tenure: int | None = Field(default=None, le=20)
40
+ timeout: float = 100
41
+
42
+
43
+ class TabuSearchParams(TabuSearchBaseParams):
44
+ """
45
+ Extended parameters for the Tabu Search optimization algorithm.
46
+
47
+ Tabu Search is a metaheuristic that enhances local search by maintaining a
48
+ "tabu list" of recently visited solutions to avoid cycling. It systematically
49
+ explores the solution space by allowing non-improving moves when no improving moves
50
+ exist, while preventing revisiting recent solutions.
51
+
52
+ This class extends the basic TabuSearch with additional parameters for fine-tuning
53
+ the search process, including restart strategies and early termination conditions.
54
+
55
+ Attributes
56
+ ----------
57
+ initial_states: Any | None
58
+ Starting states for the search. Allows the algorithm to begin from promising
59
+ regions rather than random points. If fewer states than num_reads are provided,
60
+ additional states are generated according to initial_states_generator.
61
+ Default is None (random starting states).
62
+ seed: int | None
63
+ Random seed for reproducible results. With identical parameters and seed,
64
+ results will be identical (unless timeout limits are reached, as finite
65
+ clock resolution can affect execution). Default is None (random seed).
66
+ num_restarts: int
67
+ Maximum number of tabu search restarts per read. Restarts help escape deep
68
+ local minima by starting fresh from new points after the initial search stalls.
69
+ Setting to zero results in a simple tabu search without restarts.
70
+ Default is 1,000,000, allowing many restarts if needed.
71
+ energy_threshold: float | None
72
+ Target energy value that triggers termination if found. Allows early stopping
73
+ when a sufficiently good solution is discovered. Default is None (run until
74
+ other stopping criteria are met).
75
+ coefficient_z_first: int | None
76
+ Controls the number of variable updates in the first simple tabu search (STS).
77
+ The actual limit is max(variables*coefficient_z_first, lower_bound_z).
78
+ Defaults to 10,000 for small problems (≤500 variables) and 25,000 for larger
79
+ ones. Higher values allow more thorough exploration of the initial solution
80
+ neighborhood.
81
+ coefficient_z_restart: int | None
82
+ Controls the number of variable updates in restarted tabu searches.
83
+ Similar to coefficient_z_first but for restart phases. Default is
84
+ coefficient_z_first/4, allowing faster exploration during restarts. This
85
+ typically results in broader but less deep searches after restarts.
86
+ lower_bound_z: int | None
87
+ Minimum number of variable updates for all tabu searches. Ensures a thorough
88
+ search even for small problems. Default is 500,000. Setting too low may
89
+ result in premature termination before finding good solutions.
90
+ initial_states_generator: Literal["none", "tile", "random"]
91
+ Controls how to handle situations where fewer initial states are provided
92
+ than num_reads:
93
+ - "none": Raises an error if insufficient initial states
94
+ - "tile": Reuses provided states by cycling through them
95
+ - "random": Generates additional random states as needed
96
+ Default is "random", which maximizes search space coverage when the number
97
+ of provided initial states is insufficient.
98
+ initial_states: Any | None
99
+ Starting states for the search. Allows the algorithm to begin from promising
100
+ regions rather than random points. If fewer states than num_reads are provided,
101
+ additional states are generated according to initial_states_generator.
102
+ Default is None (random starting states).
103
+ num_reads: int | None
104
+ Number of independent runs of the tabu algorithm, each producing one solution.
105
+ Multiple reads increase the chance of finding the global optimum by starting
106
+ from different initial states. If None, matches the number of initial states
107
+ provided (or performs just one read if no initial states are given).
108
+ tenure: int | None
109
+ Length of the tabu list - the number of recently visited solutions that are
110
+ forbidden. Larger values help escape deeper local minima but may slow
111
+ exploration. Default is 1/4 of the number of variables up to a maximum of 20.
112
+ A good tenure balances diversification (exploring new regions) with
113
+ intensification (focusing on promising areas).
114
+ timeout: float
115
+ Maximum running time in milliseconds per read before the algorithm stops,
116
+ regardless of convergence. Default is 100, which is suitable for small to
117
+ medium-sized problems. For larger problems, consider increasing this value
118
+ to allow sufficient exploration time.
119
+ """
120
+
121
+ seed: int | None = None
122
+ num_restarts: int = 1_000_000
123
+ energy_threshold: float | None = None
124
+ coefficient_z_first: int | None = None
125
+ coefficient_z_restart: int | None = None
126
+ lower_bound_z: int | None = None
127
+
128
+ initial_states: Any | None = None
129
+ initial_states_generator: Literal["none", "tile", "random"] = "random"
@@ -0,0 +1,59 @@
1
+ from pydantic import Field
2
+
3
+ from luna_quantum.solve.domain.abstract.luna_algorithm import LunaAlgorithm
4
+ from luna_quantum.solve.interfaces.backend_i import IBackend
5
+ from luna_quantum.solve.parameters.backends.dwave import DWave
6
+
7
+
8
+ class FlexibleParameterAlgorithm(LunaAlgorithm[IBackend]):
9
+ """Define an algorithm with flexible parameter.
10
+
11
+ This class is used to represent algorithms with flexible parameters designed
12
+ to work with a specific backend system. It also provides methods to interact
13
+ with default and compatible backends.
14
+ """
15
+
16
+ luna_algorithm_name: str = Field(
17
+ ..., exclude=True, repr=False, alias="algorithm_name"
18
+ )
19
+
20
+ @property
21
+ def algorithm_name(self) -> str:
22
+ """
23
+ Get the name of the algorithm.
24
+
25
+ Returns
26
+ -------
27
+ str
28
+ The name of the algorithm used.
29
+ """
30
+ return self.luna_algorithm_name
31
+
32
+ @classmethod
33
+ def get_default_backend(cls) -> DWave:
34
+ """
35
+ Get the default backend for computations.
36
+
37
+ The method returns a default instance of the DWave class, which can
38
+ be used as a backend for computations.
39
+
40
+ Returns
41
+ -------
42
+ DWave
43
+ An instance of the DWave class.
44
+ """
45
+ return DWave()
46
+
47
+ @classmethod
48
+ def get_compatible_backends(cls) -> tuple[type[IBackend], ...]:
49
+ """
50
+ Get compatible backend classes.
51
+
52
+ Return a tuple of backend types that are compatible with the current class.
53
+
54
+ Returns
55
+ -------
56
+ tuple of type[IBackend, ...]
57
+ Tuple containing classes of compatible backends.
58
+ """
59
+ return (IBackend,)
@@ -0,0 +1,4 @@
1
+ from .qaga import QAGA
2
+ from .saga import SAGA
3
+
4
+ __all__ = ["QAGA", "SAGA"]
@@ -0,0 +1,131 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_quantum.solve.domain.abstract import LunaAlgorithm
6
+ from luna_quantum.solve.parameters.backends import DWaveQpu
7
+ from luna_quantum.solve.parameters.constants import DEFAULT_ATOL, DEFAULT_RTOL
8
+
9
+
10
+ class QAGA(LunaAlgorithm[DWaveQpu]):
11
+ """
12
+ Parameters for the Quantum Assisted Genetic Algorithm (QAGA).
13
+
14
+ QAGA combines quantum computing with genetic algorithms to enhance the search for
15
+ optimal solutions. It uses quantum annealing for mutation and recombination
16
+ operations, potentially allowing the algorithm to escape local optima more
17
+ effectively than classical genetic algorithms.
18
+
19
+ The algorithm maintains a population of candidate solutions that evolve through
20
+ selection, quantum-enhanced recombination, and mutation operations across
21
+ generations.
22
+
23
+ Attributes
24
+ ----------
25
+ p_size : int
26
+ Initial population size (number of candidate solutions). Larger populations
27
+ provide more diversity but require more computation. Default is 20, suitable
28
+ for small to medium problems.
29
+ p_inc_num : int
30
+ Number of new individuals added to the population after each generation.
31
+ Controls population growth rate. Default is 5, allowing moderate expansion.
32
+ p_max : int | None
33
+ Maximum population size. Once reached, no more growth occurs. Prevents
34
+ unbounded population expansion. Default is 160, balancing diversity with
35
+ computational cost.
36
+ pct_random_states : float
37
+ Percentage of random states added to the population after each iteration.
38
+ Helps maintain diversity and avoid premature convergence. Default is 0.25 (25%).
39
+ mut_rate : float
40
+ Mutation rate - probability to mutate an individual after each iteration.
41
+ Higher values favor exploration, lower values favor exploitation.
42
+ Default is 0.5, balanced between the two. Must be between 0.0 and 1.0.
43
+ rec_rate : int
44
+ Recombination rate - number of mates each individual is recombined with
45
+ per generation. Higher values increase genetic mixing. Default is 1.
46
+ rec_method : Literal["cluster_moves", "one_point_crossover", "random_crossover"]
47
+ Method used for recombining individuals:
48
+ - "cluster_moves": Swaps clusters of related variables between solutions
49
+ - "one_point_crossover": Splits solutions at a random point and exchanges parts
50
+ - "random_crossover": Randomly exchanges bits between parents
51
+ Default is "random_crossover", which provides good exploration.
52
+ select_method : Literal["simple", "shared_energy"]
53
+ Selection strategy for the next generation:
54
+ - "simple": Pure energy-based selection
55
+ - "shared_energy": Promotes diversity by penalizing similar solutions
56
+ Default is "simple", focusing on solution quality.
57
+ target : float | None
58
+ Target energy level to stop the algorithm. If None, runs until other criteria
59
+ are met. Default is None.
60
+ atol : float
61
+ Absolute tolerance when comparing energies to target. Default is 0.0.
62
+ rtol : float
63
+ Relative tolerance when comparing energies to target. Default is 0.0.
64
+ timeout : float
65
+ Maximum runtime in seconds. Includes preprocessing, network overhead, and
66
+ quantum processing time. Default is 60.0 seconds.
67
+ max_iter : Union[int, None]
68
+ Maximum number of generations before stopping. None means no limit.
69
+ Default is 100 generations.
70
+ """
71
+
72
+ p_size: int = 20
73
+ p_inc_num: int = 5
74
+ p_max: int | None = 160
75
+ pct_random_states: float = 0.25
76
+ mut_rate: float = Field(default=0.5, ge=0.0, le=1.0)
77
+ rec_rate: int = 1
78
+ rec_method: Literal["cluster_moves", "one_point_crossover", "random_crossover"] = (
79
+ "random_crossover"
80
+ )
81
+ select_method: Literal["simple", "shared_energy"] = "simple"
82
+ target: float | None = None
83
+ atol: float = DEFAULT_ATOL
84
+ rtol: float = DEFAULT_RTOL
85
+ timeout: float = 60.0
86
+ max_iter: int | None = 100
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 "QAGA+"
102
+
103
+ @classmethod
104
+ def get_default_backend(cls) -> DWaveQpu:
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 DWaveQpu()
119
+
120
+ @classmethod
121
+ def get_compatible_backends(cls) -> tuple[type[DWaveQpu], ...]:
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 (DWaveQpu,)