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,869 @@
1
+ from pathlib import Path
2
+ from typing import Any, overload
3
+
4
+ from dimod import BinaryQuadraticModel, ConstrainedQuadraticModel, SampleSet
5
+ from numpy.typing import NDArray
6
+ from pyscipopt import Model as SciModel
7
+ from qiskit.primitives import PrimitiveResult, PubResult
8
+ from qiskit_optimization import QuadraticProgram
9
+
10
+ from ._core import Environment, Model, Solution, Timing, Vtype
11
+
12
+ class ZibTranslator:
13
+ """
14
+ Utility class for converting between a Zib solution and our solution format.
15
+
16
+ `ZibTranslator` provides methods to:
17
+
18
+ - Convert a Zib-style solution into our solution `Solution`.
19
+
20
+ The conversions are especially required when interacting with external zib
21
+ solvers/samplers or libraries that operate on zib-based problem-solving/sampling.
22
+
23
+ Examples
24
+ --------
25
+ >>> import luna_quantum as lq
26
+ >>> from pyscipopt import Model
27
+ >>> model = Model()
28
+ >>> model.readProblem("./path/to/my/model.lp")
29
+ >>> model.optimize()
30
+ >>> aqs = lq.translator.ZibTranslator.to_aq(model)
31
+ """
32
+
33
+ @overload
34
+ @staticmethod
35
+ def to_aq(model: SciModel) -> Solution: ...
36
+ @overload
37
+ @staticmethod
38
+ def to_aq(model: SciModel, timing: Timing) -> Solution: ...
39
+ @overload
40
+ @staticmethod
41
+ def to_aq(model: SciModel, *, env: Environment) -> Solution: ...
42
+ @overload
43
+ @staticmethod
44
+ def to_aq(model: SciModel, timing: Timing, *, env: Environment) -> Solution: ...
45
+ @staticmethod
46
+ def to_aq(
47
+ model: SciModel, timing: Timing | None = ..., *, env: Environment | None = ...
48
+ ) -> Solution:
49
+ """
50
+ Extract a solution from a ZIB model.
51
+
52
+ Parameters
53
+ ----------
54
+ model : pyscipopt.Model
55
+ The Model that ran the optimization.
56
+ timing : Timing, optional
57
+ The timing object produced while generating the result.
58
+ env : Environment, optional
59
+ The environment of the model for which the result is produced.
60
+
61
+ Raises
62
+ ------
63
+ NoActiveEnvironmentFoundError
64
+ If no environment is passed to the method or available from the context.
65
+ SolutionTranslationError
66
+ Generally if the solution translation fails. Might be specified by one of
67
+ the two following errors.
68
+ SampleIncorrectLengthError
69
+ If a solution's sample has a different number of variables than the model
70
+ environment passed to the translator.
71
+ ModelVtypeError
72
+ If the result's variable types are incompatible with the model environment's
73
+ variable types.
74
+ """
75
+ ...
76
+
77
+ class Qubo:
78
+ """The result of the QuboTranslator.
79
+
80
+ A wrapper around qubo matrices that holds all relevant metadata,
81
+ e.g., the model offset.
82
+ """
83
+
84
+ @property
85
+ def matrix(self, /) -> NDArray:
86
+ """
87
+ The actual QUBO matrix.
88
+
89
+ Returns
90
+ -------
91
+ NDArray
92
+ A square NumPy array representing the QUBO matrix derived from
93
+ the model's objective.
94
+ """
95
+ ...
96
+
97
+ @property
98
+ def variable_names(self, /) -> list[str]:
99
+ """
100
+ The name of the variables in the same order as in the QUBO matrix.
101
+
102
+ Returns
103
+ -------
104
+ list[Variable]
105
+ The variable names in the order they appear in the QUBO.
106
+ """
107
+ ...
108
+
109
+ @property
110
+ def name(self, /) -> str:
111
+ """
112
+ The name of the model the QUBO matrix was generated from.
113
+
114
+ Returns
115
+ -------
116
+ str
117
+ The model name.
118
+ """
119
+ ...
120
+
121
+ @property
122
+ def offset(self, /) -> float:
123
+ """
124
+ The constant offset of the original model passed to the QuboTranslator.
125
+
126
+ Returns
127
+ -------
128
+ float
129
+ The constant offset of the model.
130
+ """
131
+ ...
132
+
133
+ @property
134
+ def vtype(self, /) -> Vtype:
135
+ """
136
+ The type of the model variables. Can be `Binary` or `Spin`.
137
+
138
+ Returns
139
+ -------
140
+ Vtype
141
+ The variable type.
142
+ """
143
+ ...
144
+
145
+ class QuboTranslator:
146
+ """
147
+ Utility class for converting between dense QUBO matrices and symbolic models.
148
+
149
+ `QuboTranslator` provides methods to:
150
+ - Convert a NumPy-style QUBO matrix into a symbolic `Model`
151
+ - Convert a `Model` (with quadratic objective) into a dense QUBO matrix
152
+
153
+ These conversions are especially useful when interacting with external solvers
154
+ or libraries that operate on matrix-based problem definitions.
155
+
156
+ Examples
157
+ --------
158
+ >>> import numpy as np
159
+ >>> from luna_quantum.translator import QuboTranslator, Vtype
160
+ >>> q = np.array([[1.0, -1.0], [-1.0, 2.0]])
161
+
162
+ Create a model from a matrix:
163
+
164
+ >>> model = QuboTranslator.to_aq(
165
+ ... q, offset=4.2, name="qubo_model", vtype=Vtype.Binary
166
+ ... )
167
+
168
+ Convert it back to a dense matrix:
169
+
170
+ >>> recovered = QuboTranslator.from_aq(model)
171
+ >>> assert np.allclose(q, recovered.matrix)
172
+ """
173
+
174
+ @staticmethod
175
+ def to_aq(
176
+ qubo: NDArray,
177
+ *,
178
+ offset: float | None = ...,
179
+ variable_names: list[str] | None = ...,
180
+ name: str | None = ...,
181
+ vtype: Vtype | None = ...,
182
+ ) -> Model:
183
+ """
184
+ Convert a dense QUBO matrix into a symbolic `Model`.
185
+
186
+ Parameters
187
+ ----------
188
+ qubo : NDArray
189
+ A square 2D NumPy array representing the QUBO matrix.
190
+ Diagonal entries correspond to linear coefficients;
191
+ off-diagonal entries represent pairwise quadratic terms.
192
+ name : str, optional
193
+ An optional name to assign to the resulting model.
194
+ vtype : Vtype, optional
195
+ The variable type to assign to all variables (e.g. Binary, Spin).
196
+
197
+ Returns
198
+ -------
199
+ Model
200
+ A symbolic model representing the given QUBO structure.
201
+
202
+ Raises
203
+ ------
204
+ TranslationError
205
+ Generally if the translation fails. Might be specified by the following
206
+ error.
207
+ VariableNamesError
208
+ If a list of variable names is provided but contains duplicates or has an
209
+ incorrect length.
210
+ """
211
+ ...
212
+
213
+ @staticmethod
214
+ def from_aq(model: Model) -> Qubo:
215
+ """
216
+ Convert a symbolic model to a dense QUBO matrix representation.
217
+
218
+ Parameters
219
+ ----------
220
+ model : Model
221
+ The symbolic model to convert. The objective must be quadratic-only
222
+ and unconstrained.
223
+
224
+ Returns
225
+ -------
226
+ Qubo
227
+ An object representing a QUBO with information additional to the square
228
+ NumPy array representing the QUBO matrix derived from the model's objective.
229
+ This object also includes the `variable_ordering` as well as the `offset`
230
+ of the original model.
231
+
232
+ Raises
233
+ ------
234
+ TranslationError
235
+ Generally if the translation fails. Might be specified by one of the
236
+ four following errors.
237
+ ModelNotQuadraticError
238
+ If the objective contains higher-order (non-quadratic) terms.
239
+ ModelNotUnconstrainedError
240
+ If the model contains any constraints.
241
+ ModelSenseNotMinimizeError
242
+ If the model's optimization sense is 'maximize'.
243
+ ModelVtypeError
244
+ If the model contains different vtypes or vtypes other than binary and
245
+ spin.
246
+ """
247
+ ...
248
+
249
+ class QctrlTranslator:
250
+ """
251
+ Utility class for converting between a QCTRL solution and our solution format.
252
+
253
+ `QctrlTranslator` provides methods to:
254
+ - Convert a Qctrl-style solution into our solution `Solution`.
255
+
256
+ The conversions are especially required when interacting with external qctrl
257
+ solvers/samplers or libraries that operate on qctrl-based problem-solving/sampling.
258
+
259
+ Examples
260
+ --------
261
+ >>> import luna_quantum as lq
262
+ >>> ...
263
+ >>> qctrl_result = ...
264
+ >>> aqs = lq.translator.QctrlTranslator.to_aq(qctrl_result)
265
+ """
266
+
267
+ @overload
268
+ @staticmethod
269
+ def to_aq(result: dict[str, Any]) -> Solution: ...
270
+ @overload
271
+ @staticmethod
272
+ def to_aq(result: dict[str, Any], timing: Timing) -> Solution: ...
273
+ @overload
274
+ @staticmethod
275
+ def to_aq(result: dict[str, Any], *, env: Environment) -> Solution: ...
276
+ @overload
277
+ @staticmethod
278
+ def to_aq(
279
+ result: dict[str, Any], timing: Timing, *, env: Environment
280
+ ) -> Solution: ...
281
+ @staticmethod
282
+ def to_aq(
283
+ result: dict[str, Any],
284
+ timing: Timing | None = ...,
285
+ *,
286
+ env: Environment | None = ...,
287
+ ) -> Solution:
288
+ """
289
+ Convert a QCTRL result to our solution format.
290
+
291
+ Parameters
292
+ ----------
293
+ result : dict[str, Any]
294
+ The qctrl result as a dictionary.
295
+ timing : Timing, optional
296
+ The timing object produced while generating the result.
297
+ env : Environment, optional
298
+ The environment of the model for which the result is produced.
299
+
300
+ Raises
301
+ ------
302
+ NoActiveEnvironmentFoundError
303
+ If no environment is passed to the method or available from the context.
304
+ SolutionTranslationError
305
+ Generally if the solution translation fails. Might be specified by one of
306
+ the two following errors.
307
+ SampleIncorrectLengthError
308
+ If a solution's sample has a different number of variables than the model
309
+ environment passed to the translator.
310
+ ModelVtypeError
311
+ If the result's variable types are incompatible with the model environment's
312
+ variable types.
313
+ """
314
+ ...
315
+
316
+ class NumpyTranslator:
317
+ """Translate between numpy arrays and our solution format.
318
+
319
+ Utility class for converting between a result consisting of numpy arrays and our
320
+ solution format.
321
+
322
+ `NumpyTranslator` provides methods to:
323
+ - Convert a numpy-array result into our solution `Solution`.
324
+
325
+ Examples
326
+ --------
327
+ >>> import luna_quantum as lq
328
+ >>> from numpy.typing import NDArray
329
+ >>> result: NDArray = ...
330
+ >>> energies: NDArray = ...
331
+ >>> aqs = lq.translator.NumpyTranslator.to_aq(result, energies)
332
+ """
333
+
334
+ @overload
335
+ @staticmethod
336
+ def to_aq(result: NDArray, energies: NDArray) -> Solution: ...
337
+ @overload
338
+ @staticmethod
339
+ def to_aq(result: NDArray, energies: NDArray, timing: Timing) -> Solution: ...
340
+ @overload
341
+ @staticmethod
342
+ def to_aq(result: NDArray, energies: NDArray, *, env: Environment) -> Solution: ...
343
+ @overload
344
+ @staticmethod
345
+ def to_aq(
346
+ result: NDArray, energies: NDArray, timing: Timing, *, env: Environment
347
+ ) -> Solution: ...
348
+ @staticmethod
349
+ def to_aq(
350
+ result: NDArray,
351
+ energies: NDArray,
352
+ timing: Timing | None = ...,
353
+ *,
354
+ env: Environment | None = ...,
355
+ ) -> Solution:
356
+ """Convert a solution in the format of numpy arrays to our solution format.
357
+
358
+ Note that the optimization sense is always assumed to be minimization.
359
+
360
+ Parameters
361
+ ----------
362
+ result : NDArray
363
+ The samples as a 2D array where each row corresponds to one sample.
364
+ energies : NDArray
365
+ The energies of the single samples as a 1D array.
366
+ timing : Timing, optional
367
+ The timing object produced while generating the result.
368
+ env : Environment, optional
369
+ The environment of the model for which the result is produced.
370
+
371
+ Raises
372
+ ------
373
+ NoActiveEnvironmentFoundError
374
+ If no environment is passed to the method or available from the context.
375
+ SolutionTranslationError
376
+ Generally if the solution translation fails. Might be specified by one of
377
+ the two following errors.
378
+ SampleIncorrectLengthError
379
+ If a solution's sample has a different number of variables than the model
380
+ environment passed to the translator.
381
+ ModelVtypeError
382
+ If the result's variable types are incompatible with the model environment's
383
+ variable types.
384
+ """
385
+ ...
386
+
387
+ class LpTranslator:
388
+ """
389
+ Utility class for converting between LP files and symbolic models.
390
+
391
+ `LpTranslator` provides methods to:
392
+ - Convert an LP file into a symbolic `Model`
393
+ - Convert a `Model` into an Lp file.
394
+
395
+ These conversions are especially useful when interacting with external solvers
396
+ or libraries that operate on LP-based problem definitions.
397
+
398
+ Examples
399
+ --------
400
+ >>> from pathlib import Path
401
+ >>> from luna_quantum.translator import LpTranslator
402
+ >>> lp_filepath = Path("path/to/the/lp_file")
403
+
404
+ >>> model = LpTranslator.to_aq(lp_filepath)
405
+
406
+ Convert it back to an LP file:
407
+
408
+ >>> recovered = LpTranslator.to_file(model)
409
+ """
410
+
411
+ @overload
412
+ @staticmethod
413
+ def to_aq(file: Path) -> Model: ...
414
+ @overload
415
+ @staticmethod
416
+ def to_aq(file: str) -> Model: ...
417
+ @staticmethod
418
+ def to_aq(file: str | Path) -> Model:
419
+ """
420
+ Convert an LP file into a symbolic `Model`.
421
+
422
+ Parameters
423
+ ----------
424
+ file: Path | String
425
+ An LP file representing a symbolic model, either given as a
426
+ Path object to the LP file or its contents as a string.
427
+ If you pass the path as a string, it will be interpreted as a
428
+ model and thus fail to be parsed to a Model.
429
+
430
+ Returns
431
+ -------
432
+ Model
433
+ A symbolic model representing the given lp file structure.
434
+
435
+ Raises
436
+ ------
437
+ TypeError
438
+ If `file` is not of type `str` or `Path`.
439
+ TranslationError
440
+ If the translation fails for a different reason.
441
+ """
442
+ ...
443
+
444
+ @overload
445
+ @staticmethod
446
+ def from_aq(model: Model) -> str: ...
447
+ @overload
448
+ @staticmethod
449
+ def from_aq(model: Model, *, filepath: Path) -> None: ...
450
+ @staticmethod
451
+ def from_aq(model: Model, *, filepath: Path | None = ...) -> None:
452
+ """
453
+ Convert a symbolic model to an LP file representation.
454
+
455
+ Parameters
456
+ ----------
457
+ model : Model
458
+ The symbolic model to convert.
459
+ file : Path, optional
460
+ The filepath to write the model contents to.
461
+
462
+ Returns
463
+ -------
464
+ str
465
+ If no file to write to is given, i.e., the file is None.
466
+
467
+ Raises
468
+ ------
469
+ TranslationError
470
+ If the translation fails for some reason.
471
+ """
472
+ ...
473
+
474
+ class IbmTranslator:
475
+ """Utility class for converting between an IBM solution and our solution format.
476
+
477
+ `IbmTranslator` provides methods to:
478
+ - Convert an IBM-style solution into our solution `Solution`.
479
+
480
+ The conversions are especially required when interacting with external ibm
481
+ solvers/samplers oe libraries that operate on ibm-based problem-solving/sampling.
482
+
483
+ Examples
484
+ --------
485
+ >>> import luna_quantum as lq
486
+ >>> ...
487
+ >>> ibm_result = ...
488
+ >>> aqs = lq.translator.IbmTranslator.to_aq(ibm_result)
489
+ """
490
+
491
+ @overload
492
+ @staticmethod
493
+ def to_aq(
494
+ result: PrimitiveResult[PubResult], quadratic_program: QuadraticProgram
495
+ ) -> Solution: ...
496
+ @overload
497
+ @staticmethod
498
+ def to_aq(
499
+ result: PrimitiveResult[PubResult],
500
+ quadratic_program: QuadraticProgram,
501
+ timing: Timing,
502
+ ) -> Solution: ...
503
+ @overload
504
+ @staticmethod
505
+ def to_aq(
506
+ result: PrimitiveResult[PubResult],
507
+ quadratic_program: QuadraticProgram,
508
+ *,
509
+ env: Environment,
510
+ ) -> Solution: ...
511
+ @overload
512
+ @staticmethod
513
+ def to_aq(
514
+ result: PrimitiveResult[PubResult],
515
+ quadratic_program: QuadraticProgram,
516
+ timing: Timing,
517
+ *,
518
+ env: Environment,
519
+ ) -> Solution: ...
520
+ @staticmethod
521
+ def to_aq(
522
+ result: PrimitiveResult[PubResult],
523
+ quadratic_program: QuadraticProgram,
524
+ timing: Timing | None = ...,
525
+ *,
526
+ env: Environment | None = ...,
527
+ ) -> Solution:
528
+ """
529
+ Convert an IBM solution to our solution format.
530
+
531
+ Parameters
532
+ ----------
533
+ result : PrimitiveResult[PubResult]
534
+ The ibm result.
535
+ quadratic_program : QuadraticProgram
536
+ The quadratic program defining the optimization problem.
537
+ timing : Timing, optional
538
+ The timing object produced while generating the result.
539
+ env : Environment, optional
540
+ The environment of the model for which the result is produced.
541
+
542
+ Raises
543
+ ------
544
+ NoActiveEnvironmentFoundError
545
+ If no environment is passed to the method or available from the context.
546
+ SolutionTranslationError
547
+ Generally if the solution translation fails. Might be specified by one of
548
+ the two following errors.
549
+ SampleIncorrectLengthError
550
+ If a solution's sample has a different number of variables than the model
551
+ environment passed to the translator.
552
+ ModelVtypeError
553
+ If the result's variable types are incompatible with the model environment's
554
+ variable types.
555
+ """
556
+ ...
557
+
558
+ class DwaveTranslator:
559
+ """Utility class for converting between a DWAVE solution and our solution format.
560
+
561
+ `DWaveSolutionTranslator` provides methods to:
562
+ - Convert a dimod-style solution into our solution `Solution`.
563
+
564
+ The conversions are especially required when interacting with external dwave/dimod
565
+ solvers/samplers or libraries that operate on dwave/dimod-based problem-solving/
566
+ sampling.
567
+
568
+ Examples
569
+ --------
570
+ >>> import dimod
571
+ >>> import luna_quantum as lq
572
+ >>> dwave_sampleset = ...
573
+ >>> aqs = lq.translator.DwaveTranslator.to_aq(dwave_sampleset)
574
+ """
575
+
576
+ @overload
577
+ @staticmethod
578
+ def to_aq(sample_set: SampleSet) -> Solution: ...
579
+ @overload
580
+ @staticmethod
581
+ def to_aq(sample_set: SampleSet, timing: Timing) -> Solution: ...
582
+ @overload
583
+ @staticmethod
584
+ def to_aq(sample_set: SampleSet, *, env: Environment) -> Solution: ...
585
+ @overload
586
+ @staticmethod
587
+ def to_aq(
588
+ sample_set: SampleSet, timing: Timing, *, env: Environment
589
+ ) -> Solution: ...
590
+ @staticmethod
591
+ def to_aq(
592
+ sample_set: SampleSet,
593
+ timing: Timing | None = ...,
594
+ *,
595
+ env: Environment | None = ...,
596
+ ) -> Solution:
597
+ """
598
+ Convert a DWave SampleSet to our solution format.
599
+
600
+ Parameters
601
+ ----------
602
+ sample_set : SampleSet
603
+ The SampleSet returned by a DWave solver.
604
+ timing : Timing, optional
605
+ The timing object produced while generating the result.
606
+ env : Environment, optional
607
+ The environment of the model for which the result is produced.
608
+
609
+ Raises
610
+ ------
611
+ NoActiveEnvironmentFoundError
612
+ If no environment is passed to the method or available from the context.
613
+ SolutionTranslationError
614
+ Generally if the solution translation fails. Might be specified by one of
615
+ the two following errors.
616
+ SampleIncorrectLengthError
617
+ If a solution's sample has a different number of variables than the model
618
+ environment passed to the translator.
619
+ SampleUnexpectedVariableError
620
+ If the sample_set contains variables that are not contained in the passed
621
+ environment.
622
+ ModelVtypeError
623
+ If the result's variable types are incompatible with the model environment's
624
+ variable types.
625
+ """
626
+ ...
627
+
628
+ class CqmTranslator:
629
+ """CQM to AQM translator.
630
+
631
+ Utility class for converting between dimod.BinaryQuadraticModel (CQM) and symbolic
632
+ models.
633
+
634
+ `CqmTranslator` provides methods to:
635
+ - Convert a CQM into a symbolic `Model`
636
+ - Convert a `Model` (with quadratic objective) into a CQM
637
+
638
+ These conversions are especially useful when interacting with external solvers
639
+ or libraries that operate on CQMs.
640
+
641
+ Examples
642
+ --------
643
+ >>> import dimod
644
+ >>> import numpy as np
645
+ >>> from luna_quantum.translator import CqmTranslator, Vtype
646
+ >>> bqm = dimod.generators.gnm_random_bqm(5, 10, "BINARY")
647
+
648
+ Create a model from a matrix:
649
+
650
+ >>> model = CqmTranslator.to_aq(bqm, name="bqm_model")
651
+
652
+ Convert it back to a dense matrix:
653
+
654
+ >>> recovered = CqmTranslator.from_aq(model)
655
+ """
656
+
657
+ @staticmethod
658
+ def to_aq(cqm: ConstrainedQuadraticModel) -> Model:
659
+ """
660
+ Convert a CQM into a symbolic `Model`.
661
+
662
+ Parameters
663
+ ----------
664
+ cqm : ConstrainedQuadraticModel
665
+ The CQM.
666
+
667
+ Returns
668
+ -------
669
+ Model
670
+ A symbolic model representing the given CQM.
671
+
672
+ Raises
673
+ ------
674
+ TypeError
675
+ If `cqm` is not of type `ConstrainedQuadraticModel`.
676
+ TranslationError
677
+ If the translation fails for some reason.
678
+ """
679
+ ...
680
+
681
+ @staticmethod
682
+ def from_aq(model: Model) -> ConstrainedQuadraticModel:
683
+ """
684
+ Convert a symbolic model to a dense QUBO matrix representation.
685
+
686
+ Parameters
687
+ ----------
688
+ model : Model
689
+ The symbolic model to convert. The objective must be quadratic-only
690
+ and unconstrained.
691
+
692
+ Returns
693
+ -------
694
+ BinaryQuadraticModel
695
+ The resulting CQM.
696
+
697
+ Raises
698
+ ------
699
+ TranslationError
700
+ If the translation fails for some reason.
701
+ """
702
+ ...
703
+
704
+ class BqmTranslator:
705
+ """BQM to AQM translator.
706
+
707
+ Utility class for converting between dimod.BinaryQuadraticModel (BQM) and symbolic
708
+ models.
709
+
710
+ `BqmTranslator` provides methods to:
711
+ - Convert a BQM into a symbolic `Model`
712
+ - Convert a `Model` (with quadratic objective) into a BQM
713
+
714
+ These conversions are especially useful when interacting with external solvers
715
+ or libraries that operate on BQMs.
716
+
717
+ Examples
718
+ --------
719
+ >>> import dimod
720
+ >>> import numpy as np
721
+ >>> from luna_quantum.translator import BqmTranslator, Vtype
722
+ >>> bqm = dimod.generators.gnm_random_bqm(5, 10, "BINARY")
723
+
724
+ Create a model from a matrix:
725
+
726
+ >>> model = BqmTranslator.to_aq(bqm, name="bqm_model")
727
+
728
+ Convert it back to a dense matrix:
729
+
730
+ >>> recovered = BqmTranslator.from_aq(model)
731
+ """
732
+
733
+ @overload
734
+ @staticmethod
735
+ def to_aq(bqm: BinaryQuadraticModel) -> Model: ...
736
+ @overload
737
+ @staticmethod
738
+ def to_aq(bqm: BinaryQuadraticModel, *, name: str) -> Model: ...
739
+ @staticmethod
740
+ def to_aq(bqm: BinaryQuadraticModel, *, name: str | None = ...) -> Model:
741
+ """
742
+ Convert a BQM into a symbolic `Model`.
743
+
744
+ Parameters
745
+ ----------
746
+ bqm : BinaryQuadraticModel
747
+ The BQM.
748
+ name : str, optional
749
+ An optional name to assign to the resulting model.
750
+
751
+ Returns
752
+ -------
753
+ Model
754
+ A symbolic model representing the given BQM.
755
+ """
756
+ ...
757
+
758
+ @staticmethod
759
+ def from_aq(model: Model) -> BinaryQuadraticModel:
760
+ """
761
+ Convert a symbolic model to a dense QUBO matrix representation.
762
+
763
+ Parameters
764
+ ----------
765
+ model : Model
766
+ The symbolic model to convert. The objective must be quadratic-only
767
+ and unconstrained.
768
+
769
+ Returns
770
+ -------
771
+ BinaryQuadraticModel
772
+ The resulting BQM.
773
+
774
+ Raises
775
+ ------
776
+ TranslationError
777
+ Generally if the translation fails. Might be specified by one of the
778
+ four following errors.
779
+ ModelNotQuadraticError
780
+ If the objective contains higher-order (non-quadratic) terms.
781
+ ModelNotUnconstrainedError
782
+ If the model contains any constraints.
783
+ ModelSenseNotMinimizeError
784
+ If the model's optimization sense is 'maximize'.
785
+ ModelVtypeError
786
+ If the model contains different vtypes or vtypes other than binary and
787
+ spin.
788
+ """
789
+ ...
790
+
791
+ class AwsTranslator:
792
+ """
793
+ Utility class for converting between an AWS result and our solution format.
794
+
795
+ `AwsTranslator` provides methods to:
796
+ - Convert an AWS-style result into our solution `Solution`.
797
+
798
+ The conversions are especially required when interacting with external aws
799
+ solvers/samplers or libraries that operate on aws-based problem-solving/sampling.
800
+
801
+ Examples
802
+ --------
803
+ >>> import luna_quantum as lq
804
+ >>> aws_result = ...
805
+ >>> aqs = lq.translator.AwsTranslator.to_aq(aws_result)
806
+ """
807
+
808
+ @overload
809
+ @staticmethod
810
+ def to_aq(result: dict[str, Any]) -> Solution: ...
811
+ @overload
812
+ @staticmethod
813
+ def to_aq(result: dict[str, Any], timing: Timing) -> Solution: ...
814
+ @overload
815
+ @staticmethod
816
+ def to_aq(result: dict[str, Any], *, env: Environment) -> Solution: ...
817
+ @overload
818
+ @staticmethod
819
+ def to_aq(
820
+ result: dict[str, Any], timing: Timing, *, env: Environment
821
+ ) -> Solution: ...
822
+ @staticmethod
823
+ def to_aq(
824
+ result: dict[str, Any],
825
+ timing: Timing | None = ...,
826
+ *,
827
+ env: Environment | None = ...,
828
+ ) -> Solution:
829
+ """
830
+ Convert an AWS Braket result to our solution format.
831
+
832
+ Parameters
833
+ ----------
834
+ result : dict[str, Any]
835
+ The aws braket result.
836
+ timing : Timing, optional
837
+ The timing object produced while generating the result.
838
+ env : Environment, optional
839
+ The environment of the model for which the result is produced.
840
+
841
+ Raises
842
+ ------
843
+ NoActiveEnvironmentFoundError
844
+ If no environment is passed to the method or available from the context.
845
+ SolutionTranslationError
846
+ Generally if the solution translation fails. Might be specified by one of
847
+ the two following errors.
848
+ SampleIncorrectLengthError
849
+ If a solution's sample has a different number of variables than the model
850
+ environment passed to the translator.
851
+ ModelVtypeError
852
+ If the result's variable types are incompatible with the model environment's
853
+ variable types.
854
+ """
855
+ ...
856
+
857
+ __all__ = [
858
+ "AwsTranslator",
859
+ "BqmTranslator",
860
+ "CqmTranslator",
861
+ "DwaveTranslator",
862
+ "IbmTranslator",
863
+ "LpTranslator",
864
+ "NumpyTranslator",
865
+ "QctrlTranslator",
866
+ "Qubo",
867
+ "QuboTranslator",
868
+ "ZibTranslator",
869
+ ]