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.
- luna_quantum-0.0.16.dist-info/LICENSE +201 -0
- luna_quantum-0.0.16.dist-info/METADATA +46 -0
- luna_quantum-0.0.16.dist-info/RECORD +160 -0
- luna_quantum-0.0.16.dist-info/WHEEL +4 -0
- luna_sdk/__init__.py +2 -0
- luna_sdk/constants.py +1 -0
- luna_sdk/controllers/__init__.py +2 -0
- luna_sdk/controllers/custom_login_client.py +61 -0
- luna_sdk/controllers/luna_platform_client.py +62 -0
- luna_sdk/controllers/luna_q.py +36 -0
- luna_sdk/controllers/luna_solve.py +49 -0
- luna_sdk/controllers/luna_transform.py +41 -0
- luna_sdk/error/__init__.py +0 -0
- luna_sdk/error/http_error_utils.py +100 -0
- luna_sdk/exceptions/__init__.py +1 -0
- luna_sdk/exceptions/encryption_exception.py +6 -0
- luna_sdk/exceptions/luna_exception.py +7 -0
- luna_sdk/exceptions/luna_server_exception.py +18 -0
- luna_sdk/exceptions/timeout_exception.py +10 -0
- luna_sdk/exceptions/transformation.py +11 -0
- luna_sdk/interfaces/__init__.py +5 -0
- luna_sdk/interfaces/circuit_repo_i.py +62 -0
- luna_sdk/interfaces/clients/__init__.py +0 -0
- luna_sdk/interfaces/clients/client_i.py +10 -0
- luna_sdk/interfaces/clients/luna_q_i.py +39 -0
- luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
- luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
- luna_sdk/interfaces/cplex_repo_i.py +121 -0
- luna_sdk/interfaces/info_repo_i.py +40 -0
- luna_sdk/interfaces/lp_repo_i.py +106 -0
- luna_sdk/interfaces/optimization_repo_i.py +262 -0
- luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
- luna_sdk/interfaces/repository_i.py +14 -0
- luna_sdk/interfaces/solutions_repo_i.py +219 -0
- luna_sdk/py.typed +0 -0
- luna_sdk/repositories/__init__.py +4 -0
- luna_sdk/repositories/circuit_repo.py +104 -0
- luna_sdk/repositories/cplex_repo.py +118 -0
- luna_sdk/repositories/info_repo.py +45 -0
- luna_sdk/repositories/lp_repo.py +105 -0
- luna_sdk/repositories/optimization_repo.py +358 -0
- luna_sdk/repositories/qpu_token_repo.py +226 -0
- luna_sdk/repositories/solutions_repo.py +347 -0
- luna_sdk/schemas/__init__.py +4 -0
- luna_sdk/schemas/circuit.py +43 -0
- luna_sdk/schemas/create/__init__.py +3 -0
- luna_sdk/schemas/create/circuit.py +29 -0
- luna_sdk/schemas/create/optimization.py +22 -0
- luna_sdk/schemas/create/qpu_token.py +26 -0
- luna_sdk/schemas/create/qubo.py +19 -0
- luna_sdk/schemas/create/solution.py +15 -0
- luna_sdk/schemas/enums/__init__.py +0 -0
- luna_sdk/schemas/enums/circuit.py +14 -0
- luna_sdk/schemas/enums/optimization.py +10 -0
- luna_sdk/schemas/enums/problem.py +48 -0
- luna_sdk/schemas/enums/qpu_token_type.py +6 -0
- luna_sdk/schemas/enums/solution.py +8 -0
- luna_sdk/schemas/enums/status.py +10 -0
- luna_sdk/schemas/enums/timeframe.py +11 -0
- luna_sdk/schemas/error_message.py +12 -0
- luna_sdk/schemas/optimization.py +75 -0
- luna_sdk/schemas/optimization_formats/__init__.py +0 -0
- luna_sdk/schemas/optimization_formats/bqm.py +34 -0
- luna_sdk/schemas/optimization_formats/cqm.py +127 -0
- luna_sdk/schemas/optimization_formats/lp.py +9 -0
- luna_sdk/schemas/optimization_formats/qm.py +30 -0
- luna_sdk/schemas/pretty_base.py +49 -0
- luna_sdk/schemas/qpu_token.py +60 -0
- luna_sdk/schemas/representation.py +19 -0
- luna_sdk/schemas/rest/__init__.py +0 -0
- luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
- luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
- luna_sdk/schemas/solution.py +227 -0
- luna_sdk/schemas/solver_info.py +11 -0
- luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
- luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
- luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
- luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
- luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
- luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
- luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
- luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
- luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
- luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
- luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
- luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
- luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
- luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
- luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
- luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
- luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
- luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
- luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
- luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
- luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
- luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
- luna_sdk/schemas/transformations/__init__.py +2 -0
- luna_sdk/schemas/transformations/bqm.py +33 -0
- luna_sdk/schemas/transformations/matrix.py +12 -0
- luna_sdk/schemas/use_cases/__init__.py +54 -0
- luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
- luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
- luna_sdk/schemas/use_cases/base.py +5 -0
- luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
- luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
- luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
- luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
- luna_sdk/schemas/use_cases/exact_cover.py +50 -0
- luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
- luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
- luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
- luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
- luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
- luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
- luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
- luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
- luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
- luna_sdk/schemas/use_cases/linear_regression.py +59 -0
- luna_sdk/schemas/use_cases/lmwcs.py +80 -0
- luna_sdk/schemas/use_cases/longest_path.py +49 -0
- luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
- luna_sdk/schemas/use_cases/max2sat.py +51 -0
- luna_sdk/schemas/use_cases/max3sat.py +52 -0
- luna_sdk/schemas/use_cases/max_clique.py +59 -0
- luna_sdk/schemas/use_cases/max_cut.py +47 -0
- luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
- luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
- luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
- luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
- luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
- luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
- luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
- luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
- luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
- luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
- luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
- luna_sdk/schemas/use_cases/set_cover.py +55 -0
- luna_sdk/schemas/use_cases/set_packing.py +53 -0
- luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
- luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
- luna_sdk/schemas/use_cases/subset_sum.py +36 -0
- luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
- luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
- luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
- luna_sdk/schemas/use_cases/type_aliases.py +11 -0
- luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
- luna_sdk/utils/__init__.py +0 -0
- luna_sdk/utils/qpu_tokens.py +52 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from io import BufferedReader
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from dimod import BinaryQuadraticModel, ConstrainedQuadraticModel
|
|
6
|
+
|
|
7
|
+
from luna_sdk.interfaces.repository_i import IRepository
|
|
8
|
+
from luna_sdk.schemas.enums.optimization import InputType
|
|
9
|
+
from luna_sdk.schemas.enums.timeframe import TimeframeEnum
|
|
10
|
+
from luna_sdk.schemas.optimization import (
|
|
11
|
+
Optimization,
|
|
12
|
+
)
|
|
13
|
+
from luna_sdk.schemas.use_cases import UseCase
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class IOptimizationRepo(IRepository, ABC):
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def get(
|
|
19
|
+
self,
|
|
20
|
+
optimization_id: str,
|
|
21
|
+
) -> Optimization:
|
|
22
|
+
"""
|
|
23
|
+
Retrieve a optimization by id.
|
|
24
|
+
|
|
25
|
+
Parameters
|
|
26
|
+
----------
|
|
27
|
+
optimization_id: str
|
|
28
|
+
Id of the optimization to be retrieved.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
Optimization:
|
|
33
|
+
Optimization.
|
|
34
|
+
"""
|
|
35
|
+
raise NotImplementedError
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def get_all(
|
|
39
|
+
self,
|
|
40
|
+
timeframe: Optional[TimeframeEnum] = None,
|
|
41
|
+
input_type: Optional[InputType] = None,
|
|
42
|
+
limit: int = 50,
|
|
43
|
+
offset: int = 0,
|
|
44
|
+
) -> List[Optimization]:
|
|
45
|
+
"""
|
|
46
|
+
Retrieve a list of optimizations.
|
|
47
|
+
|
|
48
|
+
Parameters
|
|
49
|
+
----------
|
|
50
|
+
timeframe: Optional[TimeframeEnum]
|
|
51
|
+
Only return optimizations created within a specified timeframe.
|
|
52
|
+
Default None.
|
|
53
|
+
input_type: Optional[InputType]
|
|
54
|
+
Only return optimizations of a specified input type. Default None.
|
|
55
|
+
limit:
|
|
56
|
+
Limit the number of optimizations to be returned. Default value 50.
|
|
57
|
+
offset:
|
|
58
|
+
Offset the list of optimizations by this amount. Default value 0.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
List[Optimization]:
|
|
63
|
+
List of optimizations.
|
|
64
|
+
"""
|
|
65
|
+
raise NotImplementedError
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def create_from_qubo(
|
|
69
|
+
self,
|
|
70
|
+
name: str,
|
|
71
|
+
matrix: List[List[float]],
|
|
72
|
+
timeout: Optional[float] = 10.0,
|
|
73
|
+
) -> Optimization:
|
|
74
|
+
"""
|
|
75
|
+
Create an optimization from a QUBO matrix.
|
|
76
|
+
|
|
77
|
+
Parameters
|
|
78
|
+
----------
|
|
79
|
+
name: str
|
|
80
|
+
Name of the optimization to be created.
|
|
81
|
+
matrix: List[List[float]]
|
|
82
|
+
QUBO matrix.
|
|
83
|
+
timeout: Optional[float]
|
|
84
|
+
Default = 10.0. Timeout for the optimization. If set to None,
|
|
85
|
+
there won't be any timeout. Increase or disable the timeout if you face
|
|
86
|
+
issues uploading big QUBO matrices.
|
|
87
|
+
|
|
88
|
+
Returns
|
|
89
|
+
-------
|
|
90
|
+
Optimization:
|
|
91
|
+
Created optimization.
|
|
92
|
+
"""
|
|
93
|
+
raise NotImplementedError
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def create_from_use_case(
|
|
97
|
+
self,
|
|
98
|
+
name: str,
|
|
99
|
+
use_case: UseCase,
|
|
100
|
+
timeout: Optional[float] = 10.0,
|
|
101
|
+
) -> Optimization:
|
|
102
|
+
"""
|
|
103
|
+
Create an optimization from a use case.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
name: str
|
|
108
|
+
Name of the optimization to be created.
|
|
109
|
+
use_case: UseCase
|
|
110
|
+
Use case.
|
|
111
|
+
timeout: Optional[float]
|
|
112
|
+
Default = 10.0. Timeout for the optimization. If set to None,
|
|
113
|
+
there won't be any timeout. Increase or disable the timeout if you face
|
|
114
|
+
issues uploading big Problems.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
Optimization:
|
|
119
|
+
Created optimization.
|
|
120
|
+
"""
|
|
121
|
+
raise NotImplementedError
|
|
122
|
+
|
|
123
|
+
@abstractmethod
|
|
124
|
+
def create_from_bqm(
|
|
125
|
+
self,
|
|
126
|
+
name: str,
|
|
127
|
+
bqm: BinaryQuadraticModel,
|
|
128
|
+
timeout: Optional[float] = 10.0,
|
|
129
|
+
) -> Optimization:
|
|
130
|
+
"""
|
|
131
|
+
Create an optimization from BQM.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
name: str
|
|
136
|
+
Name of the optimization to be created.
|
|
137
|
+
bqm: BinaryQuadraticModel
|
|
138
|
+
QUBO in dimod BQM format.
|
|
139
|
+
timeout: Optional[float]
|
|
140
|
+
Default = 10.0. Timeout for the optimization. If set to None,
|
|
141
|
+
there won't be any timeout. Increase or disable the timeout if you face
|
|
142
|
+
issues uploading big Problems.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
Optimization:
|
|
147
|
+
Created optimization.
|
|
148
|
+
"""
|
|
149
|
+
raise NotImplementedError
|
|
150
|
+
|
|
151
|
+
@abstractmethod
|
|
152
|
+
def create_from_cqm(
|
|
153
|
+
self,
|
|
154
|
+
name: str,
|
|
155
|
+
cqm: ConstrainedQuadraticModel,
|
|
156
|
+
timeout: Optional[float] = 10.0,
|
|
157
|
+
) -> Optimization:
|
|
158
|
+
"""
|
|
159
|
+
Create an optimization from CQM.
|
|
160
|
+
|
|
161
|
+
Parameters
|
|
162
|
+
----------
|
|
163
|
+
name: str
|
|
164
|
+
Name of the optimization to be created.
|
|
165
|
+
cqm: ConstrainedQuadraticModel
|
|
166
|
+
in dimod CQM format.
|
|
167
|
+
timeout: Optional[float]
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
Optimization:
|
|
172
|
+
Created optimization.
|
|
173
|
+
"""
|
|
174
|
+
raise NotImplementedError
|
|
175
|
+
|
|
176
|
+
@abstractmethod
|
|
177
|
+
def create_from_lp_file(
|
|
178
|
+
self,
|
|
179
|
+
name: str,
|
|
180
|
+
lp_file: BufferedReader,
|
|
181
|
+
timeout: Optional[float] = 10.0,
|
|
182
|
+
) -> Optimization:
|
|
183
|
+
"""
|
|
184
|
+
Create an optimization from LP file.
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
name: str
|
|
189
|
+
Name of the optimization to be created.
|
|
190
|
+
lp_file: buffer reader.
|
|
191
|
+
timeout: Optional[float]
|
|
192
|
+
Default = 10.0. Timeout for the optimization. If set to None,
|
|
193
|
+
there won't be any timeout. Increase or disable the timeout if you face
|
|
194
|
+
issues uploading big Problems.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
Optimization:
|
|
199
|
+
Created optimization.
|
|
200
|
+
"""
|
|
201
|
+
raise NotImplementedError
|
|
202
|
+
|
|
203
|
+
@abstractmethod
|
|
204
|
+
def create_from_lp_string(
|
|
205
|
+
self,
|
|
206
|
+
name: str,
|
|
207
|
+
lp_string: str,
|
|
208
|
+
timeout: Optional[float] = 10.0,
|
|
209
|
+
) -> Optimization:
|
|
210
|
+
"""
|
|
211
|
+
Create an optimization from LP file.
|
|
212
|
+
|
|
213
|
+
Parameters
|
|
214
|
+
----------
|
|
215
|
+
name: str
|
|
216
|
+
Name of the optimization to be created.
|
|
217
|
+
lp_string: string.
|
|
218
|
+
timeout: Optional[float]
|
|
219
|
+
Default = 10.0. Timeout for the optimization. If set to None,
|
|
220
|
+
there won't be any timeout. Increase or disable the timeout if you face
|
|
221
|
+
issues uploading big Problems.
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
Optimization:
|
|
226
|
+
Created optimization.
|
|
227
|
+
"""
|
|
228
|
+
raise NotImplementedError
|
|
229
|
+
|
|
230
|
+
@abstractmethod
|
|
231
|
+
def rename(self, optimization_id: str, name: str) -> Optimization:
|
|
232
|
+
"""
|
|
233
|
+
Update the name of the optimization
|
|
234
|
+
|
|
235
|
+
Parameters
|
|
236
|
+
----------
|
|
237
|
+
optimization_id: str
|
|
238
|
+
Id of the optimization to be updated.
|
|
239
|
+
name: str
|
|
240
|
+
New name of the optimization
|
|
241
|
+
|
|
242
|
+
Returns
|
|
243
|
+
-------
|
|
244
|
+
Optimization:
|
|
245
|
+
Updated optimization.
|
|
246
|
+
"""
|
|
247
|
+
raise NotImplementedError
|
|
248
|
+
|
|
249
|
+
@abstractmethod
|
|
250
|
+
def delete(
|
|
251
|
+
self,
|
|
252
|
+
optimization_id: str,
|
|
253
|
+
) -> None:
|
|
254
|
+
"""
|
|
255
|
+
Delete an optimization by id.
|
|
256
|
+
|
|
257
|
+
Parameters
|
|
258
|
+
----------
|
|
259
|
+
optimization_id: str
|
|
260
|
+
Id of the optimization to be deleted.
|
|
261
|
+
"""
|
|
262
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Dict, List, NoReturn, Optional
|
|
3
|
+
|
|
4
|
+
from luna_sdk.interfaces.repository_i import IRepository
|
|
5
|
+
from luna_sdk.schemas import QpuTokenOut
|
|
6
|
+
from luna_sdk.schemas.enums.qpu_token_type import QpuTokenTypeEnum
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IQpuTokenRepo(IRepository, ABC):
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def create(
|
|
12
|
+
self,
|
|
13
|
+
name: str,
|
|
14
|
+
provider: str,
|
|
15
|
+
token: str,
|
|
16
|
+
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
17
|
+
encryption_key: Optional[str] = None,
|
|
18
|
+
) -> QpuTokenOut:
|
|
19
|
+
"""
|
|
20
|
+
Create organization QPU token
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
name: str
|
|
25
|
+
Name of the QPU token
|
|
26
|
+
provider: ProviderEnum
|
|
27
|
+
Name of provider
|
|
28
|
+
token: str
|
|
29
|
+
Token
|
|
30
|
+
token_type: QpuTokenTypeEnum
|
|
31
|
+
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
32
|
+
The default value is PERSONAL.
|
|
33
|
+
All users of an organization can use organization QPU tokens.
|
|
34
|
+
User QPU tokens can only be used by the user who created them.
|
|
35
|
+
encryption_key: Optional[str]
|
|
36
|
+
Encryption key to be used for encryption of QPU tokens.
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
QpuTokenOut
|
|
40
|
+
QpuToken instances.
|
|
41
|
+
"""
|
|
42
|
+
raise NotImplementedError
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def get_all(
|
|
46
|
+
self,
|
|
47
|
+
filter_provider: Optional[str] = None,
|
|
48
|
+
name: Optional[str] = None,
|
|
49
|
+
token_type: Optional[QpuTokenTypeEnum] = None,
|
|
50
|
+
) -> Dict[QpuTokenTypeEnum, List[QpuTokenOut]]:
|
|
51
|
+
"""
|
|
52
|
+
Retrieve a list of QPU tokens.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
filter_provider: Optional[str]
|
|
57
|
+
The provider for which qpu tokens should be retrieved
|
|
58
|
+
name: Optional[str]
|
|
59
|
+
Name of the QPU token that should be retrieved
|
|
60
|
+
token_type: Optional[QpuTokenTypeEnum]
|
|
61
|
+
If you want to retrieve only user or organization QPU tokens
|
|
62
|
+
otherwise all QPU tokens will be retrieved
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
Dict[QpuTokenTypeEnum, List[QpuTokenOut]]
|
|
66
|
+
List of QpuTokenOut instances.
|
|
67
|
+
"""
|
|
68
|
+
raise NotImplementedError
|
|
69
|
+
|
|
70
|
+
@abstractmethod
|
|
71
|
+
def get(
|
|
72
|
+
self,
|
|
73
|
+
name: str,
|
|
74
|
+
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
75
|
+
) -> QpuTokenOut:
|
|
76
|
+
"""
|
|
77
|
+
Retrieve user QPU token by id
|
|
78
|
+
|
|
79
|
+
Parameters
|
|
80
|
+
----------
|
|
81
|
+
name: str
|
|
82
|
+
Name of the QPU token that should be retrieved
|
|
83
|
+
|
|
84
|
+
token_type: QpuTokenTypeEnum
|
|
85
|
+
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
86
|
+
The default value is PERSONAL.
|
|
87
|
+
All users of an organization can use organization QPU tokens.
|
|
88
|
+
User QPU tokens can only be used by the user who created them.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
QpuTokenOut
|
|
93
|
+
QpuToken instance.
|
|
94
|
+
"""
|
|
95
|
+
raise NotImplementedError
|
|
96
|
+
|
|
97
|
+
@abstractmethod
|
|
98
|
+
def rename(
|
|
99
|
+
self,
|
|
100
|
+
name: str,
|
|
101
|
+
new_name: str,
|
|
102
|
+
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
103
|
+
) -> QpuTokenOut:
|
|
104
|
+
"""
|
|
105
|
+
Update organization QPU token by id
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
name: str
|
|
110
|
+
Current name of the QPU token that should be updated
|
|
111
|
+
new_name: str
|
|
112
|
+
The new name
|
|
113
|
+
|
|
114
|
+
token_type: QpuTokenTypeEnum
|
|
115
|
+
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
116
|
+
The default value is PERSONAL.
|
|
117
|
+
All users of an organization can use organization QPU tokens.
|
|
118
|
+
User QPU tokens can only be used by the user who created them.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
QpuTokenOut
|
|
124
|
+
QpuToken instance.
|
|
125
|
+
"""
|
|
126
|
+
raise NotImplementedError
|
|
127
|
+
|
|
128
|
+
@abstractmethod
|
|
129
|
+
def delete(
|
|
130
|
+
self,
|
|
131
|
+
name: str,
|
|
132
|
+
token_type: QpuTokenTypeEnum = QpuTokenTypeEnum.PERSONAL,
|
|
133
|
+
) -> None:
|
|
134
|
+
"""
|
|
135
|
+
Delete organization QPU token by id
|
|
136
|
+
|
|
137
|
+
Parameters
|
|
138
|
+
----------
|
|
139
|
+
name: str
|
|
140
|
+
Name of the QPU token that should be deleted
|
|
141
|
+
|
|
142
|
+
token_type: QpuTokenTypeEnum
|
|
143
|
+
There are two types of QPU tokens: PERSONAL and ORGANIZATION.
|
|
144
|
+
The default value is PERSONAL.
|
|
145
|
+
All users of an organization can use organization QPU tokens.
|
|
146
|
+
User QPU tokens can only be used by the user who created them.
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
"""
|
|
151
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from httpx import Client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IRepository(ABC):
|
|
6
|
+
_client: Client
|
|
7
|
+
|
|
8
|
+
def __init__(self, client: Client) -> None:
|
|
9
|
+
self._client = client
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def _endpoint(self) -> str:
|
|
14
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Dict, List, Optional, Union
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
from luna_sdk.interfaces.repository_i import IRepository
|
|
7
|
+
from luna_sdk.schemas.enums.timeframe import TimeframeEnum
|
|
8
|
+
from luna_sdk.schemas.qpu_token import TokenProvider
|
|
9
|
+
from luna_sdk.schemas.solution import (
|
|
10
|
+
Result,
|
|
11
|
+
Solution,
|
|
12
|
+
UseCaseRepresentation,
|
|
13
|
+
UseCaseResult,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ISolutionsRepo(IRepository, ABC):
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def get_all(
|
|
20
|
+
self,
|
|
21
|
+
timeframe: Optional[TimeframeEnum] = None,
|
|
22
|
+
limit: int = 50,
|
|
23
|
+
offset: int = 0,
|
|
24
|
+
optimization_id: Optional[str] = None,
|
|
25
|
+
) -> List[Solution]:
|
|
26
|
+
"""
|
|
27
|
+
Get list of available optimizations.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
timeframe: Optional[TimeframeEnum]
|
|
32
|
+
Only return Solutions created within a specified timeframe. Default None.
|
|
33
|
+
limit:
|
|
34
|
+
Limit the number of Optimizations to be returned. Default value 10.
|
|
35
|
+
offset:
|
|
36
|
+
Offset the list of solutions by this amount. Default value 0.
|
|
37
|
+
optimization_id: Optional[str]
|
|
38
|
+
Show solutions for only this optimization id. Default None.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
List[SolutionOut]
|
|
43
|
+
List of SolutionOut instances.
|
|
44
|
+
"""
|
|
45
|
+
raise NotImplementedError
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def get(self, solution_id: str) -> Solution:
|
|
49
|
+
"""
|
|
50
|
+
Retrieve one optimization by id.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
solution_id: str
|
|
55
|
+
Id of the solution that should be retrieved
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
Solution
|
|
60
|
+
Solution instance
|
|
61
|
+
"""
|
|
62
|
+
raise NotImplementedError
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def get_use_case_representation(self, solution_id: str) -> UseCaseRepresentation:
|
|
66
|
+
"""
|
|
67
|
+
Get the use-case-specific representation of a solution.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
solution_id: str
|
|
72
|
+
Id of the solution that should be retrieved
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
UseCaseRepresentation
|
|
77
|
+
The use-case-specific representation
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
@abstractmethod
|
|
81
|
+
def delete(self, solution_id: str) -> None:
|
|
82
|
+
"""
|
|
83
|
+
Delete one optimization by id.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
solution_id: str
|
|
88
|
+
Id of the optimization that should be deleted
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
"""
|
|
93
|
+
raise NotImplementedError
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def create(
|
|
97
|
+
self,
|
|
98
|
+
optimization_id: str,
|
|
99
|
+
solver_name: str,
|
|
100
|
+
provider: str,
|
|
101
|
+
qpu_tokens: Optional[TokenProvider] = None,
|
|
102
|
+
solver_parameters: Optional[Union[Dict, BaseModel]] = None,
|
|
103
|
+
encryption_key: Optional[str] = None,
|
|
104
|
+
name: Optional[str] = None,
|
|
105
|
+
) -> Solution:
|
|
106
|
+
"""
|
|
107
|
+
Create a solution for optimization
|
|
108
|
+
|
|
109
|
+
Parameters
|
|
110
|
+
----------
|
|
111
|
+
optimization_id: str
|
|
112
|
+
The id of the optimization for which solution should be created
|
|
113
|
+
solver_name: str
|
|
114
|
+
The name of the solver to use.
|
|
115
|
+
provider: str
|
|
116
|
+
The name of the provider to use.
|
|
117
|
+
qpu_tokens: Optional[TokenProvider]
|
|
118
|
+
The tokens to be used for the QPU.
|
|
119
|
+
solver_parameters: Optional[Union[Dict, BaseModel]]
|
|
120
|
+
Parameters to be passed to the solver.
|
|
121
|
+
encryption_key: Optional[str]
|
|
122
|
+
Encryption key to be used for encryption of QPU tokens.
|
|
123
|
+
name: Optional[str]
|
|
124
|
+
Default: None, The name of the solution to create.
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
-------
|
|
128
|
+
SolutionOut
|
|
129
|
+
Returns the location where the solution can be found once solving is complete.
|
|
130
|
+
"""
|
|
131
|
+
raise NotImplementedError
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def create_blocking(
|
|
135
|
+
self,
|
|
136
|
+
optimization_id: str,
|
|
137
|
+
solver_name: str,
|
|
138
|
+
provider: str,
|
|
139
|
+
qpu_tokens: Optional[TokenProvider] = None,
|
|
140
|
+
solver_parameters: Optional[Union[Dict, BaseModel]] = None,
|
|
141
|
+
sleep_time_max: float = 60.0,
|
|
142
|
+
sleep_time_increment: float = 5.0,
|
|
143
|
+
sleep_time_initial: float = 5.0,
|
|
144
|
+
encryption_key: Optional[str] = None,
|
|
145
|
+
name: Optional[str] = None,
|
|
146
|
+
) -> Solution:
|
|
147
|
+
"""
|
|
148
|
+
Create a solution for optimization. This method will block your code until the solution is ready.
|
|
149
|
+
Depending on the problem size, this can take a long time.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
optimization_id: str
|
|
154
|
+
The id of the optimization for which solution should be created
|
|
155
|
+
solver_name: str
|
|
156
|
+
The name of the solver to use.
|
|
157
|
+
provider: str
|
|
158
|
+
The name of the provider to use.
|
|
159
|
+
qpu_tokens: Optional[TokenProvider] = None
|
|
160
|
+
The tokens to be used for the QPU.
|
|
161
|
+
solver_parameters: Optional[Union[Dict, BaseModel]]
|
|
162
|
+
Parameters to be passed to the solver.
|
|
163
|
+
|
|
164
|
+
sleep_time_max: float
|
|
165
|
+
Maximum time to sleep between requests.
|
|
166
|
+
sleep_time_increment: float
|
|
167
|
+
Increment of sleep time between requests. Initial sleep time will be
|
|
168
|
+
sleep_time_initial: float
|
|
169
|
+
Initial sleep time.
|
|
170
|
+
encryption_key: Optional[str]
|
|
171
|
+
Encryption key to be used for encryption of QPU tokens.
|
|
172
|
+
name: Optional[str]
|
|
173
|
+
Default: None, The name of the solution to create.
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
SolutionOut
|
|
177
|
+
Returns the location where the solution can be found once solving is complete.
|
|
178
|
+
"""
|
|
179
|
+
raise NotImplementedError
|
|
180
|
+
|
|
181
|
+
@abstractmethod
|
|
182
|
+
def get_best_result(self, solution: Solution) -> Optional[Result]:
|
|
183
|
+
"""
|
|
184
|
+
Retrieves the best result from a solution.
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
solution : Solution
|
|
189
|
+
The solution received via a `solutions.get` or `solutions.get_all`.
|
|
190
|
+
|
|
191
|
+
Returns
|
|
192
|
+
-------
|
|
193
|
+
Result | None
|
|
194
|
+
The best result of the solution. If there are several best solutions with
|
|
195
|
+
the same objective value, return only the first. If the solution results are
|
|
196
|
+
not (yet) available, return `None`.
|
|
197
|
+
"""
|
|
198
|
+
raise NotImplementedError
|
|
199
|
+
|
|
200
|
+
@abstractmethod
|
|
201
|
+
def get_best_use_case_result(
|
|
202
|
+
self, use_case_representation: UseCaseRepresentation
|
|
203
|
+
) -> Optional[UseCaseResult]:
|
|
204
|
+
"""
|
|
205
|
+
Retrieves the best result from a solution's use case representation.
|
|
206
|
+
|
|
207
|
+
Parameters
|
|
208
|
+
----------
|
|
209
|
+
use_case_representation : UseCaseRepresentation
|
|
210
|
+
A solution's use case representation.
|
|
211
|
+
|
|
212
|
+
Returns
|
|
213
|
+
-------
|
|
214
|
+
UseCaseResult | None
|
|
215
|
+
The best result of the solution. If there are several best solutions with
|
|
216
|
+
the same objective value, return only the first. If the solution results are
|
|
217
|
+
not (yet) available or no the solution sense is `None`, return `None`.
|
|
218
|
+
"""
|
|
219
|
+
raise NotImplementedError
|
luna_sdk/py.typed
ADDED
|
File without changes
|