luna-quantum 0.0.16__py3-none-any.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 (160) hide show
  1. luna_quantum-0.0.16.dist-info/LICENSE +201 -0
  2. luna_quantum-0.0.16.dist-info/METADATA +46 -0
  3. luna_quantum-0.0.16.dist-info/RECORD +160 -0
  4. luna_quantum-0.0.16.dist-info/WHEEL +4 -0
  5. luna_sdk/__init__.py +2 -0
  6. luna_sdk/constants.py +1 -0
  7. luna_sdk/controllers/__init__.py +2 -0
  8. luna_sdk/controllers/custom_login_client.py +61 -0
  9. luna_sdk/controllers/luna_platform_client.py +62 -0
  10. luna_sdk/controllers/luna_q.py +36 -0
  11. luna_sdk/controllers/luna_solve.py +49 -0
  12. luna_sdk/controllers/luna_transform.py +41 -0
  13. luna_sdk/error/__init__.py +0 -0
  14. luna_sdk/error/http_error_utils.py +100 -0
  15. luna_sdk/exceptions/__init__.py +1 -0
  16. luna_sdk/exceptions/encryption_exception.py +6 -0
  17. luna_sdk/exceptions/luna_exception.py +7 -0
  18. luna_sdk/exceptions/luna_server_exception.py +18 -0
  19. luna_sdk/exceptions/timeout_exception.py +10 -0
  20. luna_sdk/exceptions/transformation.py +11 -0
  21. luna_sdk/interfaces/__init__.py +5 -0
  22. luna_sdk/interfaces/circuit_repo_i.py +62 -0
  23. luna_sdk/interfaces/clients/__init__.py +0 -0
  24. luna_sdk/interfaces/clients/client_i.py +10 -0
  25. luna_sdk/interfaces/clients/luna_q_i.py +39 -0
  26. luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
  27. luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
  28. luna_sdk/interfaces/cplex_repo_i.py +121 -0
  29. luna_sdk/interfaces/info_repo_i.py +40 -0
  30. luna_sdk/interfaces/lp_repo_i.py +106 -0
  31. luna_sdk/interfaces/optimization_repo_i.py +262 -0
  32. luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
  33. luna_sdk/interfaces/repository_i.py +14 -0
  34. luna_sdk/interfaces/solutions_repo_i.py +219 -0
  35. luna_sdk/py.typed +0 -0
  36. luna_sdk/repositories/__init__.py +4 -0
  37. luna_sdk/repositories/circuit_repo.py +104 -0
  38. luna_sdk/repositories/cplex_repo.py +118 -0
  39. luna_sdk/repositories/info_repo.py +45 -0
  40. luna_sdk/repositories/lp_repo.py +105 -0
  41. luna_sdk/repositories/optimization_repo.py +358 -0
  42. luna_sdk/repositories/qpu_token_repo.py +226 -0
  43. luna_sdk/repositories/solutions_repo.py +347 -0
  44. luna_sdk/schemas/__init__.py +4 -0
  45. luna_sdk/schemas/circuit.py +43 -0
  46. luna_sdk/schemas/create/__init__.py +3 -0
  47. luna_sdk/schemas/create/circuit.py +29 -0
  48. luna_sdk/schemas/create/optimization.py +22 -0
  49. luna_sdk/schemas/create/qpu_token.py +26 -0
  50. luna_sdk/schemas/create/qubo.py +19 -0
  51. luna_sdk/schemas/create/solution.py +15 -0
  52. luna_sdk/schemas/enums/__init__.py +0 -0
  53. luna_sdk/schemas/enums/circuit.py +14 -0
  54. luna_sdk/schemas/enums/optimization.py +10 -0
  55. luna_sdk/schemas/enums/problem.py +48 -0
  56. luna_sdk/schemas/enums/qpu_token_type.py +6 -0
  57. luna_sdk/schemas/enums/solution.py +8 -0
  58. luna_sdk/schemas/enums/status.py +10 -0
  59. luna_sdk/schemas/enums/timeframe.py +11 -0
  60. luna_sdk/schemas/error_message.py +12 -0
  61. luna_sdk/schemas/optimization.py +75 -0
  62. luna_sdk/schemas/optimization_formats/__init__.py +0 -0
  63. luna_sdk/schemas/optimization_formats/bqm.py +34 -0
  64. luna_sdk/schemas/optimization_formats/cqm.py +127 -0
  65. luna_sdk/schemas/optimization_formats/lp.py +9 -0
  66. luna_sdk/schemas/optimization_formats/qm.py +30 -0
  67. luna_sdk/schemas/pretty_base.py +49 -0
  68. luna_sdk/schemas/qpu_token.py +60 -0
  69. luna_sdk/schemas/representation.py +19 -0
  70. luna_sdk/schemas/rest/__init__.py +0 -0
  71. luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
  72. luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
  73. luna_sdk/schemas/solution.py +227 -0
  74. luna_sdk/schemas/solver_info.py +11 -0
  75. luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
  76. luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
  77. luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
  78. luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
  79. luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
  80. luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
  81. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
  82. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
  83. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
  84. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
  85. luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
  86. luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
  87. luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
  88. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
  89. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
  90. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
  91. luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
  92. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
  93. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
  94. luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
  95. luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
  96. luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
  97. luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
  98. luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
  99. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
  100. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
  101. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
  102. luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
  103. luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
  104. luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
  105. luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
  106. luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
  107. luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
  108. luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
  109. luna_sdk/schemas/transformations/__init__.py +2 -0
  110. luna_sdk/schemas/transformations/bqm.py +33 -0
  111. luna_sdk/schemas/transformations/matrix.py +12 -0
  112. luna_sdk/schemas/use_cases/__init__.py +54 -0
  113. luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
  114. luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
  115. luna_sdk/schemas/use_cases/base.py +5 -0
  116. luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
  117. luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
  118. luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
  119. luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
  120. luna_sdk/schemas/use_cases/exact_cover.py +50 -0
  121. luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
  122. luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
  123. luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
  124. luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
  125. luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
  126. luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
  127. luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
  128. luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
  129. luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
  130. luna_sdk/schemas/use_cases/linear_regression.py +59 -0
  131. luna_sdk/schemas/use_cases/lmwcs.py +80 -0
  132. luna_sdk/schemas/use_cases/longest_path.py +49 -0
  133. luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
  134. luna_sdk/schemas/use_cases/max2sat.py +51 -0
  135. luna_sdk/schemas/use_cases/max3sat.py +52 -0
  136. luna_sdk/schemas/use_cases/max_clique.py +59 -0
  137. luna_sdk/schemas/use_cases/max_cut.py +47 -0
  138. luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
  139. luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
  140. luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
  141. luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
  142. luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
  143. luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
  144. luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
  145. luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
  146. luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
  147. luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
  148. luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
  149. luna_sdk/schemas/use_cases/set_cover.py +55 -0
  150. luna_sdk/schemas/use_cases/set_packing.py +53 -0
  151. luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
  152. luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
  153. luna_sdk/schemas/use_cases/subset_sum.py +36 -0
  154. luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
  155. luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
  156. luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
  157. luna_sdk/schemas/use_cases/type_aliases.py +11 -0
  158. luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
  159. luna_sdk/utils/__init__.py +0 -0
  160. luna_sdk/utils/qpu_tokens.py +52 -0
@@ -0,0 +1,177 @@
1
+ from typing import Any, List, Literal, Optional, Tuple, Union
2
+
3
+ from numpy.typing import NDArray
4
+ from pydantic import BaseModel, ConfigDict, Field, field_serializer
5
+ from typing_extensions import Annotated
6
+
7
+ OneHot = Literal["no_way", "one_way", "two_way"]
8
+
9
+
10
+ class VarShapeBase(BaseModel):
11
+ name: str
12
+ one_hot: OneHot = "no_way"
13
+
14
+
15
+ class WithConstantBits(VarShapeBase):
16
+ shape: Optional[List[int]] = None
17
+ constant_bits: Optional[NDArray] = None
18
+
19
+ model_config = ConfigDict(arbitrary_types_allowed=True)
20
+
21
+ @field_serializer("constant_bits")
22
+ def serialize_constant_bits(self, constant_bits: Optional[NDArray], _):
23
+ if constant_bits is None:
24
+ return None
25
+ return constant_bits.tolist()
26
+
27
+
28
+ class BitArrayShape(WithConstantBits):
29
+ """An object of the class :class:`BitArrayShape` represents an array structure as part of a bit vector. It allows
30
+ multidimensional indexed access to the bit variables of a :class:`BinPol` polynomial. :class:`BitArrayShape`
31
+ objects are used inside :class:`VarShapeSet` objects, which organize index data of a complete bit vector for
32
+ a polynomial. Bit variables of such polynomials can then be accessed by name and indices according
33
+ to the shape specified in the :class:`BitArrayShape` object.
34
+
35
+ Parameters
36
+ ----------
37
+ shape: List[int]
38
+ shape of the index; specify the length of each dimension
39
+ constant_bits: Optional[NDArray]
40
+ numpy array of type int8 with same shape as the previous parameter containing 0 and 1 for constant bits and -1 variable bits
41
+ one_hot: OneHot
42
+ define variable as one_hot section
43
+ axis_names: Optional[List[str]]
44
+ Names for the axis.
45
+ index_offsets: Optional[List[int]]
46
+ index_offsets of the index, specify the index_offsets of each dimension
47
+ """
48
+
49
+ type: Literal["BitArrayShape"] = "BitArrayShape"
50
+ axis_names: Optional[List[str]] = None
51
+ index_offsets: Optional[List[int]] = None
52
+
53
+
54
+ class Variable(WithConstantBits):
55
+ """A ``Variable`` is a binary polynomial, that represents a numerical value according to values of the underlying bits.
56
+ The variable is defined by a value range and a specific representation scheme that is realized in respective
57
+ inherited classes.
58
+
59
+ Parameters
60
+ ----------
61
+ name: str
62
+ name of the variable
63
+ start: float
64
+ first number in the list of values to be represented by the variable
65
+ stop: float
66
+ stop value for the list of numbers to be represented by the variable; stop is omitted
67
+ step: float
68
+ increment for the list of numbers to be represented by the variable
69
+ shape: List[int]
70
+ shape of the index; specify the length of each dimension
71
+ constant_bits: Optional[NDArray]
72
+ numpy array of type int8 with same shape as the previous parameter containing 0 and 1 for constant bits and -1 variable bits
73
+ one_hot: OneHot
74
+ define variable as one_hot section
75
+ """
76
+
77
+ type: Literal["Variable"] = "Variable"
78
+ start: float
79
+ stop: float
80
+ step: float
81
+
82
+
83
+ class Category(VarShapeBase):
84
+ """An object of the class :class:`Category` represents an array structure as part of a bit vector. It allows
85
+ indexed access to the bit variables of a :class:`BinPol` polynomial. :class:`Category`
86
+ objects are used inside :class:`VarShapeSet` objects, which organize index data of a complete bit vector for
87
+ a polynomial. Bit variables of such polynomials can then be accessed by ``name`` and categorical indices according
88
+ to the ``values`` specified in the :class:`BitArrayShape` object. A categorical index can be any sequence of
89
+ unique values.
90
+
91
+ Parameters
92
+ ----------
93
+ name: str
94
+ name of the new index
95
+ values: List[Any]
96
+ list of unique values for this category
97
+ one_hot: OneHot
98
+ define variable as one_hot section
99
+ axis_names: List[str]
100
+ Names for the axis.
101
+ """
102
+
103
+ type: Literal["Category"] = "Category"
104
+ values: List[Any] = []
105
+ axis_names: Optional[List[str]] = None
106
+
107
+
108
+ VarDef = Annotated[
109
+ Union[BitArrayShape, Variable, Category], Field(discriminator="type")
110
+ ]
111
+
112
+
113
+ class OneHotGroup(BaseModel):
114
+ """O:class:`dadk.BinPol.OneHotGroup` is used to define a one-way-one-hot group within a set of bit variables.
115
+ In particular, the entries of the one-way-one-hot group are specified as tuples including the name of the variable
116
+ specified in a BitArrayShape and (optionally) the indices of the variable in every dimension. Here, a single number
117
+ for a particular dimension means the index of the variable with the specified numbers in the dimensions is
118
+ included in the one-way-one-hot group. Another possibility is to specify a list or a range of indices for each dimension in
119
+ order to include all indices of the variables with these specified numbers in the dimensions in the one-way-one-hot group.
120
+ Finally, one can specify the value None for a dimension. In this case, the whole range of that dimension is considered for the
121
+ one-way-one-hot group.
122
+
123
+ Parameters
124
+ ----------
125
+ entries: Union[List, Tuple]
126
+ one or more Lists or Tuples specifying the members of a one-way-one-hot group.
127
+ """
128
+
129
+ entries: List[Union[List, Tuple]] = []
130
+
131
+
132
+ class VarShapeSet(BaseModel):
133
+ """:class:`dadk.BinPol.VarShapeSet` defines an indexing structure for the bits of a BinPol polynomial. Plain BinPol
134
+ polynomials are defined on a set of bits indexed by a ``range(N)`` for some integer ``N``. The ``VarShapeSet`` lays
135
+ a sequence of disjoint named sections over this linear structure. Bits within a section can be addressed by the
136
+ defined name. With a ``BitArrayShape`` a section can be defined as multidimensional array and single bits in the
137
+ section can be addressed by an appropriate tuple of indices. With a ``Variable`` definition the section represents
138
+ a number encoded in certain bit schemes; in this case it is possible to retrieve the represented value instead of
139
+ reading single bits.
140
+
141
+ Parameters
142
+ ----------
143
+ var_defs: Union[BitArrayShape, Variable, Category]
144
+ one or more section definitions of type :class:`BitArrayShape`, :class:`Variable` or :class:`Category`
145
+ one_hot_groups: Optional[List[OneHotGroup]]
146
+ optional list of special one_hot group definitions
147
+ """
148
+
149
+ var_defs: List[VarDef] = []
150
+ one_hot_groups: Optional[List[OneHotGroup]] = None
151
+
152
+
153
+ class PartialConfig(BaseModel):
154
+ """:class:`PartialConfig` produces a dictionary that can be used to initialize bits for the annealing algorithm.
155
+
156
+ The start state for an annealing or parallel tempering optimization can be specified.
157
+ The used dictionary addresses bits with their flattened index. With the class
158
+ :class:`PartialConfig` those bits can be specified on the symbolic level of
159
+ :class:`BitArrayShape` or :class:`Variable` and the offsets in a :class:`VarShapeSet` are calculated automatically.
160
+ Flat indices can be used directly, if they are known. For variables, indices are used directly and do not need
161
+ to be adjusted by a global index consideration from the :class:`VarShapeSet`. After setting the start state accordingly,
162
+ a string can be created with the method ``as_json``. If one_hot or two_hot specifications are given in :class:`VarShapeSet`, the dictionary
163
+ generated in the methods ``get_dict`` or ``as_json`` is build up with respect to the set bit variables and one-way or two-way rules.
164
+
165
+ The object is initialized by a :class:`VarShapeSet` object or None. An initialization with None can be used for :class:`BinPol`.
166
+
167
+ Parameters
168
+ ----------
169
+
170
+ var_shape_set: Optional[VarShapeSet]
171
+ This parameter should be an object of :class:`VarShapeSet` or ``None``
172
+ auto_fill_cold_bits: bool
173
+ In case ``var_shape_set`` is defined and contains a 1-hot group, and a hot bit is set to ``True`` and this parameter is also set to ``True``, then all related cold bits are set to ``False``. Default is ``True``
174
+ """
175
+
176
+ var_shape_set: Optional[VarShapeSet] = None
177
+ auto_fill_cold_bits: bool = True
@@ -0,0 +1,4 @@
1
+ """Solver Parameters"""
2
+
3
+ from luna_sdk.schemas.solver_parameters.ibm.qaoa import QaoaParameters
4
+ from luna_sdk.schemas.solver_parameters.ibm.vqe import VqeParameters
@@ -0,0 +1,64 @@
1
+ from pydantic import BaseModel, ConfigDict
2
+
3
+ from luna_sdk.schemas.solver_parameters.ibm.standard_parameters import (
4
+ StandardParameters,
5
+ )
6
+
7
+
8
+ class QaoaConfig(BaseModel):
9
+ """
10
+ Parameters
11
+ ----------
12
+ reps : int
13
+ Depth of the circuit. Default: 1.
14
+ name : str
15
+ Name of the circuit. Default: "QAOA".
16
+ """
17
+
18
+ reps: int = 1
19
+ name: str = "QAOA"
20
+
21
+ model_config = ConfigDict(extra="forbid")
22
+
23
+
24
+ class QaoaParameters(StandardParameters):
25
+ """
26
+ The Quantum Approximate Optimization Algorithm ([QAOA](https://arxiv.org/abs/1411.4028))
27
+ solves combinatorial optimization problems by approximating the solution:
28
+
29
+ For a given problem represented as a cost Hamiltonian we formulate two unitary
30
+ operators.
31
+ The QAOA solves the problem by iteratively applying the two unitary operators on
32
+ the cost Hamiltonian for a number of steps p.
33
+ The angles for the unitary operators are iteratively updated by measuring the state
34
+ after applying these (like in VQE).
35
+
36
+ For further information see qiskit's [QAOA tutorial](https://learning.quantum.ibm.com/tutorial/quantum-approximate-optimization-algorithm).
37
+
38
+ Parameters
39
+ ----------
40
+ backend : str | dict[str, Any] | None
41
+ Which backend to use. Default: "AerSimulator"
42
+ - If None, will use no backend and StatevectorSampler and StatevectorEstimator.
43
+ - If dict, will call `runtime_service.least_busy` with the params given in the dict.
44
+ - If str:
45
+ - If "AerSimulator": use AerSimulator
46
+ - If string starts with "Fake, will use the corresponding fake backend from `qiskit_ibm_runtime.fake_provider`.
47
+ - Otherwise, will try to use a real backend with this name.
48
+ shots : int = 1024
49
+ Shots for the optimizer. Default: 1024
50
+ dynamical_decoupling : dict[str, Any] = {}
51
+ Dynamical decoupling options for the optimizer. Default: {}
52
+ optimizer : str
53
+ Name of the optimizer to use in scipy minimize. Default: "COBYLA"
54
+ maxiter : int
55
+ Maximum number of iterations for the algorithm. Default: 10
56
+ optimization_level : int
57
+ Optmimization level for the pass manager. Default: 2
58
+ service_config : ServiceConfig
59
+ Parameters to be passed to the `QiskitRuntimeService` object.
60
+ qaoa_config : QaoaConfig
61
+ Configuration for the QAOAAnsatz; see `qiskit.circuit.library.QAOAAnsatz`.
62
+ """
63
+
64
+ qaoa_config: QaoaConfig = QaoaConfig()
@@ -0,0 +1,27 @@
1
+ from typing import Any, Dict, Literal, Optional, Union
2
+
3
+ from pydantic import BaseModel, ConfigDict
4
+
5
+
6
+ class ServiceConfig(BaseModel):
7
+ channel: Optional[Literal["ibm_cloud", "ibm_quantum"]] = "ibm_quantum"
8
+ url: Optional[str] = None
9
+ name: Optional[str] = None
10
+ instance: Optional[str] = None
11
+ proxies: Optional[dict] = None
12
+ verify: Optional[bool] = None
13
+ channel_strategy: Optional[str] = None
14
+
15
+ model_config = ConfigDict(extra="forbid")
16
+
17
+
18
+ class StandardParameters(BaseModel):
19
+ backend: Optional[Union[str, Dict[str, Any]]] = "AerSimulator"
20
+ shots: int = 1024
21
+ dynamical_decoupling: Dict[str, Any] = {}
22
+ optimizer: str = "COBYLA"
23
+ maxiter: int = 10
24
+ optimization_level: int = 2
25
+ service_config: ServiceConfig = ServiceConfig()
26
+
27
+ model_config = ConfigDict(extra="forbid")
@@ -0,0 +1,49 @@
1
+ from typing import Any, Dict
2
+
3
+ from luna_sdk.schemas.solver_parameters.ibm.standard_parameters import (
4
+ StandardParameters,
5
+ )
6
+
7
+
8
+ class VqeParameters(StandardParameters):
9
+ """
10
+ The Variational Quantum Eigensolver ([VQE](https://arxiv.org/abs/1304.3061)) solves
11
+ combinatorial optimization problems by approximating the solution:
12
+ \n For a given problem represented as a cost Hamiltonian we apply
13
+ a classical/quantum hybrid algorithm to find the solution. The VQE solves
14
+ the problem by iteratively applying a linear transformation
15
+ (variational form) on the cost Hamiltonian and optimizing the parameters of
16
+ the transformation using a classical optimizer.
17
+
18
+ For further information see qiskit's [VQE tutorial](https://learning.quantum.ibm.com/tutorial/variational-quantum-eigensolver).
19
+
20
+ Parameters
21
+ ----------
22
+ backend : str | dict[str, Any] | None
23
+ Which backend to use. Default: "AerSimulator"
24
+ - If None, will use no backend and StatevectorSampler and StatevectorEstimator.
25
+ - If dict, will call `runtime_service.least_busy` with the params given in the dict.
26
+ - If str:
27
+ - If "AerSimulator": use AerSimulator
28
+ - If string starts with "Fake, will use the corresponding fake backend from qiskit_ibm_runtime.fake_provider
29
+ - Otherwise, will try to use a real backend with this name
30
+ shots : int
31
+ Shots for the optimizer. Default: 1024
32
+ dynamical_decoupling : dict[str, Any]
33
+ Dynamical decoupling options for the optimizer. Default: {}
34
+ optimizer : str
35
+ Name of the optimizer to use in scipy minimize. Default: "COBYLA"
36
+ maxiter : int
37
+ Maximum number of iterations for the algorithm. Default: 10
38
+ optimization_level : int
39
+ Optmimization level for the pass manager. Default: 2
40
+ service_config : ServiceConfig
41
+ Parameters to be passed to the `QiskitRuntimeService` object.
42
+ ansatz : str
43
+ Which ansatz to use from `qiskit.circuit.library`. Default: "EfficientSU2"
44
+ ansatz_config : dict[str, Any]
45
+ Configuration for the ansatz. Default: {}
46
+ """
47
+
48
+ ansatz: str = "EfficientSU2"
49
+ ansatz_config: Dict[str, Any] = {}
@@ -0,0 +1 @@
1
+ from luna_sdk.schemas.solver_parameters.qctrl.qaoa import QaoaParameters
@@ -0,0 +1,47 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class QaoaParameters(BaseModel):
7
+ """
8
+ QAOA is a popular algorithm that can be applied to a wide range of optimization problems that are out of reach today
9
+ like portfolio optimization, efficient logistics routing, and asset liability management.
10
+
11
+ This version of QAOA is from Q-CTRL's software framework “Fire Opal”.
12
+ When running QAOA via Fire Opal, all aspects of running QAOA on real hardware are
13
+ fully optimized to reduce errors and improve the quality of solutions. By tailoring all parts of the algorithm to be hardware-optimized,
14
+ Fire Opal enables larger problems to converge on the correct solution and do so in fewer iterations, reducing the required execution time.
15
+
16
+ For further information, see Q-CTRL's documentation(https://docs.q-ctrl.com/fire-opal/topics/fire-opals-qaoa-solver).
17
+
18
+ Parameters
19
+ ----------
20
+ ### organization_slug: str | None
21
+ Organization slug from the organization of the user. Required, if the user is part of more than one organization.
22
+ This information can be retrieved from your Q-CTRL account. Default: None
23
+
24
+ ### backend_name: str
25
+ Defines backend simulator for the algorithm.
26
+ To see, which backends are available, please check your ibm account.
27
+ It usually starts with 'ibm_', e.g., 'ibm_osaka'. 'least_busy' is also allowed. In this case, the least busy solver will be used.
28
+ Default: 'basic_simulator'
29
+
30
+ ### hub: str
31
+ The IBM Quantum hub. Default: 'ibm-q'
32
+
33
+ ### group: str
34
+ The IBM Quantum group. Default: 'open'
35
+
36
+ ### project: str
37
+ The IBM Quantum project. Default: 'main'
38
+
39
+ ### min_num_vars: int
40
+ Default: 1
41
+ """
42
+
43
+ organization_slug: Any = None
44
+ backend_name: Optional[str] = None
45
+ hub: str = "ibm-q"
46
+ group: str = "open"
47
+ project: str = "main"
@@ -0,0 +1,2 @@
1
+ from .bqm import BQMResultSchema, BQMInverter, BQMSchema
2
+ from .matrix import MatrixSchema
@@ -0,0 +1,33 @@
1
+ from enum import Enum
2
+ from typing import Dict
3
+
4
+ from pydantic import BaseModel, ConfigDict
5
+
6
+
7
+ class VarTypeStrEnum(str, Enum):
8
+ SPIN = "SPIN"
9
+ BINARY = "BINARY"
10
+ INTEGER = "INTEGER"
11
+ DISCRETE = "DISCRETE"
12
+ REAL = "REAL"
13
+
14
+
15
+ class BQMSchema(BaseModel):
16
+ linear: Dict[str, float]
17
+ quadratic: Dict[str, float]
18
+ offset: float
19
+ var_type: VarTypeStrEnum
20
+
21
+
22
+ class BQMInverter(BaseModel):
23
+ binary: Dict[str, VarTypeStrEnum]
24
+ integers: Dict[str, BQMSchema]
25
+
26
+ model_config = ConfigDict(arbitrary_types_allowed=True)
27
+
28
+
29
+ class BQMResultSchema(BaseModel):
30
+ bqm: BQMSchema
31
+ inverter: BQMInverter
32
+
33
+ model_config = ConfigDict(arbitrary_types_allowed=True)
@@ -0,0 +1,12 @@
1
+ from typing import List, Dict
2
+
3
+ from pydantic import BaseModel
4
+
5
+ from luna_sdk.schemas.transformations.bqm import BQMInverter
6
+
7
+
8
+ class MatrixSchema(BaseModel):
9
+ matrix: List[List[float]]
10
+ variable_indices: Dict[str, int]
11
+
12
+ inverter: BQMInverter
@@ -0,0 +1,54 @@
1
+ from .arbitrage_edge_based import ArbitrageEdgeBased
2
+ from .arbitrage_node_based import ArbitrageNodeBased
3
+ from .base import UseCase
4
+ from .binary_integer_linear_programming import BinaryIntegerLinearProgramming
5
+ from .binary_paint_shop_problem import BinaryPaintShopProblem
6
+ from .credit_scoring_feature_selection import CreditScoringFeatureSelection
7
+ from .dynamic_portfolio_optimization import DynamicPortfolioOptimization
8
+ from .exact_cover import ExactCover
9
+ from .flight_gate_assignment import FlightGateAssignment
10
+ from .graph_coloring import GraphColoring
11
+ from .graph_isomorphism import GraphIsomorphism
12
+ from .graph_partitioning import GraphPartitioning
13
+ from .hamiltonian_cycle import HamiltonianCycle
14
+ from .induced_subgraph_isomorphism import InducedSubGraphIsomorphism
15
+ from .job_shop_scheduling import JobShopScheduling
16
+ from .k_medoids_clustering import KMedoidsClustering
17
+ from .knapsack_integer_weights import KnapsackIntegerWeights
18
+ from .linear_regression import LinearRegression
19
+ from .lmwcs import LabeledMaxWeightedCommonSubgraph
20
+ from .longest_path import LongestPath
21
+ from .market_graph_clustering import MarketGraphClustering
22
+ from .max2sat import Max2SAT
23
+ from .max3sat import Max3SAT
24
+ from .max_clique import MaxClique
25
+ from .max_cut import MaxCut
26
+ from .max_independent_set import MaxIndependentSet
27
+ from .minimal_maximal_matching import MinimalMaximalMatching
28
+ from .minimal_spanning_tree import MinimalSpanningTree
29
+ from .minimum_vertex_cover import MinimumVertexCover
30
+ from .number_partitioning import NumberPartitioning
31
+ from .portfolio_optimization import PortfolioOptimization
32
+ from .portfolio_optimization_ib_tv import (
33
+ PortfolioOptimizationInvestmentBandsTargetVolatility,
34
+ )
35
+ from .quadratic_assignment import QuadraticAssignment
36
+ from .quadratic_knapsack import QuadraticKnapsack
37
+ from .satellite_scheduling import SatelliteScheduling
38
+ from .sensor_placement import SensorPlacement
39
+ from .set_cover import SetCover
40
+ from .set_packing import SetPacking
41
+ from .set_partitioning import SetPartitioning
42
+ from .subgraph_isomorphism import SubGraphIsomorphism
43
+ from .subset_sum import SubsetSum
44
+ from .support_vector_machine import SupportVectorMachine
45
+ from .traffic_flow import TrafficFlow
46
+ from .travelling_salesman_problem import TravellingSalesmanProblem
47
+ from .type_aliases import (
48
+ CalculusLiteral,
49
+ Clause,
50
+ NestedDictGraph,
51
+ NestedDictIntGraph,
52
+ Node,
53
+ )
54
+ from .weighted_max_cut import WeightedMaxCut
@@ -0,0 +1,49 @@
1
+ from typing import Dict, Literal, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class ArbitrageEdgeBased(UseCase):
9
+ """
10
+ # Arbitrage Edge Based
11
+
12
+ Description
13
+ -----------
14
+
15
+ In economics and finance, arbitrage is the practice of taking advantage of a
16
+ difference in prices in two or more markets; striking a combination of matching
17
+ deals to capitalize on the difference.
18
+ The edge based Arbitrage problem tries to find the best cycle in a directed and
19
+ complete graph. In this graph, each node corresponds to an asset and each directed
20
+ edge is weighted with the corresponding conversion rate. It creates a QUBO with the
21
+ size _n_edges x n_edges_, which produces a solution vector where each binary
22
+ position maps to an edge.
23
+
24
+ Links
25
+ -----
26
+
27
+ [Wikipedia](https://en.wikipedia.org/wiki/Arbitrage)
28
+
29
+ [Transformation](http://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Finding-Optimal-Arbitrage-Opportunities-Using-a-Quantum-Annealer.pdf)
30
+
31
+ Attributes
32
+ ----------
33
+
34
+ ### graph: Dict[str, Dict[str, Dict[str, float]]]
35
+ \n The input graph as described above in the form of nested dictionaries.
36
+ \n Example for three different currencies:
37
+ \n _{_
38
+ \n _0: {1: {'weight': 1.31904}, 2: {'weight': 6.72585}},_
39
+ \n _1: {0: {'weight': 0.75799}, 2: {'weight': 5.10327},_
40
+ \n _2: {0: {'weight': 0.14864}, 1: {'weight': 0.19586}}_
41
+ \n _}_
42
+
43
+ ### penalty: Optional[float] = None
44
+ \n The penalty term for the QUBO matrix. Has to be greater than 0.
45
+ """
46
+
47
+ name: Literal["AEB"] = "AEB"
48
+ graph: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
49
+ penalty: Optional[float] = None
@@ -0,0 +1,54 @@
1
+ from typing import Dict, Literal, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class ArbitrageNodeBased(UseCase):
9
+ """
10
+ # Arbitrage Node Based
11
+
12
+ Description
13
+ -----------
14
+
15
+ In economics and finance, arbitrage is the practice of taking advantage of a
16
+ difference in prices in two or more markets; striking a combination of matching
17
+ deals to capitalize on the difference.
18
+ The node based Arbitrage problem tries to find the best cycle in a directed and
19
+ complete graph. In this graph, each node corresponds to an asset and each directed
20
+ edge is weighted with the corresponding conversion rate.
21
+ The problem creates a QUBO with the size
22
+ _(n_nodes * cycle_length) x (n_nodes * cycle_length)_, which produces a solution
23
+ vector where each binary position maps to to a node and its position in the cycle.
24
+
25
+ Links
26
+ -----
27
+
28
+ [Wikipedia](https://en.wikipedia.org/wiki/Arbitrage)
29
+
30
+ [Transformation](http://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Finding-Optimal-Arbitrage-Opportunities-Using-a-Quantum-Annealer.pdf)
31
+
32
+ Attributes
33
+ ----------
34
+
35
+ ### graph: Dict[str, Dict[str, Dict[str, float]]]
36
+ \n The input graph as described above in the form of nested dictionaries.
37
+ \n Example for three different currencies:\n
38
+ \n _{_
39
+ \n _0: {1: {'weight': 1.31904}, 2: {'weight': 6.72585}},_
40
+ \n _1: {0: {'weight': 0.75799}, 2: {'weight': 5.10327},_
41
+ \n _2: {0: {'weight': 0.14864}, 1: {'weight': 0.19586}}_
42
+ \n _}_
43
+
44
+ ### penalty: Optional[float] = None
45
+ \n The penalty term for the QUBO matrix. Has to be greater than 0.
46
+
47
+ ### K: Optional[int] = None
48
+ \n The maximum length of the arbitrage cycle.
49
+ """
50
+
51
+ name: Literal["ANB"] = "ANB"
52
+ graph: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
53
+ penalty: Optional[float] = None
54
+ K: Optional[int] = None
@@ -0,0 +1,5 @@
1
+ from luna_sdk.schemas.pretty_base import PrettyBase
2
+
3
+
4
+ class UseCase(PrettyBase):
5
+ name: str
@@ -0,0 +1,53 @@
1
+ from typing import List, Literal
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class BinaryIntegerLinearProgramming(UseCase):
7
+ """
8
+ # Binary Integer Linear Programming
9
+
10
+ Description
11
+ -----------
12
+
13
+ For a binary decision vector _x_ and some vector _c_ of length _N_, the Binary
14
+ Integer Linear Programming problem maximizes _c * x_, given the constraint _Sx = b_
15
+ with _S_ being an _m x N_ matrix and _b_ a vector with _m_ components.
16
+
17
+ Q-Bit Interpretation
18
+ --------------------
19
+
20
+ The vector of qubits is simply the decision vector _x_.
21
+
22
+ Links
23
+ -----
24
+
25
+ [Wikipedia](https://en.wikipedia.org/wiki/Integer_programming)
26
+
27
+ [Transformation](https://arxiv.org/pdf/1302.5843.pdf)
28
+
29
+ Attributes
30
+ ----------
31
+
32
+ ### S: List[List[int]]
33
+ \n The _m x N_ matrix.
34
+
35
+ ### b: List[int]
36
+ \n Vector with _m_ components.
37
+
38
+ ### c: List[int]
39
+ \n Custom vector of length _N_.
40
+
41
+ ### A: int
42
+ \n A constant enforcing, if possible, that _Sx = b_.
43
+
44
+ ### B: int
45
+ \n A constant (_B << A_) helping maximize _c * x_.
46
+ """
47
+
48
+ name: Literal["BIP"] = "BIP"
49
+ S: List[List[int]]
50
+ b: List[int]
51
+ c: List[int]
52
+ A: int = 10
53
+ B: int = 2