luna-quantum 1.0.8rc2__cp314-cp314-macosx_11_0_arm64.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.cpython-314-darwin.so +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,37 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class BinaryPaintShopProblem(UseCase):
9
+ r"""
10
+ # Binary Paint Shop.
11
+
12
+ Description
13
+ -----------
14
+
15
+ The Binary Paint Shop Problem tries to minimize the color change of a paint job with
16
+ two colors of a sequence of cars. The sequence consists of a fixed number of cars,
17
+ in which each car type occurs exactly twice and these are to be colored in different
18
+ colors. Therefore, the car sequence consists of exactly twice as many cars as there
19
+ are car types.
20
+
21
+ Links
22
+ -----
23
+
24
+ [Transformation](https://arxiv.org/pdf/2011.03403.pdf)
25
+
26
+ Attributes
27
+ ----------
28
+ ### n_cars: int
29
+ \n Amount of different car types.
30
+
31
+ ### sequence: List[int]
32
+ \n Sequence of the cars.
33
+ """
34
+
35
+ name: Literal["BPSP"] = "BPSP"
36
+ n_cars: int
37
+ sequence: list[int]
@@ -0,0 +1,40 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class CreditScoringFeatureSelection(UseCase):
9
+ r"""
10
+ # Feature Selection for Credit Scoring.
11
+
12
+ Description
13
+ -----------
14
+
15
+ Find the optimal feature subset with regard to independence and influence of
16
+ features for credit scoring of credit applicants.
17
+
18
+ Links
19
+ -----
20
+
21
+ [Transformation](https://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Optimal-Feature-Selection-in-Credit-Scoring-and-Classification-Using-a-Quantum-Annealer_-_2017.04.13.pdf)
22
+
23
+ Attributes
24
+ ----------
25
+ ### U: List[List[float]]
26
+ \n The matrix U is the design matrix, where each column represents a feature
27
+ and each row represents the specific values for a feature set.
28
+
29
+ ### V: List[int]
30
+ \n The binary label vector for the respective row in matrix U.
31
+
32
+ ### alpha: float
33
+ \n The balance between feature influence and feature independence in the range
34
+ _[0, 1]_.
35
+ """
36
+
37
+ name: Literal["CSFS"] = "CSFS"
38
+ U: list[list[float]]
39
+ V: list[int]
40
+ alpha: float
@@ -0,0 +1,64 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class DynamicPortfolioOptimization(UseCase):
9
+ r"""
10
+ # Dynamic Portfolio Optimization.
11
+
12
+ Description
13
+ -----------
14
+
15
+ The Dynamic Portfolio Optimization problem tries to find the optimal portfolio for a
16
+ given set of assets and a fixed investment amount. It aims to find the portfolio
17
+ with optimal returns for a given risk tolerance. It considers transaction costs when
18
+ rebalancing across multiple time steps. The optimal portfolio is defined by the
19
+ binary choices whether to invest in a specific asset and how much to invest in it.
20
+ The investment amount is split into several so called packages defined as
21
+ 2^(package number). The total number of packages determines the granularity of the
22
+ result. It defines the amount of possible investment sums in one asset as well as
23
+ the maximum possible investment in any one asset, which is
24
+ 2^(Number of packages) - 1.
25
+
26
+ Links
27
+ -----
28
+
29
+ [Transformation](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.4.013006)
30
+
31
+ Attributes
32
+ ----------
33
+ ### tickers: List
34
+ \n Tickers of assets being tested.
35
+ ### mu: List[List[float]]
36
+ \n Expected Returns of the assets.
37
+ \n Shape: [time_steps][number_of_assets]
38
+ ### sigma: List[List[List[float]]]
39
+ \n Coviariance Matrix of the assets.
40
+ \n Shape: [time_steps][number_of_assets][number_of_assets]
41
+ ### packages: int
42
+ \n Number of packages per asset, determines granularity of investment.
43
+ \n _Package value = 2^(package number)_
44
+ ### K: int
45
+ \n Total investment amount, which is fixed.
46
+ ### gamma: float
47
+ \n Risk Aversion Coefficient.
48
+ \n Range: Risk Seeking 0-100 Very Risk Averse.
49
+ \n Divided by factor 2 as a convention, as stated in paper.
50
+ ### nu: float
51
+ \n Transaction Cost percentage, e.g., 0.01 = 1% of transaction size.
52
+ ### rho: float
53
+ \n Total investment size constraint factor, Lagrange Multiplier.
54
+ """
55
+
56
+ name: Literal["DPO"] = "DPO"
57
+ tickers: list[str | int]
58
+ mu: list[list[float]]
59
+ sigma: list[list[list[float]]]
60
+ packages: int
61
+ K: int
62
+ gamma: float
63
+ nu: float
64
+ rho: float
@@ -0,0 +1,51 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class ExactCover(UseCase):
9
+ r"""
10
+ # Exact Cover.
11
+
12
+ Description
13
+ -----------
14
+
15
+ Given a set _S_ and a list of subsets of _S_, an exact cover is a family _C_ of
16
+ these subsets so that all elements of _S_ are contained in exactly one subset of
17
+ _C_. For a set _S_ and a list of subsets of _S_, the Exact Cover problem tries to
18
+ find the smallest exact cover, i.e. the one that uses the least subsets.
19
+
20
+ Q-Bit Interpretation
21
+ --------------------
22
+
23
+ Subset _i_ is part of the exact cover iff. qubit _i_ is 1.
24
+
25
+ Links
26
+ -----
27
+
28
+ [Wikipedia](https://en.wikipedia.org/wiki/Exact_cover)
29
+
30
+ [Transformation](https://arxiv.org/pdf/1302.5843.pdf)
31
+
32
+ Attributes
33
+ ----------
34
+ ### subset_matrix: List[List[float]]
35
+ \n A matrix containing all subsets.
36
+ \n e.g. for the set _{1, 2, 3}_ and the subsets _{1, 2}_, _{2, 3}_, and _{3}_:
37
+ \n _[[1, 1, 0], [0, 1, 1], [0, 0, 1]]_
38
+ \n or:
39
+ \n _ExactCover.gen_subsets_matrix([1, 2, 3], [[1, 2], [2, 3], [3]])_
40
+
41
+ ### A: int
42
+ \n A constant enforcing the exact cover of the solution.
43
+
44
+ ### B: int
45
+ \n A constant (_A > nB_) helping find the smallest exact cover.
46
+ """
47
+
48
+ name: Literal["EC"] = "EC"
49
+ subset_matrix: list[list[int]]
50
+ A: int = 2
51
+ B: int = 2
@@ -0,0 +1,79 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class FlightGateAssignment(UseCase):
9
+ r"""
10
+ # Flight Gate Assignment.
11
+
12
+ Description
13
+ -----------
14
+
15
+ Flight Gate Assignment is a highly relevant optimization problem in airport
16
+ management. It tries to minimize the total transit time of passengers, considering
17
+ three typical parts of passenger flow in an airport:
18
+ \n 1) After a flight, passengers claim their baggage and leave the airport.
19
+ \n 2) Other passengers switch from one plane to another to get a connecting flight.
20
+ \n 3) A third group of passengers pass the security check and leave with a flight.
21
+
22
+ Links
23
+ -----
24
+
25
+ [Description and Transformation](https://arxiv.org/pdf/1811.09465.pdf)
26
+
27
+ Attributes
28
+ ----------
29
+ ### n_flights: int
30
+ \n Number of flights.
31
+
32
+ ### n_gates: int
33
+ \n Number of gates.
34
+
35
+ ### n_passengers: List[Tuple[int, int]]
36
+ \n Number of passengers arriving and departing with each flight.
37
+ \n Example: _n_passengers[3][departure_index]_, gives us the number of
38
+ passengers departing with flight _3_.
39
+
40
+ ### time_gates: List[Tuple[float, float]]
41
+ \n The time it takes between every gate and check-in (when leaving) or the gate
42
+ and baggage claim (when arriving).
43
+ \n Example: _time_gates[0][arriving_index]_, gives us the time it takes to go
44
+ from gate _0_ to baggage claim.
45
+
46
+ ### time_flights: List[Tuple[float, float]]
47
+ \n The time at which a flight arrives/leaves.
48
+ \n Example: _time_flights[2][departure_index]_, gives us the time at which
49
+ flight 2 departs.
50
+
51
+ ### transfer_passengers: List[List[int]]
52
+ \n Matrix with the information of the passengers transferring from one flight to
53
+ another.
54
+ \n Example: _transfer_passengers[2][5]_, gives the number of passengers
55
+ transferring from flight 2 to flight 5.
56
+
57
+ ### time_between_gates: List[List[float]]
58
+ \n Gives the time it takes to go from one gate to another.
59
+
60
+ ### t_buf: float
61
+ \n Time needed for a gate to be free after a flight has departed.
62
+
63
+ ### arrival_index, departure_index: int
64
+ \n Index to subscribe the variables _time_gates_, _n_passengers_,
65
+ _time_gates_, _time_flights_.
66
+ \n One of these variables needs to be _0_, the other _1_.
67
+ """
68
+
69
+ name: Literal["FGO"] = "FGO"
70
+ n_flights: int
71
+ n_gates: int
72
+ n_passengers: list[tuple[int, int]]
73
+ time_gates: list[tuple[float, float]]
74
+ time_flights: list[tuple[float, float]]
75
+ transfer_passengers: list[list[int]]
76
+ time_between_gates: list[list[float]]
77
+ t_buf: float
78
+ arrival_index: int = 0
79
+ departure_index: int = 1
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import Field
6
+
7
+ from luna_quantum.solve.use_cases.base import UseCase
8
+
9
+
10
+ class GraphColoring(UseCase):
11
+ r"""
12
+ # Graph Coloring.
13
+
14
+ Description
15
+ -----------
16
+
17
+ The Graph Coloring problem tries to color the nodes of a graph with a given number
18
+ of different colors so that no adjacent nodes have the same color.
19
+
20
+ Links
21
+ -----
22
+
23
+ [Wikipedia](https://en.wikipedia.org/wiki/Graph_coloring)
24
+
25
+ [Transformation](https://arxiv.org/pdf/1811.11538.pdf)
26
+
27
+ Attributes
28
+ ----------
29
+ ### graph: Dict[int, Dict[int, Dict[str, float]]]
30
+ \n Problem graph for the graph coloring problem in form of nested dictionaries.
31
+ \n (e.g. fully connected graph with 3 nodes:
32
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
33
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
34
+
35
+ ### n_colors: int
36
+ \n Number of different colors.
37
+ """
38
+
39
+ name: Literal["GC"] = "GC"
40
+ graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
41
+ n_colors: int
42
+ P: int = 4
@@ -0,0 +1,52 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+ from luna_quantum.solve.use_cases.type_aliases import NestedDictIntGraph
7
+
8
+
9
+ class GraphIsomorphism(UseCase):
10
+ r"""
11
+ # Graph Isomorphism.
12
+
13
+ Description
14
+ -----------
15
+
16
+ The Graph Isomorphism problem tries to find out whether two graphs _G1_ and _G2_are
17
+ isomorphic, i.e. there exists a bijective, edge-invariant vertex mapping from _G1_
18
+ to _G2_.
19
+
20
+ Links
21
+ -----
22
+
23
+ [Wikipedia](https://en.wikipedia.org/wiki/Graph_isomorphism)
24
+
25
+ [Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf?sequence=1)
26
+
27
+ Attributes
28
+ ----------
29
+ ### graph1: Dict[int, Dict[int, Dict[str, float]]]
30
+ \n The first graph (in form of nested dictionaries) to check for isomorphism.
31
+ \n (e.g. fully connected graph with 3 nodes:
32
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
33
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
34
+
35
+ ### graph2: Dict[int, Dict[int, Dict[str, float]]]
36
+ \n The second graph (in form of nested dictionaries) to check for isomorphism.
37
+ \n (e.g. fully connected graph with 3 nodes:
38
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
39
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
40
+
41
+ ### a: float
42
+ \n A penalty value enforcing the bijectivity of the isomorphism.
43
+
44
+ ### b: float
45
+ \n A penalty value (b > a) enforcing the edge-invariance of the isomorphism.
46
+ """
47
+
48
+ name: Literal["GI"] = "GI"
49
+ graph1: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
50
+ graph2: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
51
+ a: float = 1
52
+ b: float = 2
@@ -0,0 +1,46 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class GraphPartitioning(UseCase):
9
+ r"""
10
+ Graph Partitioning.
11
+
12
+ Description
13
+ -----------
14
+
15
+ The Graph Partitioning problem tries to find two equal sized partitions for a given
16
+ undirected graph with an even number of vertices, so that the number of edges
17
+ connecting the two subsets is minimized.
18
+
19
+ Links
20
+ -----
21
+
22
+ [Transformation](https://arxiv.org/abs/1302.5843)
23
+
24
+ Attributes
25
+ ----------
26
+ ### graph : Dict[int, Dict[int, Dict[str, float]]]
27
+ \n The graph, for which the partitions are to be foundin form of nested
28
+ dictionaries.
29
+ \n (e.g. fully connected graph with 3 nodes:
30
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
31
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
32
+
33
+ ### A : Optional[int]
34
+ \n Penalty parameter A panalizes violation of the constraint that makes sure
35
+ both partitions are of equal size. It can be left "None" to be estimated from
36
+ the problem graph via the papers suggestion.
37
+
38
+ ### B : Optional[int]
39
+ \n Optimization penalty parameter B penalizes each edge connecting two nodes of
40
+ different partitions. If not given it defaults to 1.
41
+ """
42
+
43
+ name: Literal["GP"] = "GP"
44
+ graph: dict[str, dict[str, dict[str, float]]]
45
+ A: int | None = None
46
+ B: int | None = 1
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import Field
6
+
7
+ from luna_quantum.solve.use_cases.base import UseCase
8
+
9
+
10
+ class HamiltonianCycle(UseCase):
11
+ r"""
12
+ # Hamiltonian Cycle.
13
+
14
+ Description
15
+ -----------
16
+
17
+ The Hamiltonian Cycle problem, either for a directed or undirected graph, asks the
18
+ following: starting at an arbitrary node in the graph, can one travel along the
19
+ edges of the graph so that each graph will be visited exactly once and there is an
20
+ edge between the starting node and the last node?
21
+
22
+ Links
23
+ -----
24
+
25
+ [Wikipedia](https://en.wikipedia.org/wiki/Hamiltonian_path_problem)
26
+
27
+ [Transformation](https://arxiv.org/pdf/1302.5843.pdf)
28
+
29
+ Attributes
30
+ ----------
31
+ ### graph: Dict[int, Dict[int, Dict[str, float]]]
32
+ \n Problem graph for the hamiltonian cycle problem in form of nested
33
+ dictionaries.
34
+ \n (e.g. fully connected graph with 3 nodes:
35
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
36
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
37
+
38
+ ### A: Optional[float]
39
+ \n Positive penalty value which enforces that each node is visited exactly once.
40
+ \n Default: _1.0_
41
+ """
42
+
43
+ # Hamiltonian Cycle is just TSP with B = 0.
44
+
45
+ name: Literal["HC"] = "HC"
46
+ graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
47
+ directed: bool | None = False
48
+ A: float = 1.0
49
+ B: float = 0.0
@@ -0,0 +1,50 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import Field
6
+
7
+ from luna_quantum.solve.use_cases.base import UseCase
8
+
9
+
10
+ class InducedSubGraphIsomorphism(UseCase):
11
+ r"""
12
+ # Induced Subgraph Isomorphism.
13
+
14
+ Description
15
+ -----------
16
+
17
+ Given two graphs the induced subgraph isomorphism problem is to decide if there
18
+ exists an edge invariant injective mapping from the vertices of the first graph to
19
+ the second graph.
20
+ The task is slightly different from the subgraph isomorphism problem, because here
21
+ additional edges present between two vertices in the second graph to which the
22
+ isomorphism maps, are prohibited.
23
+
24
+ This Implementation is heavily based on the subgraph isomorphism problem
25
+ implementation.
26
+ It uses slack variables to counterbalance unnecessary penalties.
27
+
28
+ Links
29
+ -----
30
+
31
+ [Wikipedia](https://en.wikipedia.org/wiki/Induced_subgraph_isomorphism_problem)
32
+
33
+ [Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf)
34
+
35
+ Attributes
36
+ ----------
37
+ ### graph1: Dict[int, Dict[int, Dict[str, float]]]
38
+ \n The first graph in form of nested dictionaries.
39
+ \n (e.g. fully connected graph with 3 nodes:
40
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
41
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
42
+
43
+ ### graph2: Dict[int, Dict[int, Dict[str, float]]]
44
+ \n The second graph, on which the first one is to be mapped, also in form of
45
+ nested dictionaries.
46
+ """
47
+
48
+ name: Literal["ISGI"] = "ISGI"
49
+ graph1: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
50
+ graph2: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
@@ -0,0 +1,44 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from pydantic import Field
6
+
7
+ from luna_quantum.solve.use_cases.base import UseCase
8
+
9
+
10
+ class JobShopScheduling(UseCase):
11
+ r"""
12
+ # Job Shop Scheduling.
13
+
14
+ Description
15
+ -----------
16
+
17
+ Consider a number of jobs, each of which consists of a number of operations which
18
+ have to be processed in a specific order. Each operation has a specific machine that
19
+ it needs to be processed on and only one operation in a job can be processed at a
20
+ given time. Also, each machine can only execute one job at a time. The objective of
21
+ the Job Shop Scheduling problem is to schedule all operations in a valid sequence
22
+ while minimizing the makespan of the jobs, i.e. the completion time of the last
23
+ running job.
24
+
25
+ Links
26
+ -----
27
+
28
+ [Wikipedia](https://en.wikipedia.org/wiki/Job-shop_scheduling)
29
+
30
+ [Transformation](https://arxiv.org/pdf/1506.08479.pdf)
31
+
32
+ Attributes
33
+ ----------
34
+ ### jobs: Dict[int, List[Tuple[int, int]]]
35
+ \n A dictionary containing all jobs. Each job is a list of operations and each
36
+ operation is tuple containing the machine and the processing time.
37
+
38
+ ### T: int
39
+ \n Strict upper bound when all jobs should be finished.
40
+ """
41
+
42
+ name: Literal["JSS"] = "JSS"
43
+ jobs: dict[int, list[tuple[int, int]]] = Field(name="dict") # type: ignore[call-overload]
44
+ T: int = 0
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class KMedoidsClustering(UseCase):
9
+ r"""
10
+ # K-Medoids Clustering.
11
+
12
+ Description
13
+ -----------
14
+
15
+ The authors are concerned with k-medoids clustering and propose a quadratic
16
+ unconstrained binary optimization (*QUBO*) formulation of the problem of
17
+ identifying *k* medoids among *n* data points without having to cluster the data.
18
+ Given our *QUBO* formulation of this NP-hard problem, it should be possible to solve
19
+ it on adiabatic quantum computers.
20
+
21
+ Q-Bit Interpretation
22
+ --------------------
23
+
24
+ "The qubit vector at index _k_ is 1 iff. data point _k_ from the distance matrix is
25
+ chosen as medoid of a cluster. The step of assigning the remaining data points to
26
+ clusters is not covered in this problem but can be easily done in linear time with
27
+ respect to the number of data points."
28
+
29
+ Links
30
+ -----
31
+
32
+ [Transformation](http://ceur-ws.org/Vol-2454/paper_39.pdf)
33
+
34
+ Attributes
35
+ ----------
36
+ D : List[List[float]]
37
+ \n The (*n x n*) similarity matrix (diagonal elements are *1* (*one*)).
38
+
39
+ k : int
40
+ \n The number of medoids.
41
+
42
+ gamma : float
43
+ \n Penalty coefficient to enforce feasibility.
44
+ """
45
+
46
+ name: Literal["KMC"] = "KMC"
47
+ D: list[list[float]]
48
+ k: int
49
+ gamma: float
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Literal
4
+
5
+ from luna_quantum.solve.use_cases.base import UseCase
6
+
7
+
8
+ class KnapsackIntegerWeights(UseCase):
9
+ r"""
10
+ # Knapsack with Integer Weights.
11
+
12
+ Description
13
+ -----------
14
+
15
+ Given a knapsack that can only carry a weight _W_ and a set of objects, each object
16
+ having a weight _w_ and a value _c_, the Knapsack with Integer Weights problem tries
17
+ to find objects so that the sum of their values is maximized while, at the same
18
+ time, the sum of their weights does not exceed the capacity of the knapsack.
19
+
20
+ Links
21
+ -----
22
+
23
+ [Description and Transformation](https://arxiv.org/pdf/1302.5843.pdf)
24
+
25
+ Attributes
26
+ ----------
27
+ ### w: List[int]
28
+ \n The weight of each object.
29
+
30
+ ### c: List[float]
31
+ \n The value of each object.
32
+
33
+ ### W: int
34
+ \n The weight that the knapsack can carry.
35
+
36
+ ### B: float
37
+ \n A positive constant to reward putting an object into the knapsack.
38
+ \n Default: _1_
39
+
40
+ ### A: Optional[float]
41
+ \n A positive penalty value, enforcing that the maximal weight will not be
42
+ exceeded. If specified, the equation _A > B _max_(c)_ must hold. If not
43
+ specified, will be computed automatically as _A = 1 + B _max_(c)_.
44
+
45
+ ### linear_encoding: bool
46
+ \n If false, the number of qubits will be highly reduced, using the log trick
47
+ from section 2.4 of the paper linked above.
48
+ """
49
+
50
+ name: Literal["KIW"] = "KIW"
51
+ w: list[int]
52
+ c: list[float]
53
+ W: int
54
+ B: float = 1.0
55
+ A: float | None = None
56
+ linear_encoding: bool = False