luna-quantum 1.0.8rc2__cp314-cp314-macosx_10_12_x86_64.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/__init__.py +121 -0
- luna_quantum/__init__.pyi +85 -0
- luna_quantum/_core.cpython-314-darwin.so +0 -0
- luna_quantum/_core.pyi +4185 -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/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 +457 -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 +196 -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 +55 -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_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 +26 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +99 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +102 -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 +22 -0
- luna_quantum/solve/parameters/backends/aqarios.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/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/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_result_usecase.py +95 -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.0.8rc2.dist-info/METADATA +36 -0
- luna_quantum-1.0.8rc2.dist-info/RECORD +264 -0
- luna_quantum-1.0.8rc2.dist-info/WHEEL +4 -0
- luna_quantum-1.0.8rc2.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.0.8rc2.dist-info/licenses/NOTICE +13 -0
|
@@ -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 BinaryPaintShopProblem(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Binary Paint Shop.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Binary Paint Shop Problem tries to minimize the color change of a paint job with
|
|
16
|
+
two colors of a sequence of cars. The sequence consists of a fixed number of cars,
|
|
17
|
+
in which each car type occurs exactly twice and these are to be colored in different
|
|
18
|
+
colors. Therefore, the car sequence consists of exactly twice as many cars as there
|
|
19
|
+
are car types.
|
|
20
|
+
|
|
21
|
+
Links
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
[Transformation](https://arxiv.org/pdf/2011.03403.pdf)
|
|
25
|
+
|
|
26
|
+
Attributes
|
|
27
|
+
----------
|
|
28
|
+
### n_cars: int
|
|
29
|
+
\n Amount of different car types.
|
|
30
|
+
|
|
31
|
+
### sequence: List[int]
|
|
32
|
+
\n Sequence of the cars.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
name: Literal["BPSP"] = "BPSP"
|
|
36
|
+
n_cars: int
|
|
37
|
+
sequence: list[int]
|
|
@@ -0,0 +1,40 @@
|
|
|
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 CreditScoringFeatureSelection(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Feature Selection for Credit Scoring.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Find the optimal feature subset with regard to independence and influence of
|
|
16
|
+
features for credit scoring of credit applicants.
|
|
17
|
+
|
|
18
|
+
Links
|
|
19
|
+
-----
|
|
20
|
+
|
|
21
|
+
[Transformation](https://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Optimal-Feature-Selection-in-Credit-Scoring-and-Classification-Using-a-Quantum-Annealer_-_2017.04.13.pdf)
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
### U: List[List[float]]
|
|
26
|
+
\n The matrix U is the design matrix, where each column represents a feature
|
|
27
|
+
and each row represents the specific values for a feature set.
|
|
28
|
+
|
|
29
|
+
### V: List[int]
|
|
30
|
+
\n The binary label vector for the respective row in matrix U.
|
|
31
|
+
|
|
32
|
+
### alpha: float
|
|
33
|
+
\n The balance between feature influence and feature independence in the range
|
|
34
|
+
_[0, 1]_.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
name: Literal["CSFS"] = "CSFS"
|
|
38
|
+
U: list[list[float]]
|
|
39
|
+
V: list[int]
|
|
40
|
+
alpha: float
|
|
@@ -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 DynamicPortfolioOptimization(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Dynamic Portfolio Optimization.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Dynamic Portfolio Optimization problem tries to find the optimal portfolio for a
|
|
16
|
+
given set of assets and a fixed investment amount. It aims to find the portfolio
|
|
17
|
+
with optimal returns for a given risk tolerance. It considers transaction costs when
|
|
18
|
+
rebalancing across multiple time steps. The optimal portfolio is defined by the
|
|
19
|
+
binary choices whether to invest in a specific asset and how much to invest in it.
|
|
20
|
+
The investment amount is split into several so called packages defined as
|
|
21
|
+
2^(package number). The total number of packages determines the granularity of the
|
|
22
|
+
result. It defines the amount of possible investment sums in one asset as well as
|
|
23
|
+
the maximum possible investment in any one asset, which is
|
|
24
|
+
2^(Number of packages) - 1.
|
|
25
|
+
|
|
26
|
+
Links
|
|
27
|
+
-----
|
|
28
|
+
|
|
29
|
+
[Transformation](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.4.013006)
|
|
30
|
+
|
|
31
|
+
Attributes
|
|
32
|
+
----------
|
|
33
|
+
### tickers: List
|
|
34
|
+
\n Tickers of assets being tested.
|
|
35
|
+
### mu: List[List[float]]
|
|
36
|
+
\n Expected Returns of the assets.
|
|
37
|
+
\n Shape: [time_steps][number_of_assets]
|
|
38
|
+
### sigma: List[List[List[float]]]
|
|
39
|
+
\n Coviariance Matrix of the assets.
|
|
40
|
+
\n Shape: [time_steps][number_of_assets][number_of_assets]
|
|
41
|
+
### packages: int
|
|
42
|
+
\n Number of packages per asset, determines granularity of investment.
|
|
43
|
+
\n _Package value = 2^(package number)_
|
|
44
|
+
### K: int
|
|
45
|
+
\n Total investment amount, which is fixed.
|
|
46
|
+
### gamma: float
|
|
47
|
+
\n Risk Aversion Coefficient.
|
|
48
|
+
\n Range: Risk Seeking 0-100 Very Risk Averse.
|
|
49
|
+
\n Divided by factor 2 as a convention, as stated in paper.
|
|
50
|
+
### nu: float
|
|
51
|
+
\n Transaction Cost percentage, e.g., 0.01 = 1% of transaction size.
|
|
52
|
+
### rho: float
|
|
53
|
+
\n Total investment size constraint factor, Lagrange Multiplier.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
name: Literal["DPO"] = "DPO"
|
|
57
|
+
tickers: list[str | int]
|
|
58
|
+
mu: list[list[float]]
|
|
59
|
+
sigma: list[list[list[float]]]
|
|
60
|
+
packages: int
|
|
61
|
+
K: int
|
|
62
|
+
gamma: float
|
|
63
|
+
nu: float
|
|
64
|
+
rho: float
|
|
@@ -0,0 +1,51 @@
|
|
|
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 ExactCover(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Exact Cover.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Given a set _S_ and a list of subsets of _S_, an exact cover is a family _C_ of
|
|
16
|
+
these subsets so that all elements of _S_ are contained in exactly one subset of
|
|
17
|
+
_C_. For a set _S_ and a list of subsets of _S_, the Exact Cover problem tries to
|
|
18
|
+
find the smallest exact cover, i.e. the one that uses the least subsets.
|
|
19
|
+
|
|
20
|
+
Q-Bit Interpretation
|
|
21
|
+
--------------------
|
|
22
|
+
|
|
23
|
+
Subset _i_ is part of the exact cover iff. qubit _i_ is 1.
|
|
24
|
+
|
|
25
|
+
Links
|
|
26
|
+
-----
|
|
27
|
+
|
|
28
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Exact_cover)
|
|
29
|
+
|
|
30
|
+
[Transformation](https://arxiv.org/pdf/1302.5843.pdf)
|
|
31
|
+
|
|
32
|
+
Attributes
|
|
33
|
+
----------
|
|
34
|
+
### subset_matrix: List[List[float]]
|
|
35
|
+
\n A matrix containing all subsets.
|
|
36
|
+
\n e.g. for the set _{1, 2, 3}_ and the subsets _{1, 2}_, _{2, 3}_, and _{3}_:
|
|
37
|
+
\n _[[1, 1, 0], [0, 1, 1], [0, 0, 1]]_
|
|
38
|
+
\n or:
|
|
39
|
+
\n _ExactCover.gen_subsets_matrix([1, 2, 3], [[1, 2], [2, 3], [3]])_
|
|
40
|
+
|
|
41
|
+
### A: int
|
|
42
|
+
\n A constant enforcing the exact cover of the solution.
|
|
43
|
+
|
|
44
|
+
### B: int
|
|
45
|
+
\n A constant (_A > nB_) helping find the smallest exact cover.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["EC"] = "EC"
|
|
49
|
+
subset_matrix: list[list[int]]
|
|
50
|
+
A: int = 2
|
|
51
|
+
B: int = 2
|
|
@@ -0,0 +1,79 @@
|
|
|
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 FlightGateAssignment(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Flight Gate Assignment.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Flight Gate Assignment is a highly relevant optimization problem in airport
|
|
16
|
+
management. It tries to minimize the total transit time of passengers, considering
|
|
17
|
+
three typical parts of passenger flow in an airport:
|
|
18
|
+
\n 1) After a flight, passengers claim their baggage and leave the airport.
|
|
19
|
+
\n 2) Other passengers switch from one plane to another to get a connecting flight.
|
|
20
|
+
\n 3) A third group of passengers pass the security check and leave with a flight.
|
|
21
|
+
|
|
22
|
+
Links
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
[Description and Transformation](https://arxiv.org/pdf/1811.09465.pdf)
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
### n_flights: int
|
|
30
|
+
\n Number of flights.
|
|
31
|
+
|
|
32
|
+
### n_gates: int
|
|
33
|
+
\n Number of gates.
|
|
34
|
+
|
|
35
|
+
### n_passengers: List[Tuple[int, int]]
|
|
36
|
+
\n Number of passengers arriving and departing with each flight.
|
|
37
|
+
\n Example: _n_passengers[3][departure_index]_, gives us the number of
|
|
38
|
+
passengers departing with flight _3_.
|
|
39
|
+
|
|
40
|
+
### time_gates: List[Tuple[float, float]]
|
|
41
|
+
\n The time it takes between every gate and check-in (when leaving) or the gate
|
|
42
|
+
and baggage claim (when arriving).
|
|
43
|
+
\n Example: _time_gates[0][arriving_index]_, gives us the time it takes to go
|
|
44
|
+
from gate _0_ to baggage claim.
|
|
45
|
+
|
|
46
|
+
### time_flights: List[Tuple[float, float]]
|
|
47
|
+
\n The time at which a flight arrives/leaves.
|
|
48
|
+
\n Example: _time_flights[2][departure_index]_, gives us the time at which
|
|
49
|
+
flight 2 departs.
|
|
50
|
+
|
|
51
|
+
### transfer_passengers: List[List[int]]
|
|
52
|
+
\n Matrix with the information of the passengers transferring from one flight to
|
|
53
|
+
another.
|
|
54
|
+
\n Example: _transfer_passengers[2][5]_, gives the number of passengers
|
|
55
|
+
transferring from flight 2 to flight 5.
|
|
56
|
+
|
|
57
|
+
### time_between_gates: List[List[float]]
|
|
58
|
+
\n Gives the time it takes to go from one gate to another.
|
|
59
|
+
|
|
60
|
+
### t_buf: float
|
|
61
|
+
\n Time needed for a gate to be free after a flight has departed.
|
|
62
|
+
|
|
63
|
+
### arrival_index, departure_index: int
|
|
64
|
+
\n Index to subscribe the variables _time_gates_, _n_passengers_,
|
|
65
|
+
_time_gates_, _time_flights_.
|
|
66
|
+
\n One of these variables needs to be _0_, the other _1_.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
name: Literal["FGO"] = "FGO"
|
|
70
|
+
n_flights: int
|
|
71
|
+
n_gates: int
|
|
72
|
+
n_passengers: list[tuple[int, int]]
|
|
73
|
+
time_gates: list[tuple[float, float]]
|
|
74
|
+
time_flights: list[tuple[float, float]]
|
|
75
|
+
transfer_passengers: list[list[int]]
|
|
76
|
+
time_between_gates: list[list[float]]
|
|
77
|
+
t_buf: float
|
|
78
|
+
arrival_index: int = 0
|
|
79
|
+
departure_index: int = 1
|
|
@@ -0,0 +1,42 @@
|
|
|
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 GraphColoring(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Graph Coloring.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Graph Coloring problem tries to color the nodes of a graph with a given number
|
|
18
|
+
of different colors so that no adjacent nodes have the same color.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Graph_coloring)
|
|
24
|
+
|
|
25
|
+
[Transformation](https://arxiv.org/pdf/1811.11538.pdf)
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
30
|
+
\n Problem graph for the graph coloring problem in form of nested 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
|
+
### n_colors: int
|
|
36
|
+
\n Number of different colors.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
name: Literal["GC"] = "GC"
|
|
40
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
41
|
+
n_colors: int
|
|
42
|
+
P: int = 4
|
|
@@ -0,0 +1,52 @@
|
|
|
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 GraphIsomorphism(UseCase):
|
|
10
|
+
r"""
|
|
11
|
+
# Graph Isomorphism.
|
|
12
|
+
|
|
13
|
+
Description
|
|
14
|
+
-----------
|
|
15
|
+
|
|
16
|
+
The Graph Isomorphism problem tries to find out whether two graphs _G1_ and _G2_are
|
|
17
|
+
isomorphic, i.e. there exists a bijective, edge-invariant vertex mapping from _G1_
|
|
18
|
+
to _G2_.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Graph_isomorphism)
|
|
24
|
+
|
|
25
|
+
[Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf?sequence=1)
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
### graph1: Dict[int, Dict[int, Dict[str, float]]]
|
|
30
|
+
\n The first graph (in form of nested dictionaries) to check for isomorphism.
|
|
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
|
+
### graph2: Dict[int, Dict[int, Dict[str, float]]]
|
|
36
|
+
\n The second graph (in form of nested dictionaries) to check for isomorphism.
|
|
37
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
38
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
39
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
40
|
+
|
|
41
|
+
### a: float
|
|
42
|
+
\n A penalty value enforcing the bijectivity of the isomorphism.
|
|
43
|
+
|
|
44
|
+
### b: float
|
|
45
|
+
\n A penalty value (b > a) enforcing the edge-invariance of the isomorphism.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["GI"] = "GI"
|
|
49
|
+
graph1: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
|
|
50
|
+
graph2: NestedDictIntGraph = Field(name="graph") # type: ignore[call-overload]
|
|
51
|
+
a: float = 1
|
|
52
|
+
b: float = 2
|
|
@@ -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 GraphPartitioning(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
Graph Partitioning.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Graph Partitioning problem tries to find two equal sized partitions for a given
|
|
16
|
+
undirected graph with an even number of vertices, so that the number of edges
|
|
17
|
+
connecting the two subsets is minimized.
|
|
18
|
+
|
|
19
|
+
Links
|
|
20
|
+
-----
|
|
21
|
+
|
|
22
|
+
[Transformation](https://arxiv.org/abs/1302.5843)
|
|
23
|
+
|
|
24
|
+
Attributes
|
|
25
|
+
----------
|
|
26
|
+
### graph : Dict[int, Dict[int, Dict[str, float]]]
|
|
27
|
+
\n The graph, for which the partitions are to be foundin form of nested
|
|
28
|
+
dictionaries.
|
|
29
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
30
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
31
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
32
|
+
|
|
33
|
+
### A : Optional[int]
|
|
34
|
+
\n Penalty parameter A panalizes violation of the constraint that makes sure
|
|
35
|
+
both partitions are of equal size. It can be left "None" to be estimated from
|
|
36
|
+
the problem graph via the papers suggestion.
|
|
37
|
+
|
|
38
|
+
### B : Optional[int]
|
|
39
|
+
\n Optimization penalty parameter B penalizes each edge connecting two nodes of
|
|
40
|
+
different partitions. If not given it defaults to 1.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
name: Literal["GP"] = "GP"
|
|
44
|
+
graph: dict[str, dict[str, dict[str, float]]]
|
|
45
|
+
A: int | None = None
|
|
46
|
+
B: int | None = 1
|
|
@@ -0,0 +1,49 @@
|
|
|
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 HamiltonianCycle(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Hamiltonian Cycle.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
The Hamiltonian Cycle problem, either for a directed or undirected graph, asks the
|
|
18
|
+
following: starting at an arbitrary node in the graph, can one travel along the
|
|
19
|
+
edges of the graph so that each graph will be visited exactly once and there is an
|
|
20
|
+
edge between the starting node and the last node?
|
|
21
|
+
|
|
22
|
+
Links
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Hamiltonian_path_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 hamiltonian cycle 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 Default: _1.0_
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
# Hamiltonian Cycle is just TSP with B = 0.
|
|
44
|
+
|
|
45
|
+
name: Literal["HC"] = "HC"
|
|
46
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
47
|
+
directed: bool | None = False
|
|
48
|
+
A: float = 1.0
|
|
49
|
+
B: float = 0.0
|
|
@@ -0,0 +1,50 @@
|
|
|
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 InducedSubGraphIsomorphism(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Induced Subgraph Isomorphism.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
Given two graphs the induced subgraph isomorphism problem is to decide if there
|
|
18
|
+
exists an edge invariant injective mapping from the vertices of the first graph to
|
|
19
|
+
the second graph.
|
|
20
|
+
The task is slightly different from the subgraph isomorphism problem, because here
|
|
21
|
+
additional edges present between two vertices in the second graph to which the
|
|
22
|
+
isomorphism maps, are prohibited.
|
|
23
|
+
|
|
24
|
+
This Implementation is heavily based on the subgraph isomorphism problem
|
|
25
|
+
implementation.
|
|
26
|
+
It uses slack variables to counterbalance unnecessary penalties.
|
|
27
|
+
|
|
28
|
+
Links
|
|
29
|
+
-----
|
|
30
|
+
|
|
31
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Induced_subgraph_isomorphism_problem)
|
|
32
|
+
|
|
33
|
+
[Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf)
|
|
34
|
+
|
|
35
|
+
Attributes
|
|
36
|
+
----------
|
|
37
|
+
### graph1: Dict[int, Dict[int, Dict[str, float]]]
|
|
38
|
+
\n The first graph in form of nested dictionaries.
|
|
39
|
+
\n (e.g. fully connected graph with 3 nodes:
|
|
40
|
+
\n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
|
|
41
|
+
\n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
|
|
42
|
+
|
|
43
|
+
### graph2: Dict[int, Dict[int, Dict[str, float]]]
|
|
44
|
+
\n The second graph, on which the first one is to be mapped, also in form of
|
|
45
|
+
nested dictionaries.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["ISGI"] = "ISGI"
|
|
49
|
+
graph1: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
50
|
+
graph2: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
@@ -0,0 +1,44 @@
|
|
|
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 JobShopScheduling(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Job Shop Scheduling.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
Consider a number of jobs, each of which consists of a number of operations which
|
|
18
|
+
have to be processed in a specific order. Each operation has a specific machine that
|
|
19
|
+
it needs to be processed on and only one operation in a job can be processed at a
|
|
20
|
+
given time. Also, each machine can only execute one job at a time. The objective of
|
|
21
|
+
the Job Shop Scheduling problem is to schedule all operations in a valid sequence
|
|
22
|
+
while minimizing the makespan of the jobs, i.e. the completion time of the last
|
|
23
|
+
running job.
|
|
24
|
+
|
|
25
|
+
Links
|
|
26
|
+
-----
|
|
27
|
+
|
|
28
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Job-shop_scheduling)
|
|
29
|
+
|
|
30
|
+
[Transformation](https://arxiv.org/pdf/1506.08479.pdf)
|
|
31
|
+
|
|
32
|
+
Attributes
|
|
33
|
+
----------
|
|
34
|
+
### jobs: Dict[int, List[Tuple[int, int]]]
|
|
35
|
+
\n A dictionary containing all jobs. Each job is a list of operations and each
|
|
36
|
+
operation is tuple containing the machine and the processing time.
|
|
37
|
+
|
|
38
|
+
### T: int
|
|
39
|
+
\n Strict upper bound when all jobs should be finished.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
name: Literal["JSS"] = "JSS"
|
|
43
|
+
jobs: dict[int, list[tuple[int, int]]] = Field(name="dict") # type: ignore[call-overload]
|
|
44
|
+
T: int = 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 KMedoidsClustering(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# K-Medoids Clustering.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The authors are concerned with k-medoids clustering and propose a quadratic
|
|
16
|
+
unconstrained binary optimization (*QUBO*) formulation of the problem of
|
|
17
|
+
identifying *k* medoids among *n* data points without having to cluster the data.
|
|
18
|
+
Given our *QUBO* formulation of this NP-hard problem, it should be possible to solve
|
|
19
|
+
it on adiabatic quantum computers.
|
|
20
|
+
|
|
21
|
+
Q-Bit Interpretation
|
|
22
|
+
--------------------
|
|
23
|
+
|
|
24
|
+
"The qubit vector at index _k_ is 1 iff. data point _k_ from the distance matrix is
|
|
25
|
+
chosen as medoid of a cluster. The step of assigning the remaining data points to
|
|
26
|
+
clusters is not covered in this problem but can be easily done in linear time with
|
|
27
|
+
respect to the number of data points."
|
|
28
|
+
|
|
29
|
+
Links
|
|
30
|
+
-----
|
|
31
|
+
|
|
32
|
+
[Transformation](http://ceur-ws.org/Vol-2454/paper_39.pdf)
|
|
33
|
+
|
|
34
|
+
Attributes
|
|
35
|
+
----------
|
|
36
|
+
D : List[List[float]]
|
|
37
|
+
\n The (*n x n*) similarity matrix (diagonal elements are *1* (*one*)).
|
|
38
|
+
|
|
39
|
+
k : int
|
|
40
|
+
\n The number of medoids.
|
|
41
|
+
|
|
42
|
+
gamma : float
|
|
43
|
+
\n Penalty coefficient to enforce feasibility.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
name: Literal["KMC"] = "KMC"
|
|
47
|
+
D: list[list[float]]
|
|
48
|
+
k: int
|
|
49
|
+
gamma: float
|
|
@@ -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 KnapsackIntegerWeights(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Knapsack with Integer Weights.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
Given a knapsack that can only carry a weight _W_ and a set of objects, each object
|
|
16
|
+
having a weight _w_ and a value _c_, the Knapsack with Integer Weights problem tries
|
|
17
|
+
to find objects so that the sum of their values is maximized while, at the same
|
|
18
|
+
time, the sum of their weights does not exceed the capacity of the knapsack.
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Description and Transformation](https://arxiv.org/pdf/1302.5843.pdf)
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
### w: List[int]
|
|
28
|
+
\n The weight of each object.
|
|
29
|
+
|
|
30
|
+
### c: List[float]
|
|
31
|
+
\n The value of each object.
|
|
32
|
+
|
|
33
|
+
### W: int
|
|
34
|
+
\n The weight that the knapsack can carry.
|
|
35
|
+
|
|
36
|
+
### B: float
|
|
37
|
+
\n A positive constant to reward putting an object into the knapsack.
|
|
38
|
+
\n Default: _1_
|
|
39
|
+
|
|
40
|
+
### A: Optional[float]
|
|
41
|
+
\n A positive penalty value, enforcing that the maximal weight will not be
|
|
42
|
+
exceeded. If specified, the equation _A > B _max_(c)_ must hold. If not
|
|
43
|
+
specified, will be computed automatically as _A = 1 + B _max_(c)_.
|
|
44
|
+
|
|
45
|
+
### linear_encoding: bool
|
|
46
|
+
\n If false, the number of qubits will be highly reduced, using the log trick
|
|
47
|
+
from section 2.4 of the paper linked above.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
name: Literal["KIW"] = "KIW"
|
|
51
|
+
w: list[int]
|
|
52
|
+
c: list[float]
|
|
53
|
+
W: int
|
|
54
|
+
B: float = 1.0
|
|
55
|
+
A: float | None = None
|
|
56
|
+
linear_encoding: bool = False
|