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,60 @@
|
|
|
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 MaxClique(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Maximum Clique.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Maximum Clique problem describes the task of finding the largest sized clique in
|
|
18
|
+
a given graph. A clique is a set of nodes in a graph, where every node has an edge
|
|
19
|
+
to every other node in the clique. A k-clique denotes a clique with exactly k nodes.
|
|
20
|
+
The maximum clique of a graph is the clique with the highest possible k value.
|
|
21
|
+
|
|
22
|
+
There is a closely related problem, the decisional clique problem, which describes
|
|
23
|
+
the challenge of determining whether a clique of at least size k exists in the given
|
|
24
|
+
graph.
|
|
25
|
+
|
|
26
|
+
Math
|
|
27
|
+
----
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Links
|
|
33
|
+
-----
|
|
34
|
+
|
|
35
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Clique_problem#Finding_a_single_maximal_clique)
|
|
36
|
+
|
|
37
|
+
[Transformation](https://arxiv.org/pdf/1801.08649.pdf)
|
|
38
|
+
|
|
39
|
+
Attributes
|
|
40
|
+
----------
|
|
41
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
42
|
+
\n Problem graph for the maximum clique problem in form of nested dictionaries.
|
|
43
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
44
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
45
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
46
|
+
|
|
47
|
+
### hard_constraints: Dict
|
|
48
|
+
\n Hard constraints that must be fulfilled by any valid instance. They are
|
|
49
|
+
defined in _aqcore.transformator.specifications.graph_specifications_.
|
|
50
|
+
|
|
51
|
+
### soft_constraints: Optional[Dict]
|
|
52
|
+
\n Desirable traits that instances should fulfill.
|
|
53
|
+
|
|
54
|
+
### check_soft_constraints: bool
|
|
55
|
+
\n Defines whether soft constraints should also be fulfilled. Default is
|
|
56
|
+
_False_.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
name: Literal["MCQ"] = "MCQ"
|
|
60
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
@@ -0,0 +1,48 @@
|
|
|
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 MaxCut(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Maximum Cut.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Maximum Cut problem tries to find a cut that maximizes the number of
|
|
18
|
+
intersecting edges in an undirected graph.
|
|
19
|
+
|
|
20
|
+
Q-Bit Interpretation
|
|
21
|
+
--------------------
|
|
22
|
+
A cut defines two sets of nodes, 0 and 1.
|
|
23
|
+
The qubits x = (x_0, x_1, ..., x_n) can be interpreted like this:
|
|
24
|
+
x_i = 0 iff. node i belongs to set 0 and x_i = 1 iff. it belongs to set 1.
|
|
25
|
+
|
|
26
|
+
Math
|
|
27
|
+
----
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
Links
|
|
32
|
+
-----
|
|
33
|
+
|
|
34
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Maximum_cut)
|
|
35
|
+
|
|
36
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
37
|
+
|
|
38
|
+
Attributes
|
|
39
|
+
----------
|
|
40
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
41
|
+
\n Problem graph for the maximum cut problem in form of nested dictionaries.
|
|
42
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
43
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
44
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
name: Literal["MC"] = "MC"
|
|
48
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
@@ -0,0 +1,37 @@
|
|
|
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 MaxIndependentSet(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Maximum Independent Set.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
An independent set of a graph _G_ is a set of vertices of _G_, where every two
|
|
18
|
+
vertices are not connected by an edge in _G_. The Maximum Independent Set problem
|
|
19
|
+
tries to find the largest independent set of a graph.
|
|
20
|
+
|
|
21
|
+
Links
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
[Description and Transformation](https://arxiv.org/pdf/1801.08653.pdf)
|
|
25
|
+
|
|
26
|
+
Attributes
|
|
27
|
+
----------
|
|
28
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
29
|
+
\n Problem graph for the maximum independent set problem in form of nested
|
|
30
|
+
dictionaries.
|
|
31
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
32
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
33
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
name: Literal["MIS"] = "MIS"
|
|
37
|
+
graph: dict[int, dict[int, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
@@ -0,0 +1,54 @@
|
|
|
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 MinimalMaximalMatching(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Minimal Maximal Matching.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
For a graph _G = (V, E)_, the Minimal Maximal Matching problem tries to find a
|
|
18
|
+
"coloring" _C ⊆ E_ with the following three constraints:
|
|
19
|
+
\n 1. For each edge in _C_, the incident vertices shall be colored and the union of
|
|
20
|
+
all these vertices shall be called _D_.
|
|
21
|
+
\n 2. No two edges in _C_ share a vertex.
|
|
22
|
+
\n 3. If _u, v ∈ D_, then _(uv) ∉ E_.\n
|
|
23
|
+
|
|
24
|
+
Links
|
|
25
|
+
-----
|
|
26
|
+
|
|
27
|
+
[Description and 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 minimal maximal matching 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: int
|
|
39
|
+
\n A positive constant enforcing that no vertex has two colored edges.
|
|
40
|
+
|
|
41
|
+
### B: int
|
|
42
|
+
\n A constant to penalize when an edge is uncolored although it would not
|
|
43
|
+
violate the coloring condition. For _d_ being the maximal degree in the graph,
|
|
44
|
+
choose _A > (d - 2)B_.
|
|
45
|
+
|
|
46
|
+
### C: int
|
|
47
|
+
\n A constant (C < B) to minimize the number of colored edges.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
name: Literal["MMM"] = "MMM"
|
|
51
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
52
|
+
A: int = 10
|
|
53
|
+
B: int = 2
|
|
54
|
+
C: int = 1
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from luna_quantum.solve.use_cases.type_aliases import NestedDictGraph
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MinimalSpanningTree(UseCase):
|
|
14
|
+
r"""
|
|
15
|
+
# Minimal Spanning Tree with maximal degree constraint.
|
|
16
|
+
|
|
17
|
+
Description
|
|
18
|
+
-----------
|
|
19
|
+
|
|
20
|
+
The Minimal Spanning Tree problem tries to find a spanning tree over all nodes in a
|
|
21
|
+
given input graph such that the cost of the covered edges (the sum of the weights
|
|
22
|
+
inside the tree) is minimal. The addition maximal degree constraint, i.e. limiting
|
|
23
|
+
the degree of the tree at each node to a maximum value, makes this problem NP-hard.
|
|
24
|
+
|
|
25
|
+
Convention on depth index of vertex and edge:
|
|
26
|
+
Zero index is vertex root and all the edges leaving from root, etc.
|
|
27
|
+
That means there are N/2 possible depths for edges and N/2 + 1 possible depths for
|
|
28
|
+
vertices.
|
|
29
|
+
|
|
30
|
+
Q-Bit Interpretation
|
|
31
|
+
--------------------
|
|
32
|
+
|
|
33
|
+
Assume we have a graph with _m_ nodes, _n_ edges, a max degree of _k_, and the qubit
|
|
34
|
+
vector _q_.
|
|
35
|
+
Then, for _i = 0, ..., n-1_, _q[i] = 1_ iff. edge _i_ is included in the tree.
|
|
36
|
+
Variables _n, ..., n + ⌈ m / 2 ⌉_ keep track of the depth of a node in the tree.
|
|
37
|
+
Now, let _a := n + ⌈ m / 2 ⌉_. Variables _a, ..., a + 2 * n_ tell for each edge in
|
|
38
|
+
the graph which vertex is closer to the root of the tree.
|
|
39
|
+
Finally, with _b := a * 2 * n_, the variables
|
|
40
|
+
_b, ..., b + m * ⌊ log2(maxDegree) + 1 ⌋_ count the degree of a node in the tree.
|
|
41
|
+
|
|
42
|
+
Links
|
|
43
|
+
-----
|
|
44
|
+
|
|
45
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Degree-constrained_spanning_tree),
|
|
46
|
+
[Without degree constraint](https://en.wikipedia.org/wiki/Minimum_spanning_tree)
|
|
47
|
+
|
|
48
|
+
[Transformation](https://arxiv.org/abs/1302.5843)
|
|
49
|
+
|
|
50
|
+
Attributes
|
|
51
|
+
----------
|
|
52
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]
|
|
53
|
+
\n Problem graph for the minimal spanning tree problem in form of nested
|
|
54
|
+
dictionaries. Each vertex needs to be weighted.
|
|
55
|
+
\n (e.g. Wikipedia example
|
|
56
|
+
\n _{
|
|
57
|
+
0: {1: {"weight": 1}, 3: {"weight": 4}, 4: {"weight": 3}},
|
|
58
|
+
1: {3: {"weight": 4}, 4: {"weight": 2}},
|
|
59
|
+
2: {4: {"weight": 4}, 5: {"weight": 5}},
|
|
60
|
+
3: {4: {"weight": 4}},
|
|
61
|
+
4: {5: {"weight": 7}}
|
|
62
|
+
}_ )
|
|
63
|
+
|
|
64
|
+
### max_degree : int
|
|
65
|
+
\n The maximum degree at one joint of the tree. (e.g. 2 is a special case of the
|
|
66
|
+
travelling salesman problem).
|
|
67
|
+
|
|
68
|
+
### A : Optional[float] = None.
|
|
69
|
+
\n The penalty factor for constraints. Can be left _None_ to be estimated from
|
|
70
|
+
the problem graph via the papers suggestion.
|
|
71
|
+
\n Default: _None_
|
|
72
|
+
|
|
73
|
+
### B : Optional[float] = 1.
|
|
74
|
+
\n The optimization penalty factor.
|
|
75
|
+
\n Deafult: _1_
|
|
76
|
+
|
|
77
|
+
### ba_ratio : Optional[float] = 0.1
|
|
78
|
+
\n A factor that increases or decreases the ratio between constraint and
|
|
79
|
+
model penalty factors in the automatic estimation. If constraints are
|
|
80
|
+
violated, this ratio needs to be decreased as the _A_ penalty needs to be
|
|
81
|
+
increased. _0.1_ is a good starting point.
|
|
82
|
+
\n Default: _0.1_
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
name: Literal["MST"] = "MST"
|
|
86
|
+
graph: NestedDictGraph = Field(name="graph") # type: ignore[call-overload]
|
|
87
|
+
max_degree: int
|
|
88
|
+
A: float | None = None
|
|
89
|
+
B: float | None = 1.0
|
|
90
|
+
ba_ratio: float | None = 0.1
|
|
@@ -0,0 +1,45 @@
|
|
|
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 MinimumVertexCover(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Minimum Vertex Cover.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
A vertex cover of an undirected graph is a set of vertices that includes at least
|
|
18
|
+
one endpoint of every edge of this graph. The Minimum Vertex Cover problem tries to
|
|
19
|
+
find the smallest vertex cover in a given graph. The smallest vertex cover is the
|
|
20
|
+
one that contains the least amount of nodes.
|
|
21
|
+
|
|
22
|
+
Links
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Vertex_cover)
|
|
26
|
+
|
|
27
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
28
|
+
|
|
29
|
+
Attributes
|
|
30
|
+
----------
|
|
31
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
32
|
+
\n Problem graph for the minimum vertex cover 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
|
+
### P: int
|
|
39
|
+
\n Positive, scalar penalty value to penalize edges that are not covered.
|
|
40
|
+
\n Default: _8_
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
name: Literal["MVC"] = "MVC"
|
|
44
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
45
|
+
P: int = 8
|
|
@@ -0,0 +1,32 @@
|
|
|
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 NumberPartitioning(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Number Partitioning.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Number Partitioning problem partitions a set of numbers into two subsets such
|
|
16
|
+
that the difference of the subset sums is minimized.
|
|
17
|
+
|
|
18
|
+
Links
|
|
19
|
+
-----
|
|
20
|
+
|
|
21
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Partition_problem)
|
|
22
|
+
|
|
23
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
### numbers: List[int]
|
|
28
|
+
\n The set of numbers which has to be partitioned.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
name: Literal["NP"] = "NP"
|
|
32
|
+
numbers: list[int]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PortfolioOptimization(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Portfolio Optimization.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Portfolio Optimization problem tries to find the optimal portfolio of assets
|
|
16
|
+
which achieves an equal or higher return than the target return with the lowest
|
|
17
|
+
risk possible. The optimal portfolio is defined by the binary choices whether to
|
|
18
|
+
invest in a specific asset or not.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Portfolio_optimization)
|
|
24
|
+
|
|
25
|
+
[Transformation](https://arxiv.org/pdf/2012.01121.pdf)
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
### returns: List[List[float]]
|
|
30
|
+
\n Returns matrix which contains time-series of returns per asset i.
|
|
31
|
+
|
|
32
|
+
### R: float
|
|
33
|
+
\n Target for overall return of portfolio.
|
|
34
|
+
|
|
35
|
+
### n: int
|
|
36
|
+
\n Number of wanted assets in set.
|
|
37
|
+
|
|
38
|
+
### lambda0: int = 1
|
|
39
|
+
\n Default lagrange multiplier.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
name: Literal["PO"] = "PO"
|
|
43
|
+
returns: list[list[float]]
|
|
44
|
+
R: float
|
|
45
|
+
n: int
|
|
46
|
+
lambda0: int = 1
|
|
@@ -0,0 +1,63 @@
|
|
|
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 PortfolioOptimizationInvestmentBandsTargetVolatility(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Portfolio Optimization with Investment Bands and Target Volatility.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Portfolio Optimization problem tries to find the optimal portfolio of assets
|
|
16
|
+
which achieves an equal or higher return than the target return with the lowest
|
|
17
|
+
risk possible. The optimal portfolio is defined by the binary choices whether to
|
|
18
|
+
invest in a specific asset or not.
|
|
19
|
+
|
|
20
|
+
This special case of portfolio optimization handles to additional constraints. On
|
|
21
|
+
the one hand, it tries to find optimal investment portfolios with a fixed
|
|
22
|
+
volatility. On the other hand, it imposes investment bands in the computed
|
|
23
|
+
portfolios, i.e. the investment for each asset is between a minimum and a maximum.
|
|
24
|
+
|
|
25
|
+
Links
|
|
26
|
+
-----
|
|
27
|
+
|
|
28
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Portfolio_optimization)
|
|
29
|
+
|
|
30
|
+
[Transformation](https://arxiv.org/pdf/2106.06735.pdf)
|
|
31
|
+
|
|
32
|
+
Attributes
|
|
33
|
+
----------
|
|
34
|
+
### log_returns: List[float]
|
|
35
|
+
\n Log return of each asset.
|
|
36
|
+
|
|
37
|
+
### sigma: List[List[float]]
|
|
38
|
+
\n Risk matrix.
|
|
39
|
+
|
|
40
|
+
### investment_bands: List[Tuple[float, float]]
|
|
41
|
+
\n Investment bands for each asset.
|
|
42
|
+
|
|
43
|
+
### target_volatility: float
|
|
44
|
+
\n Target volatility of portfolio.
|
|
45
|
+
|
|
46
|
+
### max_budget: int
|
|
47
|
+
\n Maximum budget.
|
|
48
|
+
|
|
49
|
+
### budget_weight: float
|
|
50
|
+
\n Budget penalty factor.
|
|
51
|
+
|
|
52
|
+
### volatility_weight: float
|
|
53
|
+
\n Volatility penalty factor.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
name: Literal["POIBTV"] = "POIBTV"
|
|
57
|
+
log_returns: list[float]
|
|
58
|
+
sigma: list[list[float]]
|
|
59
|
+
investment_bands: list[tuple[float, float]]
|
|
60
|
+
target_volatility: float
|
|
61
|
+
max_budget: int
|
|
62
|
+
budget_weight: float = 5.0
|
|
63
|
+
volatility_weight: float = 50.0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QuadraticAssignment(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Quadratic Assignment.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
There are a set of _n_ facilities and a set of _n_ locations. For each pair of
|
|
16
|
+
locations, a distance is specified and for each pair of facilities a weight or flow
|
|
17
|
+
is specified. The Quadratic Assignment problem assigns all facilities to different
|
|
18
|
+
locations with the goal of minimizing the sum of products of the distances and the
|
|
19
|
+
corresponding flows.
|
|
20
|
+
|
|
21
|
+
Links
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Quadratic_assignment_problem)
|
|
25
|
+
|
|
26
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
27
|
+
|
|
28
|
+
Attributes
|
|
29
|
+
----------
|
|
30
|
+
### flow_matrix: List[List]
|
|
31
|
+
\n A matrix denoting the flow (or weight) between the facilities.
|
|
32
|
+
\n e.g. for two facilities with a flow of 3, the flow_matrix will be
|
|
33
|
+
_[[0, 3], [3, 0]]_.
|
|
34
|
+
|
|
35
|
+
### distance_matrix: List[List]
|
|
36
|
+
\n A matrix denoting the distance between the locations.
|
|
37
|
+
\n e.g. for two places with a distance of 8, the flow_matrix will be
|
|
38
|
+
_[[0, 8], [8, 0]]_.
|
|
39
|
+
|
|
40
|
+
### P: int
|
|
41
|
+
\n Positive, scalar penalty value to penalize when a facility is mapped to two
|
|
42
|
+
different locations or vice versa.
|
|
43
|
+
\n Default: _200_
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
name: Literal["QA"] = "QA"
|
|
47
|
+
flow_matrix: list[list[float]]
|
|
48
|
+
distance_matrix: list[list[float]]
|
|
49
|
+
P: int = 200
|
|
@@ -0,0 +1,48 @@
|
|
|
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 QuadraticKnapsack(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Quadratic Knapsack.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Given an upper bound of budget and a set of potential projects, each having a
|
|
16
|
+
certain cost, a certain value, and value interactions with the other projects, the
|
|
17
|
+
Quadratic Knapsack problem selects the combination of projects with the highest
|
|
18
|
+
total value, without exceeding the budget restraint.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Quadratic_knapsack_problem)
|
|
24
|
+
|
|
25
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
### projects: List[List[float]]
|
|
30
|
+
\n A double nested list with entries _projects[i][j]_ corresponding to the value
|
|
31
|
+
gain of choosing both projects i and j at the same time.
|
|
32
|
+
|
|
33
|
+
### costs: List[float]
|
|
34
|
+
\n The individual costs of each project.
|
|
35
|
+
|
|
36
|
+
### budget: float
|
|
37
|
+
\n Budget restraint (upper bound) on projects.
|
|
38
|
+
|
|
39
|
+
### P: int
|
|
40
|
+
\n The weight of the penalty term.
|
|
41
|
+
\n Default: _10_
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
name: Literal["QK"] = "QK"
|
|
45
|
+
projects: list[list[float]]
|
|
46
|
+
costs: list[float]
|
|
47
|
+
budget: float
|
|
48
|
+
P: float = 10
|
|
@@ -0,0 +1,73 @@
|
|
|
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 SatelliteScheduling(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Satellite Scheduling.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
We assume a satellite can occupy three states: charging (*c*), downlink (*d*) and
|
|
16
|
+
experiment (*e*). We discretize the time and assume time steps *t ∈ {0,1,...,T}*.
|
|
17
|
+
The variable *x_st* tells us if the satellite is in the state *s ∈ {c,d,e}* at time
|
|
18
|
+
*t*. With this, the time sequence of these variables represents the schedule we want
|
|
19
|
+
to optimize. The optimization goal is to record as much data as possible during the
|
|
20
|
+
mission. [1]
|
|
21
|
+
|
|
22
|
+
There are two satellite variables which may change over time: The charge of the
|
|
23
|
+
battery *C* and the data stored on the memory *D*. The rate with which these
|
|
24
|
+
variables are changing depending on state *s* are denoted by *c_s* and *d_s*
|
|
25
|
+
respectively. [1]
|
|
26
|
+
|
|
27
|
+
For example the experiment state will increase the data *dd > 0* and decrease the
|
|
28
|
+
charge *dc < 0*. Both the battery and the memory define an upper and lower limit
|
|
29
|
+
for the charge and the data, respectively. Not every state can be occupied at each
|
|
30
|
+
instance in time. For example, the charging through solar panels is only possible
|
|
31
|
+
in sunlight, or the downlink is only possible in the vicinity of a ground station.
|
|
32
|
+
Therefore for each state s there is a subset of times `τ_s ⊆ {0,1,...,T}* at which
|
|
33
|
+
the satellite can occupy this state. To enforce this constraint, we remove all
|
|
34
|
+
variables *x_st ∈ {x_st |t ∈ τ_s}*. [1]
|
|
35
|
+
|
|
36
|
+
For the sake of simplicity, we assume that each state has minimum duration of *1*.
|
|
37
|
+
|
|
38
|
+
Links
|
|
39
|
+
-----
|
|
40
|
+
|
|
41
|
+
[Transformation (Experiences with Scheduling Problems on Adiabatic Quantum Computers)](https://elib.dlr.de/110044/1/43.pdf)
|
|
42
|
+
|
|
43
|
+
Attributes
|
|
44
|
+
----------
|
|
45
|
+
### T: int
|
|
46
|
+
\n T is the latest included time step. Note that the earliest included time step
|
|
47
|
+
is always *0*.
|
|
48
|
+
|
|
49
|
+
### P: Tuple[int, int, int, int, int, int]
|
|
50
|
+
\n The penalties for each constraint.
|
|
51
|
+
|
|
52
|
+
### Tau: List[List[int]]
|
|
53
|
+
\n Times to be removed for each state.
|
|
54
|
+
|
|
55
|
+
### d: Dict
|
|
56
|
+
\n Dict describing downlink state which includes entries *rate*, *initial*,
|
|
57
|
+
*max*, *min*.
|
|
58
|
+
|
|
59
|
+
### c: Dict
|
|
60
|
+
\n Dict describing charging state which includes entries *rate*, *initial*,
|
|
61
|
+
*max*, *min*.
|
|
62
|
+
|
|
63
|
+
### S: int
|
|
64
|
+
\n *S* is the total number of possible states.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
name: Literal["SSC"] = "SSC"
|
|
68
|
+
T: int
|
|
69
|
+
P: tuple[int, int, int, int, int, int]
|
|
70
|
+
Tau: list[list[int]]
|
|
71
|
+
d: dict[str, float]
|
|
72
|
+
c: dict[str, float]
|
|
73
|
+
S: int = 3
|