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.
- luna_quantum/__init__.py +139 -0
- luna_quantum/__init__.pyi +98 -0
- luna_quantum/_core.cp312-win_amd64.pyd +0 -0
- luna_quantum/_core.pyi +4286 -0
- luna_quantum/_utility.py +148 -0
- luna_quantum/_utility.pyi +20 -0
- luna_quantum/algorithms/__init__.py +1 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -0
- luna_quantum/backends/__init__.py +1 -0
- luna_quantum/client/__init__.py +0 -0
- luna_quantum/client/controllers/__init__.py +4 -0
- luna_quantum/client/controllers/luna_http_client.py +37 -0
- luna_quantum/client/controllers/luna_platform_client.py +256 -0
- luna_quantum/client/controllers/luna_q.py +67 -0
- luna_quantum/client/controllers/luna_solve.py +129 -0
- luna_quantum/client/error/__init__.py +0 -0
- luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
- luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
- luna_quantum/client/error/luna_error.py +2 -0
- luna_quantum/client/error/luna_server_error.py +20 -0
- luna_quantum/client/error/timeout_error.py +12 -0
- luna_quantum/client/error/transformation_error.py +18 -0
- luna_quantum/client/error/utils/__init__.py +0 -0
- luna_quantum/client/error/utils/http_error_utils.py +112 -0
- luna_quantum/client/interfaces/__init__.py +4 -0
- luna_quantum/client/interfaces/clients/__init__.py +25 -0
- luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
- luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
- luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
- luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
- luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
- luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
- luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
- luna_quantum/client/interfaces/services/__init__.py +0 -0
- luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
- luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
- luna_quantum/client/interfaces/services/service_i.py +56 -0
- luna_quantum/client/rest_client/__init__.py +15 -0
- luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
- luna_quantum/client/rest_client/info_rest_client.py +74 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
- luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
- luna_quantum/client/rest_client/users_rest_client.py +35 -0
- luna_quantum/client/schemas/__init__.py +26 -0
- luna_quantum/client/schemas/circuit.py +48 -0
- luna_quantum/client/schemas/create/__init__.py +15 -0
- luna_quantum/client/schemas/create/circuit.py +30 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +22 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
- luna_quantum/client/schemas/create/qubo.py +19 -0
- luna_quantum/client/schemas/create/solve_job_create.py +43 -0
- luna_quantum/client/schemas/enums/__init__.py +0 -0
- luna_quantum/client/schemas/enums/call_style.py +13 -0
- luna_quantum/client/schemas/enums/circuit.py +42 -0
- luna_quantum/client/schemas/enums/model_format.py +11 -0
- luna_quantum/client/schemas/enums/problem.py +50 -0
- luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
- luna_quantum/client/schemas/enums/sense.py +8 -0
- luna_quantum/client/schemas/enums/status.py +40 -0
- luna_quantum/client/schemas/enums/timeframe.py +11 -0
- luna_quantum/client/schemas/error_message.py +14 -0
- luna_quantum/client/schemas/model_metadata.py +35 -0
- luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
- luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +50 -0
- luna_quantum/client/schemas/solver_info.py +11 -0
- luna_quantum/client/schemas/user.py +11 -0
- luna_quantum/client/schemas/wrappers/__init__.py +5 -0
- luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
- luna_quantum/client/utils/__init__.py +0 -0
- luna_quantum/client/utils/qpu_token_utils.py +147 -0
- luna_quantum/config.py +11 -0
- luna_quantum/decorators.py +248 -0
- luna_quantum/errors.py +34 -0
- luna_quantum/errors.pyi +287 -0
- luna_quantum/exceptions/__init__.py +0 -0
- luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
- luna_quantum/exceptions/luna_quantum_call_type_error.py +9 -0
- luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
- luna_quantum/factories/__init__.py +4 -0
- luna_quantum/factories/luna_solve_client_factory.py +100 -0
- luna_quantum/factories/usecase_factory.py +489 -0
- luna_quantum/py.typed +0 -0
- luna_quantum/solve/__init__.py +13 -0
- luna_quantum/solve/default_token.py +304 -0
- luna_quantum/solve/domain/__init__.py +0 -0
- luna_quantum/solve/domain/abstract/__init__.py +4 -0
- luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +56 -0
- luna_quantum/solve/domain/solve_job.py +230 -0
- luna_quantum/solve/errors/__init__.py +0 -0
- luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
- luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
- luna_quantum/solve/errors/solve_base_error.py +5 -0
- luna_quantum/solve/errors/token_missing_error.py +11 -0
- luna_quantum/solve/interfaces/__init__.py +0 -0
- luna_quantum/solve/interfaces/algorithm_i.py +49 -0
- luna_quantum/solve/interfaces/backend_i.py +28 -0
- luna_quantum/solve/interfaces/usecases/__init__.py +59 -0
- luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
- luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
- luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
- luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_by_id_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
- luna_quantum/solve/parameters/__init__.py +0 -0
- luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
- luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
- luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
- luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
- luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
- luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +10 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/__init__.py +29 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/config.py +58 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/flexqaoa.py +188 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/optimizers.py +53 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/pipeline.py +164 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +112 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
- luna_quantum/solve/parameters/backends/__init__.py +27 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aqarios_gpu.py +17 -0
- luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
- luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
- luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
- luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
- luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
- luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
- luna_quantum/solve/parameters/backends/cudaq/__init__.py +5 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_base.py +16 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_cpu.py +30 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_gpu.py +32 -0
- luna_quantum/solve/parameters/backends/dwave.py +17 -0
- luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
- luna_quantum/solve/parameters/backends/fda.py +17 -0
- luna_quantum/solve/parameters/backends/ibm.py +138 -0
- luna_quantum/solve/parameters/backends/qctrl.py +103 -0
- luna_quantum/solve/parameters/backends/zib.py +17 -0
- luna_quantum/solve/parameters/constants.py +11 -0
- luna_quantum/solve/parameters/errors.py +30 -0
- luna_quantum/solve/parameters/mixins/__init__.py +0 -0
- luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
- luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
- luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
- luna_quantum/solve/use_cases/__init__.py +119 -0
- luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
- luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
- luna_quantum/solve/use_cases/base.py +7 -0
- luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
- luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
- luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
- luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
- luna_quantum/solve/use_cases/exact_cover.py +51 -0
- luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
- luna_quantum/solve/use_cases/graph_coloring.py +42 -0
- luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
- luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
- luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
- luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
- luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
- luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
- luna_quantum/solve/use_cases/linear_regression.py +60 -0
- luna_quantum/solve/use_cases/lmwcs.py +84 -0
- luna_quantum/solve/use_cases/longest_path.py +50 -0
- luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
- luna_quantum/solve/use_cases/max2sat.py +54 -0
- luna_quantum/solve/use_cases/max3sat.py +55 -0
- luna_quantum/solve/use_cases/max_clique.py +60 -0
- luna_quantum/solve/use_cases/max_cut.py +48 -0
- luna_quantum/solve/use_cases/max_independent_set.py +37 -0
- luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
- luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
- luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
- luna_quantum/solve/use_cases/number_partitioning.py +32 -0
- luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
- luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
- luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
- luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
- luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
- luna_quantum/solve/use_cases/sensor_placement.py +58 -0
- luna_quantum/solve/use_cases/set_cover.py +56 -0
- luna_quantum/solve/use_cases/set_packing.py +54 -0
- luna_quantum/solve/use_cases/set_partitioning.py +52 -0
- luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
- luna_quantum/solve/use_cases/subset_sum.py +37 -0
- luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
- luna_quantum/solve/use_cases/traffic_flow.py +35 -0
- luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
- luna_quantum/solve/use_cases/type_aliases.py +9 -0
- luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
- luna_quantum/solve/usecases/__init__.py +45 -0
- luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
- luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
- luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
- luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
- luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
- luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
- luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
- luna_quantum/solve/usecases/model_save_usecase.py +63 -0
- luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
- luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
- luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
- luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
- luna_quantum/solve/usecases/solve_job_get_by_id_usecase.py +44 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +105 -0
- luna_quantum/transformations.py +18 -0
- luna_quantum/transformations.pyi +371 -0
- luna_quantum/translator.py +23 -0
- luna_quantum/translator.pyi +869 -0
- luna_quantum/util/__init__.py +0 -0
- luna_quantum/util/active_waiting.py +79 -0
- luna_quantum/util/class_patcher.py +164 -0
- luna_quantum/util/debug_info.py +52 -0
- luna_quantum/util/log_utils.py +187 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +3 -0
- luna_quantum/utils.pyi +67 -0
- luna_quantum-1.1.0.dist-info/METADATA +36 -0
- luna_quantum-1.1.0.dist-info/RECORD +276 -0
- luna_quantum-1.1.0.dist-info/WHEEL +4 -0
- luna_quantum-1.1.0.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.1.0.dist-info/licenses/NOTICE +13 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SensorPlacement(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Sensor Placement.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Sensor Placement problem finds the optimal placement of pressure sensors on a
|
|
18
|
+
water distribution network, which is modelled by a graph where the edges have
|
|
19
|
+
weights assigned to them. A higher weight corresponds to a higher importance that a
|
|
20
|
+
sensor is placed on one of the nodes of the edge. Placing a sensor at a given node
|
|
21
|
+
has a cost attached to it. The total cost of placing the sensors should also be
|
|
22
|
+
minimized. As a constraint, there is a predetermined number of sensors s, which
|
|
23
|
+
should be placed on the network.
|
|
24
|
+
|
|
25
|
+
Links
|
|
26
|
+
-----
|
|
27
|
+
|
|
28
|
+
[Transformation](https://arxiv.org/pdf/2108.04075.pdf)
|
|
29
|
+
|
|
30
|
+
Attributes
|
|
31
|
+
----------
|
|
32
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
33
|
+
\n Problem graph for the sensor placement problem in form of nested
|
|
34
|
+
dictionaries.
|
|
35
|
+
\n (e.g. network with 3 nodes:
|
|
36
|
+
\n _{0: {2: {'weight': 1.0}}, 1: {2: {'weight': 6.0}},
|
|
37
|
+
2: {0: {'weight': 1.0}, 1: {'weight': 6.0}}}_
|
|
38
|
+
\n or _networkx.to_dict_of_dicts(networkx.Graph(...))_ )
|
|
39
|
+
|
|
40
|
+
### costs: List[float]
|
|
41
|
+
\n Cost of placing a sensor on specific node.
|
|
42
|
+
|
|
43
|
+
### s: int
|
|
44
|
+
\n Number of sensors.
|
|
45
|
+
|
|
46
|
+
### A: float
|
|
47
|
+
\n Lagrange multiplier in front of constraint in eq. (15).
|
|
48
|
+
|
|
49
|
+
### B: float
|
|
50
|
+
\n Lagrange multiplier in front of constraint in eq. (13).
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
name: Literal["SPL"] = "SPL"
|
|
54
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
55
|
+
costs: list[float]
|
|
56
|
+
s: int
|
|
57
|
+
A: float = 1
|
|
58
|
+
B: float = 30
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SetCover(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Set Cover.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Given a set _S_ and a list of subsets of _S_, so that each element of _S_ is
|
|
16
|
+
contained in at least one of the subsets, the Set Cover problem tries to find the
|
|
17
|
+
smallest possible family _C_ of these subsets so that all elements of _S_ are
|
|
18
|
+
contained in at least one subset of _C_.
|
|
19
|
+
|
|
20
|
+
Q-Bit Interpretation
|
|
21
|
+
--------------------
|
|
22
|
+
|
|
23
|
+
Let _n_ be the number of elements of _S_ and let _N_ be the number of subsets of
|
|
24
|
+
_S_. Then, the qubit vector _x_ will have length _N + N * n_. For _x[:N]_,
|
|
25
|
+
_x[i] = 1_, iff. subset _i_ is contained in the set cover. For _x[N:]_, _x[i] = 1_,
|
|
26
|
+
iff. the number of subsets which include element _a_ is _m > 0_ and
|
|
27
|
+
_i = N + a * N + m_.
|
|
28
|
+
|
|
29
|
+
Links
|
|
30
|
+
-----
|
|
31
|
+
|
|
32
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Set_cover_problem)
|
|
33
|
+
|
|
34
|
+
[Transformation](https://arxiv.org/pdf/1302.5843.pdf)
|
|
35
|
+
|
|
36
|
+
Attributes
|
|
37
|
+
----------
|
|
38
|
+
### subset_matrix: List[List[float]]
|
|
39
|
+
\n A matrix containing all subsets.
|
|
40
|
+
\n e.g. for the set _{1, 2, 3}_ and the subsets _{1, 2}_, _{2, 3}_, and _{3}_:
|
|
41
|
+
\n _[[1, 1, 0], [0, 1, 1], [0, 0, 1]]_
|
|
42
|
+
\n or:
|
|
43
|
+
\n _SetCover.gen_subsets_matrix([1, 2, 3], [[1, 2], [2, 3], [3]])_
|
|
44
|
+
|
|
45
|
+
### A: int
|
|
46
|
+
\n A positive constant enforcing that each element of _S_ is contained in at
|
|
47
|
+
least one subset.
|
|
48
|
+
|
|
49
|
+
### B: int
|
|
50
|
+
\n A constant (_0 < B < A) minimizing the number of subsets included.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
name: Literal["SC"] = "SC"
|
|
54
|
+
subset_matrix: list[list[int]]
|
|
55
|
+
A: int = 4
|
|
56
|
+
B: int = 2
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SetPacking(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Set Packing.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Given a set _S_ and a list of subsets of _S_, a packing is a family _C_ of these
|
|
16
|
+
subsets so that all sets in _C_ are pairwise disjoint. For a set _S_ and a list of
|
|
17
|
+
subsets of _S_, the Set Packing problem assigns a weight to each set and tries to
|
|
18
|
+
find a packing so that the sum of the weights of the used sets is maximized.
|
|
19
|
+
|
|
20
|
+
Note that, in contrast to the [transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
21
|
+
mentioned below, our QUBO formulation searches for _min x^t Q x_ instead of
|
|
22
|
+
_max x^t Q x_ and thus all signs are flipped.
|
|
23
|
+
|
|
24
|
+
Q-Bit Interpretation
|
|
25
|
+
--------------------
|
|
26
|
+
|
|
27
|
+
Subset _i_ is part of the packing iff. qubit _i_ is 1.
|
|
28
|
+
|
|
29
|
+
Links
|
|
30
|
+
-----
|
|
31
|
+
|
|
32
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Set_packing)
|
|
33
|
+
|
|
34
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
35
|
+
|
|
36
|
+
Attributes
|
|
37
|
+
----------
|
|
38
|
+
### subset_matrix: List[List[int]]
|
|
39
|
+
\n A matrix containing all subsets.
|
|
40
|
+
\n e.g. for the set _{1, 2, 3}_ and the subsets _{1, 2}_, _{2, 3}_, and _{3}_:
|
|
41
|
+
\n _[[1, 1, 0], [0, 1, 1], [0, 0, 1]]_
|
|
42
|
+
|
|
43
|
+
### weights: List[int]
|
|
44
|
+
\n An array of length n_subsets which assigns a weight to each subset.
|
|
45
|
+
|
|
46
|
+
### P: int
|
|
47
|
+
\n Positive, scalar penalty value to penalize subsets that are not disjoint.
|
|
48
|
+
\n Default: _6_
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
name: Literal["SP"] = "SP"
|
|
52
|
+
subset_matrix: list[list[int]]
|
|
53
|
+
weights: list[float]
|
|
54
|
+
P: int = 6
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SetPartitioning(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Set Partitioning.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Set Partitioning problem partitions a set of items into a selection of possible
|
|
16
|
+
subsets so that each item of the set occurs in one and only one subset and the cost
|
|
17
|
+
of the chosen subsets is minimized.
|
|
18
|
+
|
|
19
|
+
Q-Bit Interpretation
|
|
20
|
+
--------------------
|
|
21
|
+
|
|
22
|
+
Subset _i_ is part of the partitioning iff. qubit _i_ is 1.
|
|
23
|
+
|
|
24
|
+
Links
|
|
25
|
+
-----
|
|
26
|
+
|
|
27
|
+
[Description and Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
28
|
+
|
|
29
|
+
Attributes
|
|
30
|
+
----------
|
|
31
|
+
### set_: List[int]
|
|
32
|
+
\n The set of items which has to be partitioned.
|
|
33
|
+
|
|
34
|
+
### subsets: List[List[int]]
|
|
35
|
+
\n The possible subsets of set_.
|
|
36
|
+
\n e.g. for _set=[1, 2, 3]_ and the possible subsets _{1, 2}_ and _{3}_ one
|
|
37
|
+
has to specify _subsets=[[1, 2], [3]]_.
|
|
38
|
+
|
|
39
|
+
### costs: List[int]
|
|
40
|
+
\n The cost of each possible subset. Has to be of the same length as _subsets_.
|
|
41
|
+
|
|
42
|
+
### P: int
|
|
43
|
+
\n Positive, scalar penalty value to penalize items that occur in more than one
|
|
44
|
+
subset.
|
|
45
|
+
\n Default: _10_
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["SPP"] = "SPP"
|
|
49
|
+
set_: list[int]
|
|
50
|
+
subsets: list[list[int]]
|
|
51
|
+
costs: list[int]
|
|
52
|
+
P: int = 10
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
from luna_quantum.solve.use_cases.type_aliases import NestedDictIntGraph
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SubGraphIsomorphism(UseCase):
|
|
10
|
+
r"""
|
|
11
|
+
# Subgraph Isomorphism.
|
|
12
|
+
|
|
13
|
+
Description
|
|
14
|
+
-----------
|
|
15
|
+
|
|
16
|
+
The Subgraph Isomorphism problem tries to find out whether, for two graphs _G1_ and
|
|
17
|
+
_G2_, _G2_ contains a subgraph _G3_ that is isomorphic to _G1_, i.e. there exists a
|
|
18
|
+
bijective, edge-invariant vertex mapping from _G1_ to _G3_. It returns the best such
|
|
19
|
+
mapping it is able to find.
|
|
20
|
+
|
|
21
|
+
Links
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Subgraph_isomorphism_problem)
|
|
25
|
+
|
|
26
|
+
[Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf?sequence=1)
|
|
27
|
+
|
|
28
|
+
Attributes
|
|
29
|
+
----------
|
|
30
|
+
### graph1: Dict[int, Dict[int, Dict[str, float]]]
|
|
31
|
+
\n The graph (in form of nested dictionaries) for which to check whether it is
|
|
32
|
+
isomorphic to a subgraph of graph2.
|
|
33
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
34
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
35
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
36
|
+
|
|
37
|
+
### graph2: Dict[int, Dict[int, Dict[str, float]]]
|
|
38
|
+
\n The graph (in form of nested dictionaries) for which to check whether it
|
|
39
|
+
contains a subgraph that is isomorphic to graph1.
|
|
40
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
41
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
42
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
43
|
+
|
|
44
|
+
### a: float = 1
|
|
45
|
+
\n A penalty value enforcing the bijectivity of the isomorphism.
|
|
46
|
+
|
|
47
|
+
### b: float = 2
|
|
48
|
+
\n A penalty value (b > a) enforcing the edge-invariance of the isomorphism.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
name: Literal["SGI"] = "SGI"
|
|
52
|
+
graph1: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
|
|
53
|
+
graph2: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
|
|
54
|
+
a: float = 1
|
|
55
|
+
b: float = 2
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SubsetSum(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Subset Sum.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Subset Sum problem finds a subset of numbers from a given set of integers where
|
|
16
|
+
the total sum over the subset is equal or maximally close to a target value t.
|
|
17
|
+
Example: Set _{5, 8, 4, 6}_ and Target _9_ returns the Subset _{5, 4}_
|
|
18
|
+
|
|
19
|
+
Links
|
|
20
|
+
-----
|
|
21
|
+
|
|
22
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Subset_sum_problem)
|
|
23
|
+
|
|
24
|
+
[Transformation](https://arxiv.org/pdf/1911.08043.pdf) (section 3.2.3)
|
|
25
|
+
|
|
26
|
+
Attributes
|
|
27
|
+
----------
|
|
28
|
+
### numbers: List[int]
|
|
29
|
+
\n Set of integers from which the subset is chosen.
|
|
30
|
+
|
|
31
|
+
### t: int
|
|
32
|
+
\n Target value for sum over all numbers in subset.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
name: Literal["SS"] = "SS"
|
|
36
|
+
numbers: list[int]
|
|
37
|
+
t: int
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SupportVectorMachine(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Support Vector Machine.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
In machine learning, support vector machines are supervised learning models that
|
|
16
|
+
perform linear classification in such a way that the seperating hyperplane is as far
|
|
17
|
+
away from each data point as possible.
|
|
18
|
+
|
|
19
|
+
Note that, in this implementation, the model always assumes the separating
|
|
20
|
+
hyperplane to be unbiased, i.e. it goes through the origin.
|
|
21
|
+
|
|
22
|
+
Q-Bit Interpretation
|
|
23
|
+
--------------------
|
|
24
|
+
|
|
25
|
+
For interpretation, the qubit vector has to be cut into N sublists of length K
|
|
26
|
+
(specified below). The sum of each of the products of each of these sublists and the
|
|
27
|
+
precision vector gives a lagrangian multiplier for each data point.
|
|
28
|
+
|
|
29
|
+
Links
|
|
30
|
+
-----
|
|
31
|
+
|
|
32
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Support-vector_machine)
|
|
33
|
+
|
|
34
|
+
[Transformation](https://doi.org/10.1038/s41598-021-89461-4)
|
|
35
|
+
|
|
36
|
+
Attributes
|
|
37
|
+
----------
|
|
38
|
+
### X: List[List[float]]
|
|
39
|
+
\n Training data set in form of a nested list.
|
|
40
|
+
\n All inner lists have to be of the same length.
|
|
41
|
+
\n (e.g. 3 data points with 2 features:
|
|
42
|
+
\n _[[1.1, 4.23], [0.1, -2.4], [-2.3, 1.11]]_
|
|
43
|
+
|
|
44
|
+
### Y: List[int]
|
|
45
|
+
\n Classification labels of the training data set.
|
|
46
|
+
\n e.g. for 3 data points:
|
|
47
|
+
\n _[-1, 1, 1]_
|
|
48
|
+
|
|
49
|
+
### K: int
|
|
50
|
+
\n Length of the precision vector.
|
|
51
|
+
\n As the problem outputs are supposed to be real values but the qubo only
|
|
52
|
+
gives a binary vector, we need a precision vector, consisting of positive powers
|
|
53
|
+
of 2, to simulate real values. This parameter determines the length of this
|
|
54
|
+
vector.
|
|
55
|
+
\n (e.g. for K = 5, the precision vector is _[0.25, 0.5, 1, 2, 4]_)
|
|
56
|
+
\n This parameter also determines the size of the qubo matrix together with the
|
|
57
|
+
number of data points _N_:
|
|
58
|
+
\n _size = N * K_
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
name: Literal["SVM"] = "SVM"
|
|
62
|
+
X: list[list[float]]
|
|
63
|
+
Y: list[int]
|
|
64
|
+
K: int = 5
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TrafficFlow(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Traffic Flow Optimization.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Traffic Flow Optimization problem tries to minimize the total time for a given
|
|
16
|
+
set of cars to travel between their individual sources and destinations. This is
|
|
17
|
+
achieved by minimizing the number of overlapping segments between assigned routes
|
|
18
|
+
for each car.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Description and Transformation](https://www.frontiersin.org/articles/10.3389/fict.2017.00029/full)
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
### car_routes: List[List[List[int]]]
|
|
28
|
+
\n The route segments of each possible route for each car.
|
|
29
|
+
\n (e.g. for two cars, where car 1 can take either route 0, 1, 2 or route 0, 3,
|
|
30
|
+
4 and car 2 can take either route 3, 0, 5 or route 6, 7, 5:
|
|
31
|
+
\n _[[[0, 1, 2], [0, 3, 4]], [[3, 0, 5], [6, 7, 5]]]_
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
name: Literal["TFO"] = "TFO"
|
|
35
|
+
car_routes: list[list[list[int]]]
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TravellingSalesmanProblem(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Travelling Salesman.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Travelling Salesman problem, either for a directed or undirected graph, asks the
|
|
18
|
+
following: given a graph, where the edges are labeled with the distances between the
|
|
19
|
+
corresponding nodes, what is the shortest possible route that visits each node
|
|
20
|
+
exactly once and returns to the origin node?
|
|
21
|
+
|
|
22
|
+
Links
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Travelling_salesman_problem)
|
|
26
|
+
|
|
27
|
+
[Transformation](https://arxiv.org/pdf/1302.5843.pdf)
|
|
28
|
+
|
|
29
|
+
Attributes
|
|
30
|
+
----------
|
|
31
|
+
graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
32
|
+
\n Problem graph for the travelling salesman problem in form of nested
|
|
33
|
+
dictionaries.
|
|
34
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
35
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
36
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
37
|
+
|
|
38
|
+
A: Optional[float]
|
|
39
|
+
\n Positive penalty value which enforces that each node is visited exactly once.
|
|
40
|
+
\n if _None_, will be calculated with the equation: _A = B * _max_weight_ + 1_
|
|
41
|
+
\n Default: _None_
|
|
42
|
+
|
|
43
|
+
B: Optional[float]
|
|
44
|
+
\n Positive penalty value (_B * _max_weight_) < A_) which helps find the
|
|
45
|
+
shortest route.
|
|
46
|
+
\n Default: _1.0_
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
name: Literal["TSP"] = "TSP"
|
|
50
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
51
|
+
directed: bool | None = False
|
|
52
|
+
B: float | None = 1.0
|
|
53
|
+
A: float | None = None
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class WeightedMaxCut(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Weighted Maximum Cut.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Weighted Maximum Cut problem tries to find a cut that maximizes the weight of
|
|
16
|
+
intersecting edges in an undirected weighted graph.
|
|
17
|
+
|
|
18
|
+
Links
|
|
19
|
+
-----
|
|
20
|
+
|
|
21
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Maximum_cut)
|
|
22
|
+
|
|
23
|
+
[Transformation](https://arxiv.org/pdf/2009.05008.pdf)
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
28
|
+
\n Problem graph for the weighted maximum cut problem in form of nested
|
|
29
|
+
dictionaries.
|
|
30
|
+
\n Every edge has to have an assigned weight.
|
|
31
|
+
\n (e.g. fully connected graph with 3 nodes and edge weights:
|
|
32
|
+
\n _{0: {1: {"weight": 1}, 2: {"weight": 1}}, 1: {0: {"weight": 1},
|
|
33
|
+
2: {"weight": 1}}, 2: {0: {"weight": 1}, 1: {"weight": 1}}}_ )
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
name: Literal["WMC"] = "WMC"
|
|
37
|
+
graph: dict[int, dict[int, dict[str, float]]]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from luna_quantum.solve.usecases.model_delete_usecase import ModelDeleteUseCase
|
|
2
|
+
from luna_quantum.solve.usecases.model_fetch_metadata_usecase import (
|
|
3
|
+
ModelFetchMetadataUseCase,
|
|
4
|
+
)
|
|
5
|
+
from luna_quantum.solve.usecases.model_get_solution_usecase import (
|
|
6
|
+
ModelGetSolutionUseCase,
|
|
7
|
+
)
|
|
8
|
+
from luna_quantum.solve.usecases.model_get_solve_jobs_usecase import (
|
|
9
|
+
ModelGetSolveJobsUseCase,
|
|
10
|
+
)
|
|
11
|
+
from luna_quantum.solve.usecases.model_load_by_id_usecase import (
|
|
12
|
+
ModelLoadByIdUseCase,
|
|
13
|
+
)
|
|
14
|
+
from luna_quantum.solve.usecases.model_load_by_metadata_usecase import (
|
|
15
|
+
ModelLoadByMetadataUseCase,
|
|
16
|
+
)
|
|
17
|
+
from luna_quantum.solve.usecases.model_load_metadata_by_hash_usecase import (
|
|
18
|
+
ModelLoadMetadataByHashUseCase,
|
|
19
|
+
)
|
|
20
|
+
from luna_quantum.solve.usecases.model_save_usecase import ModelSaveUseCase
|
|
21
|
+
from luna_quantum.solve.usecases.solve_job_cancel_usecase import SolveJobCancelUseCase
|
|
22
|
+
from luna_quantum.solve.usecases.solve_job_create_usecase import SolveJobCreateUseCase
|
|
23
|
+
from luna_quantum.solve.usecases.solve_job_delete_usecase import SolveJobDeleteUseCase
|
|
24
|
+
from luna_quantum.solve.usecases.solve_job_fetch_updates_usecase import (
|
|
25
|
+
SolveJobFetchUpdatesUseCase,
|
|
26
|
+
)
|
|
27
|
+
from luna_quantum.solve.usecases.solve_job_get_result_usecase import (
|
|
28
|
+
SolveJobGetResultUseCase,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"ModelDeleteUseCase",
|
|
33
|
+
"ModelFetchMetadataUseCase",
|
|
34
|
+
"ModelGetSolutionUseCase",
|
|
35
|
+
"ModelGetSolveJobsUseCase",
|
|
36
|
+
"ModelLoadByIdUseCase",
|
|
37
|
+
"ModelLoadByMetadataUseCase",
|
|
38
|
+
"ModelLoadMetadataByHashUseCase",
|
|
39
|
+
"ModelSaveUseCase",
|
|
40
|
+
"SolveJobCancelUseCase",
|
|
41
|
+
"SolveJobCreateUseCase",
|
|
42
|
+
"SolveJobDeleteUseCase",
|
|
43
|
+
"SolveJobFetchUpdatesUseCase",
|
|
44
|
+
"SolveJobGetResultUseCase",
|
|
45
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from luna_quantum.aqm_overwrites import Model
|
|
2
|
+
from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
|
|
3
|
+
from luna_quantum.solve.interfaces.usecases.model_delete_usecase_i import (
|
|
4
|
+
IModelDeleteUseCase,
|
|
5
|
+
)
|
|
6
|
+
from luna_quantum.util.log_utils import progress
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ModelDeleteUseCase(IModelDeleteUseCase):
|
|
10
|
+
"""
|
|
11
|
+
Handle the deletion of models.
|
|
12
|
+
|
|
13
|
+
This class facilitates the execution of the model delete method
|
|
14
|
+
for a given Model.
|
|
15
|
+
|
|
16
|
+
Attributes
|
|
17
|
+
----------
|
|
18
|
+
client : ILunaSolve
|
|
19
|
+
The client instance used for invoking the model delete method.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
client: ILunaSolve
|
|
23
|
+
|
|
24
|
+
def __init__(self, client: ILunaSolve) -> None:
|
|
25
|
+
self.client = client
|
|
26
|
+
|
|
27
|
+
@progress(total=None, desc="Deleting model...")
|
|
28
|
+
def __call__(self, model: Model) -> None:
|
|
29
|
+
"""
|
|
30
|
+
Delete the given Model from the client.
|
|
31
|
+
|
|
32
|
+
If the Model does not have metadata, this method does nothing. It is assumed
|
|
33
|
+
that the model was not stored in the client.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
model : Model
|
|
38
|
+
The Model instance for which the model delete method is called.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
None
|
|
43
|
+
This method does not return a value.
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
if model.metadata is None:
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
self.client.model.delete(model_id=model.metadata.id)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from luna_quantum.aqm_overwrites import Model
|
|
2
|
+
from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
|
|
3
|
+
from luna_quantum.solve.domain.model_metadata import ModelMetadata
|
|
4
|
+
from luna_quantum.solve.interfaces.usecases.model_fetch_metadata_usecase_i import (
|
|
5
|
+
IModelFetchMetadataUseCase,
|
|
6
|
+
)
|
|
7
|
+
from luna_quantum.util.log_utils import progress
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ModelFetchMetadataUseCase(IModelFetchMetadataUseCase):
|
|
11
|
+
"""Use case for fetching metadata of an AQ model.
|
|
12
|
+
|
|
13
|
+
The `ModelFetchMetadataUseCase` works with a given client interface to
|
|
14
|
+
retrieve metadata for a specified AQ model.
|
|
15
|
+
|
|
16
|
+
Attributes
|
|
17
|
+
----------
|
|
18
|
+
client : ILunaSolve
|
|
19
|
+
Client used to fetch the metadata for an AQ model.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
client: ILunaSolve
|
|
23
|
+
|
|
24
|
+
def __init__(self, client: ILunaSolve) -> None:
|
|
25
|
+
self.client = client
|
|
26
|
+
|
|
27
|
+
@progress(total=None, desc="Fetching model...")
|
|
28
|
+
def __call__(self, model: Model) -> ModelMetadata:
|
|
29
|
+
"""
|
|
30
|
+
Fetch the metadata of the given Model.
|
|
31
|
+
|
|
32
|
+
Load the metadata associated with the given Model instance from the client.
|
|
33
|
+
The metadata is validated before returning it. The metadata is not written to
|
|
34
|
+
the Model instance.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
model : Model
|
|
39
|
+
The Model instance to be associated with metadata.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
ModelMetadata
|
|
44
|
+
The metadata associated with the provided Model.
|
|
45
|
+
"""
|
|
46
|
+
metadata_schema = self.client.model.get_metadata_by_hash(
|
|
47
|
+
model_hash=model.__hash__()
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return ModelMetadata.model_validate(metadata_schema.model_dump())
|