luna-quantum 0.0.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of luna-quantum might be problematic. Click here for more details.

Files changed (160) hide show
  1. luna_quantum-0.0.16.dist-info/LICENSE +201 -0
  2. luna_quantum-0.0.16.dist-info/METADATA +46 -0
  3. luna_quantum-0.0.16.dist-info/RECORD +160 -0
  4. luna_quantum-0.0.16.dist-info/WHEEL +4 -0
  5. luna_sdk/__init__.py +2 -0
  6. luna_sdk/constants.py +1 -0
  7. luna_sdk/controllers/__init__.py +2 -0
  8. luna_sdk/controllers/custom_login_client.py +61 -0
  9. luna_sdk/controllers/luna_platform_client.py +62 -0
  10. luna_sdk/controllers/luna_q.py +36 -0
  11. luna_sdk/controllers/luna_solve.py +49 -0
  12. luna_sdk/controllers/luna_transform.py +41 -0
  13. luna_sdk/error/__init__.py +0 -0
  14. luna_sdk/error/http_error_utils.py +100 -0
  15. luna_sdk/exceptions/__init__.py +1 -0
  16. luna_sdk/exceptions/encryption_exception.py +6 -0
  17. luna_sdk/exceptions/luna_exception.py +7 -0
  18. luna_sdk/exceptions/luna_server_exception.py +18 -0
  19. luna_sdk/exceptions/timeout_exception.py +10 -0
  20. luna_sdk/exceptions/transformation.py +11 -0
  21. luna_sdk/interfaces/__init__.py +5 -0
  22. luna_sdk/interfaces/circuit_repo_i.py +62 -0
  23. luna_sdk/interfaces/clients/__init__.py +0 -0
  24. luna_sdk/interfaces/clients/client_i.py +10 -0
  25. luna_sdk/interfaces/clients/luna_q_i.py +39 -0
  26. luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
  27. luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
  28. luna_sdk/interfaces/cplex_repo_i.py +121 -0
  29. luna_sdk/interfaces/info_repo_i.py +40 -0
  30. luna_sdk/interfaces/lp_repo_i.py +106 -0
  31. luna_sdk/interfaces/optimization_repo_i.py +262 -0
  32. luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
  33. luna_sdk/interfaces/repository_i.py +14 -0
  34. luna_sdk/interfaces/solutions_repo_i.py +219 -0
  35. luna_sdk/py.typed +0 -0
  36. luna_sdk/repositories/__init__.py +4 -0
  37. luna_sdk/repositories/circuit_repo.py +104 -0
  38. luna_sdk/repositories/cplex_repo.py +118 -0
  39. luna_sdk/repositories/info_repo.py +45 -0
  40. luna_sdk/repositories/lp_repo.py +105 -0
  41. luna_sdk/repositories/optimization_repo.py +358 -0
  42. luna_sdk/repositories/qpu_token_repo.py +226 -0
  43. luna_sdk/repositories/solutions_repo.py +347 -0
  44. luna_sdk/schemas/__init__.py +4 -0
  45. luna_sdk/schemas/circuit.py +43 -0
  46. luna_sdk/schemas/create/__init__.py +3 -0
  47. luna_sdk/schemas/create/circuit.py +29 -0
  48. luna_sdk/schemas/create/optimization.py +22 -0
  49. luna_sdk/schemas/create/qpu_token.py +26 -0
  50. luna_sdk/schemas/create/qubo.py +19 -0
  51. luna_sdk/schemas/create/solution.py +15 -0
  52. luna_sdk/schemas/enums/__init__.py +0 -0
  53. luna_sdk/schemas/enums/circuit.py +14 -0
  54. luna_sdk/schemas/enums/optimization.py +10 -0
  55. luna_sdk/schemas/enums/problem.py +48 -0
  56. luna_sdk/schemas/enums/qpu_token_type.py +6 -0
  57. luna_sdk/schemas/enums/solution.py +8 -0
  58. luna_sdk/schemas/enums/status.py +10 -0
  59. luna_sdk/schemas/enums/timeframe.py +11 -0
  60. luna_sdk/schemas/error_message.py +12 -0
  61. luna_sdk/schemas/optimization.py +75 -0
  62. luna_sdk/schemas/optimization_formats/__init__.py +0 -0
  63. luna_sdk/schemas/optimization_formats/bqm.py +34 -0
  64. luna_sdk/schemas/optimization_formats/cqm.py +127 -0
  65. luna_sdk/schemas/optimization_formats/lp.py +9 -0
  66. luna_sdk/schemas/optimization_formats/qm.py +30 -0
  67. luna_sdk/schemas/pretty_base.py +49 -0
  68. luna_sdk/schemas/qpu_token.py +60 -0
  69. luna_sdk/schemas/representation.py +19 -0
  70. luna_sdk/schemas/rest/__init__.py +0 -0
  71. luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
  72. luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
  73. luna_sdk/schemas/solution.py +227 -0
  74. luna_sdk/schemas/solver_info.py +11 -0
  75. luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
  76. luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
  77. luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
  78. luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
  79. luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
  80. luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
  81. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
  82. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
  83. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
  84. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
  85. luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
  86. luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
  87. luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
  88. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
  89. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
  90. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
  91. luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
  92. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
  93. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
  94. luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
  95. luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
  96. luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
  97. luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
  98. luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
  99. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
  100. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
  101. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
  102. luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
  103. luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
  104. luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
  105. luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
  106. luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
  107. luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
  108. luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
  109. luna_sdk/schemas/transformations/__init__.py +2 -0
  110. luna_sdk/schemas/transformations/bqm.py +33 -0
  111. luna_sdk/schemas/transformations/matrix.py +12 -0
  112. luna_sdk/schemas/use_cases/__init__.py +54 -0
  113. luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
  114. luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
  115. luna_sdk/schemas/use_cases/base.py +5 -0
  116. luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
  117. luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
  118. luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
  119. luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
  120. luna_sdk/schemas/use_cases/exact_cover.py +50 -0
  121. luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
  122. luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
  123. luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
  124. luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
  125. luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
  126. luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
  127. luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
  128. luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
  129. luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
  130. luna_sdk/schemas/use_cases/linear_regression.py +59 -0
  131. luna_sdk/schemas/use_cases/lmwcs.py +80 -0
  132. luna_sdk/schemas/use_cases/longest_path.py +49 -0
  133. luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
  134. luna_sdk/schemas/use_cases/max2sat.py +51 -0
  135. luna_sdk/schemas/use_cases/max3sat.py +52 -0
  136. luna_sdk/schemas/use_cases/max_clique.py +59 -0
  137. luna_sdk/schemas/use_cases/max_cut.py +47 -0
  138. luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
  139. luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
  140. luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
  141. luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
  142. luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
  143. luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
  144. luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
  145. luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
  146. luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
  147. luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
  148. luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
  149. luna_sdk/schemas/use_cases/set_cover.py +55 -0
  150. luna_sdk/schemas/use_cases/set_packing.py +53 -0
  151. luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
  152. luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
  153. luna_sdk/schemas/use_cases/subset_sum.py +36 -0
  154. luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
  155. luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
  156. luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
  157. luna_sdk/schemas/use_cases/type_aliases.py +11 -0
  158. luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
  159. luna_sdk/utils/__init__.py +0 -0
  160. luna_sdk/utils/qpu_tokens.py +52 -0
@@ -0,0 +1,36 @@
1
+ from typing import List, Literal
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class BinaryPaintShopProblem(UseCase):
7
+ """
8
+ # Binary Paint Shop
9
+
10
+ Description
11
+ -----------
12
+
13
+ The Binary Paint Shop Problem tries to minimize the color change of a paint job with
14
+ two colors of a sequence of cars. The sequence consists of a fixed number of cars,
15
+ in which each car type occurs exactly twice and these are to be colored in different
16
+ colors. Therefore, the car sequence consists of exactly twice as many cars as there
17
+ are car types.
18
+
19
+ Links
20
+ -----
21
+
22
+ [Transformation](https://arxiv.org/pdf/2011.03403.pdf)
23
+
24
+ Attributes
25
+ ----------
26
+
27
+ ### n_cars: int
28
+ \n Amount of different car types.
29
+
30
+ ### sequence: List[int]
31
+ \n Sequence of the cars.
32
+ """
33
+
34
+ name: Literal["BPSP"] = "BPSP"
35
+ n_cars: int
36
+ sequence: List[int]
@@ -0,0 +1,39 @@
1
+ from typing import List, Literal
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class CreditScoringFeatureSelection(UseCase):
7
+ """
8
+ # Feature Selection for Credit Scoring
9
+
10
+ Description
11
+ -----------
12
+
13
+ Find the optimal feature subset with regard to independence and influence of
14
+ features for credit scoring of credit applicants.
15
+
16
+ Links
17
+ -----
18
+
19
+ [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)
20
+
21
+ Attributes
22
+ ----------
23
+
24
+ ### U: List[List[float]]
25
+ \n The matrix U is the design matrix, where each column represents a feature
26
+ and each row represents the specific values for a feature set.
27
+
28
+ ### V: List[int]
29
+ \n The binary label vector for the respective row in matrix U.
30
+
31
+ ### alpha: float
32
+ \n The balance between feature influence and feature independence in the range
33
+ _[0, 1]_.
34
+ """
35
+
36
+ name: Literal["CSFS"] = "CSFS"
37
+ U: List[List[float]]
38
+ V: List[int]
39
+ alpha: float
@@ -0,0 +1,63 @@
1
+ from typing import List, Literal, Union
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class DynamicPortfolioOptimization(UseCase):
7
+ """
8
+ # Dynamic Portfolio Optimization
9
+
10
+ Description
11
+ -----------
12
+
13
+ The Dynamic Portfolio Optimization problem tries to find the optimal portfolio for a
14
+ given set of assets and a fixed investment amount. It aims to find the portfolio
15
+ with optimal returns for a given risk tolerance. It considers transaction costs when
16
+ rebalancing across multiple time steps. The optimal portfolio is defined by the
17
+ binary choices whether to invest in a specific asset and how much to invest in it.
18
+ The investment amount is split into several so called packages defined as
19
+ 2^(package number). The total number of packages determines the granularity of the
20
+ result. It defines the amount of possible investment sums in one asset as well as
21
+ the maximum possible investment in any one asset, which is
22
+ 2^(Number of packages) - 1.
23
+
24
+ Links
25
+ -----
26
+
27
+ [Transformation](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.4.013006)
28
+
29
+ Attributes
30
+ ----------
31
+
32
+ ### tickers: List
33
+ \n Tickers of assets being tested.
34
+ ### mu: List[List[float]]
35
+ \n Expected Returns of the assets.
36
+ \n Shape: [time_steps][number_of_assets]
37
+ ### sigma: List[List[List[float]]]
38
+ \n Coviariance Matrix of the assets.
39
+ \n Shape: [time_steps][number_of_assets][number_of_assets]
40
+ ### packages: int
41
+ \n Number of packages per asset, determines granularity of investment.
42
+ \n _Package value = 2^(package number)_
43
+ ### K: int
44
+ \n Total investment amount, which is fixed.
45
+ ### gamma: float
46
+ \n Risk Aversion Coefficient.
47
+ \n Range: Risk Seeking 0-100 Very Risk Averse.
48
+ \n Divided by factor 2 as a convention, as stated in paper.
49
+ ### nu: float
50
+ \n Transaction Cost percentage, e.g., 0.01 = 1% of transaction size.
51
+ ### rho: float
52
+ \n Total investment size constraint factor, Lagrange Multiplier.
53
+ """
54
+
55
+ name: Literal["DPO"] = "DPO"
56
+ tickers: List[Union[str, int]]
57
+ mu: List[List[float]]
58
+ sigma: List[List[List[float]]]
59
+ packages: int
60
+ K: int
61
+ gamma: float
62
+ nu: float
63
+ rho: float
@@ -0,0 +1,50 @@
1
+ from typing import List, Literal
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class ExactCover(UseCase):
7
+ """
8
+ # Exact Cover
9
+
10
+ Description
11
+ -----------
12
+
13
+ Given a set _S_ and a list of subsets of _S_, an exact cover is a family _C_ of
14
+ these subsets so that all elements of _S_ are contained in exactly one subset of
15
+ _C_. For a set _S_ and a list of subsets of _S_, the Exact Cover problem tries to
16
+ find the smallest exact cover, i.e. the one that uses the least subsets.
17
+
18
+ Q-Bit Interpretation
19
+ --------------------
20
+
21
+ Subset _i_ is part of the exact cover iff. qubit _i_ is 1.
22
+
23
+ Links
24
+ -----
25
+
26
+ [Wikipedia](https://en.wikipedia.org/wiki/Exact_cover)
27
+
28
+ [Transformation](https://arxiv.org/pdf/1302.5843.pdf)
29
+
30
+ Attributes
31
+ ----------
32
+
33
+ ### subset_matrix: List[List[float]]
34
+ \n A matrix containing all subsets.
35
+ \n e.g. for the set _{1, 2, 3}_ and the subsets _{1, 2}_, _{2, 3}_, and _{3}_:
36
+ \n _[[1, 1, 0], [0, 1, 1], [0, 0, 1]]_
37
+ \n or:
38
+ \n _ExactCover.gen_subsets_matrix([1, 2, 3], [[1, 2], [2, 3], [3]])_
39
+
40
+ ### A: int
41
+ \n A constant enforcing the exact cover of the solution.
42
+
43
+ ### B: int
44
+ \n A constant (_A > nB_) helping find the smallest exact cover.
45
+ """
46
+
47
+ name: Literal["EC"] = "EC"
48
+ subset_matrix: List[List[int]]
49
+ A: int = 2
50
+ B: int = 2
@@ -0,0 +1,78 @@
1
+ from typing import List, Literal, Tuple
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class FlightGateAssignment(UseCase):
7
+ """
8
+ # Flight Gate Assignment
9
+
10
+ Description
11
+ -----------
12
+
13
+ Flight Gate Assignment is a highly relevant optimization problem in airport
14
+ management. It tries to minimize the total transit time of passengers, considering
15
+ three typical parts of passenger flow in an airport:
16
+ \n 1) After a flight, passengers claim their baggage and leave the airport.
17
+ \n 2) Other passengers switch from one plane to another to get a connecting flight.
18
+ \n 3) A third group of passengers pass the security check and leave with a flight.
19
+
20
+ Links
21
+ -----
22
+
23
+ [Description and Transformation](https://arxiv.org/pdf/1811.09465.pdf)
24
+
25
+ Attributes
26
+ ----------
27
+
28
+ ### n_flights: int
29
+ \n Number of flights.
30
+
31
+ ### n_gates: int
32
+ \n Number of gates.
33
+
34
+ ### n_passengers: List[Tuple[int, int]]
35
+ \n Number of passengers arriving and departing with each flight.
36
+ \n Example: _n_passengers[3][departure_index]_, gives us the number of
37
+ passengers departing with flight _3_.
38
+
39
+ ### time_gates: List[Tuple[float, float]]
40
+ \n The time it takes between every gate and check-in (when leaving) or the gate
41
+ and baggage claim (when arriving).
42
+ \n Example: _time_gates[0][arriving_index]_, gives us the time it takes to go
43
+ from gate _0_ to baggage claim.
44
+
45
+ ### time_flights: List[Tuple[float, float]]
46
+ \n The time at which a flight arrives/leaves.
47
+ \n Example: _time_flights[2][departure_index]_, gives us the time at which
48
+ flight 2 departs.
49
+
50
+ ### transfer_passengers: List[List[int]]
51
+ \n Matrix with the information of the passengers transferring from one flight to
52
+ another.
53
+ \n Example: _transfer_passengers[2][5]_, gives the number of passengers
54
+ transferring from flight 2 to flight 5.
55
+
56
+ ### time_between_gates: List[List[float]]
57
+ \n Gives the time it takes to go from one gate to another.
58
+
59
+ ### t_buf: float
60
+ \n Time needed for a gate to be free after a flight has departed.
61
+
62
+ ### arrival_index, departure_index: int
63
+ \n Index to subscribe the variables _time_gates_, _n_passengers_,
64
+ _time_gates_, _time_flights_.
65
+ \n One of these variables needs to be _0_, the other _1_.
66
+ """
67
+
68
+ name: Literal["FGO"] = "FGO"
69
+ n_flights: int
70
+ n_gates: int
71
+ n_passengers: List[Tuple[int, int]]
72
+ time_gates: List[Tuple[float, float]]
73
+ time_flights: List[Tuple[float, float]]
74
+ transfer_passengers: List[List[int]]
75
+ time_between_gates: List[List[float]]
76
+ t_buf: float
77
+ arrival_index: int = 0
78
+ departure_index: int = 1
@@ -0,0 +1,41 @@
1
+ from typing import Dict, Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class GraphColoring(UseCase):
9
+ """
10
+ # Graph Coloring
11
+
12
+ Description
13
+ -----------
14
+
15
+ The Graph Coloring problem tries to color the nodes of a graph with a given number
16
+ of different colors so that no adjacent nodes have the same color.
17
+
18
+ Links
19
+ -----
20
+
21
+ [Wikipedia](https://en.wikipedia.org/wiki/Graph_coloring)
22
+
23
+ [Transformation](https://arxiv.org/pdf/1811.11538.pdf)
24
+
25
+ Attributes
26
+ ----------
27
+
28
+ ### graph: Dict[int, Dict[int, Dict[str, float]]]
29
+ \n Problem graph for the graph coloring problem in form of nested dictionaries.
30
+ \n (e.g. fully connected graph with 3 nodes:
31
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
32
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
33
+
34
+ ### n_colors: int
35
+ \n Number of different colors.
36
+ """
37
+
38
+ name: Literal["GC"] = "GC"
39
+ graph: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
40
+ n_colors: int
41
+ P: int = 4
@@ -0,0 +1,53 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+ from luna_sdk.schemas.use_cases.type_aliases import NestedDictIntGraph
7
+
8
+
9
+ class GraphIsomorphism(UseCase):
10
+ """
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
+
30
+ ### graph1: Dict[int, Dict[int, Dict[str, float]]]
31
+ \n The first graph (in form of nested dictionaries) to check for isomorphism.
32
+ \n (e.g. fully connected graph with 3 nodes:
33
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
34
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
35
+
36
+ ### graph2: Dict[int, Dict[int, Dict[str, float]]]
37
+ \n The second graph (in form of nested dictionaries) to check for isomorphism.
38
+ \n (e.g. fully connected graph with 3 nodes:
39
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
40
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
41
+
42
+ ### a: float
43
+ \n A penalty value enforcing the bijectivity of the isomorphism.
44
+
45
+ ### b: float
46
+ \n A penalty value (b > a) enforcing the edge-invariance of the isomorphism.
47
+ """
48
+
49
+ name: Literal["GI"] = "GI"
50
+ graph1: NestedDictIntGraph = Field(name="graph") # type: ignore
51
+ graph2: NestedDictIntGraph = Field(name="graph") # type: ignore
52
+ a: float = 1
53
+ b: float = 2
@@ -0,0 +1,45 @@
1
+ from typing import Dict, Literal, Optional
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class GraphPartitioning(UseCase):
7
+ """
8
+ Graph Partitioning
9
+
10
+ Description
11
+ -----------
12
+
13
+ The Graph Partitioning problem tries to find two equal sized partitions for a given
14
+ undirected graph with an even number of vertices, so that the number of edges
15
+ connecting the two subsets is minimized.
16
+
17
+ Links
18
+ -----
19
+
20
+ [Transformation](https://arxiv.org/abs/1302.5843)
21
+
22
+ Attributes
23
+ ----------
24
+
25
+ ### graph : Dict[int, Dict[int, Dict[str, float]]]
26
+ \n The graph, for which the partitions are to be foundin form of nested
27
+ dictionaries.
28
+ \n (e.g. fully connected graph with 3 nodes:
29
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
30
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
31
+
32
+ ### A : Optional[int]
33
+ \n Penalty parameter A panalizes violation of the constraint that makes sure
34
+ both partitions are of equal size. It can be left "None" to be estimated from
35
+ the problem graph via the papers suggestion.
36
+
37
+ ### B : Optional[int]
38
+ \n Optimization penalty parameter B penalizes each edge connecting two nodes of
39
+ different partitions. If not given it defaults to 1.
40
+ """
41
+
42
+ name: Literal["GP"] = "GP"
43
+ graph: Dict[str, Dict[str, Dict[str, float]]]
44
+ A: Optional[int] = None
45
+ B: Optional[int] = 1
@@ -0,0 +1,48 @@
1
+ from typing import Dict, Final, Literal, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class HamiltonianCycle(UseCase):
9
+ """
10
+ # Hamiltonian Cycle
11
+
12
+ Description
13
+ -----------
14
+
15
+ The Hamiltonian Cycle problem, either for a directed or undirected graph, asks the
16
+ following: starting at an arbitrary node in the graph, can one travel along the
17
+ edges of the graph so that each graph will be visited exactly once and there is an
18
+ edge between the starting node and the last node?
19
+
20
+ Links
21
+ -----
22
+
23
+ [Wikipedia](https://en.wikipedia.org/wiki/Hamiltonian_path_problem)
24
+
25
+ [Transformation](https://arxiv.org/pdf/1302.5843.pdf)
26
+
27
+ Attributes
28
+ ----------
29
+
30
+ ### graph: Dict[int, Dict[int, Dict[str, float]]]
31
+ \n Problem graph for the hamiltonian cycle problem in form of nested
32
+ dictionaries.
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
+ ### A: Optional[float]
38
+ \n Positive penalty value which enforces that each node is visited exactly once.
39
+ \n Default: _1.0_
40
+ """
41
+
42
+ # Hamiltonian Cycle is just TSP with B = 0.
43
+
44
+ name: Literal["HC"] = "HC"
45
+ graph: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
46
+ directed: Optional[bool] = False
47
+ A: float = 1.0
48
+ B: Final[float] = 0.0
@@ -0,0 +1,49 @@
1
+ from typing import Dict, Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class InducedSubGraphIsomorphism(UseCase):
9
+ """
10
+ # Induced Subgraph Isomorphism
11
+
12
+ Description
13
+ -----------
14
+
15
+ Given two graphs the induced subgraph isomorphism problem is to decide if there
16
+ exists an edge invariant injective mapping from the vertices of the first graph to
17
+ the second graph.
18
+ The task is slightly different from the subgraph isomorphism problem, because here
19
+ additional edges present between two vertices in the second graph to which the
20
+ isomorphism maps, are prohibited.
21
+
22
+ This Implementation is heavily based on the subgraph isomorphism problem
23
+ implementation.
24
+ It uses slack variables to counterbalance unnecessary penalties.
25
+
26
+ Links
27
+ -----
28
+
29
+ [Wikipedia](https://en.wikipedia.org/wiki/Induced_subgraph_isomorphism_problem)
30
+
31
+ [Transformation](https://researchspace.auckland.ac.nz/bitstream/handle/2292/31756/CDMTCS499.pdf)
32
+
33
+ Attributes
34
+ ----------
35
+
36
+ ### graph1: Dict[int, Dict[int, Dict[str, float]]]
37
+ \n The first graph in form of nested dictionaries.
38
+ \n (e.g. fully connected graph with 3 nodes:
39
+ \n _{0: {1: {}, 2: {}}, 1: {0: {}, 2: {}}, 2: {0: {}, 1: {}}}_
40
+ \n or _networkx.to_dict_of_dicts(networkx.complete_graph(3))_ )
41
+
42
+ ### graph2: Dict[int, Dict[int, Dict[str, float]]]
43
+ \n The second graph, on which the first one is to be mapped, also in form of
44
+ nested dictionaries.
45
+ """
46
+
47
+ name: Literal["ISGI"] = "ISGI"
48
+ graph1: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
49
+ graph2: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
@@ -0,0 +1,43 @@
1
+ from typing import Dict, List, Literal, Tuple
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.use_cases.base import UseCase
6
+
7
+
8
+ class JobShopScheduling(UseCase):
9
+ """
10
+ # Job Shop Scheduling
11
+
12
+ Description
13
+ -----------
14
+
15
+ Consider a number of jobs, each of which consists of a number of operations which
16
+ have to be processed in a specific order. Each operation has a specific machine that
17
+ it needs to be processed on and only one operation in a job can be processed at a
18
+ given time. Also, each machine can only execute one job at a time. The objective of
19
+ the Job Shop Scheduling problem is to schedule all operations in a valid sequence
20
+ while minimizing the makespan of the jobs, i.e. the completion time of the last
21
+ running job.
22
+
23
+ Links
24
+ -----
25
+
26
+ [Wikipedia](https://en.wikipedia.org/wiki/Job-shop_scheduling)
27
+
28
+ [Transformation](https://arxiv.org/pdf/1506.08479.pdf)
29
+
30
+ Attributes
31
+ ----------
32
+
33
+ ### jobs: Dict[int, List[Tuple[int, int]]]
34
+ \n A dictionary containing all jobs. Each job is a list of operations and each
35
+ operation is tuple containing the machine and the processing time.
36
+
37
+ ### T: int
38
+ \n Strict upper bound when all jobs should be finished.
39
+ """
40
+
41
+ name: Literal["JSS"] = "JSS"
42
+ jobs: Dict[int, List[Tuple[int, int]]] = Field(name="dict") # type: ignore
43
+ T: int = 0
@@ -0,0 +1,48 @@
1
+ from typing import List, Literal
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class KMedoidsClustering(UseCase):
7
+ """
8
+ # K-Medoids Clustering
9
+
10
+ Description
11
+ -----------
12
+
13
+ The authors are concerned with k-medoids clustering and propose a quadratic
14
+ unconstrained binary optimization (*QUBO*) formulation of the problem of
15
+ identifying *k* medoids among *n* data points without having to cluster the data.
16
+ Given our *QUBO* formulation of this NP-hard problem, it should be possible to solve
17
+ it on adiabatic quantum computers.
18
+
19
+ Q-Bit Interpretation
20
+ --------------------
21
+
22
+ "The qubit vector at index _k_ is 1 iff. data point _k_ from the distance matrix is
23
+ chosen as medoid of a cluster. The step of assigning the remaining data points to
24
+ clusters is not covered in this problem but can be easily done in linear time with
25
+ respect to the number of data points."
26
+
27
+ Links
28
+ -----
29
+
30
+ [Transformation](http://ceur-ws.org/Vol-2454/paper_39.pdf)
31
+
32
+ Attributes
33
+ ----------
34
+
35
+ D : List[List[float]]
36
+ \n The (*n x n*) similarity matrix (diagonal elements are *1* (*one*)).
37
+
38
+ k : int
39
+ \n The number of medoids.
40
+
41
+ gamma : float
42
+ \n Penalty coefficient to enforce feasibility.
43
+ """
44
+
45
+ name: Literal["KMC"] = "KMC"
46
+ D: List[List[float]]
47
+ k: int
48
+ gamma: float
@@ -0,0 +1,55 @@
1
+ from typing import List, Literal, Optional
2
+
3
+ from luna_sdk.schemas.use_cases.base import UseCase
4
+
5
+
6
+ class KnapsackIntegerWeights(UseCase):
7
+ """
8
+ # Knapsack with Integer Weights
9
+
10
+ Description
11
+ -----------
12
+
13
+ Given a knapsack that can only carry a weight _W_ and a set of objects, each object
14
+ having a weight _w_ and a value _c_, the Knapsack with Integer Weights problem tries
15
+ to find objects so that the sum of their values is maximized while, at the same
16
+ time, the sum of their weights does not exceed the capacity of the knapsack.
17
+
18
+ Links
19
+ -----
20
+
21
+ [Description and Transformation](https://arxiv.org/pdf/1302.5843.pdf)
22
+
23
+ Attributes
24
+ ----------
25
+
26
+ ### w: List[int]
27
+ \n The weight of each object.
28
+
29
+ ### c: List[float]
30
+ \n The value of each object.
31
+
32
+ ### W: int
33
+ \n The weight that the knapsack can carry.
34
+
35
+ ### B: float
36
+ \n A positive constant to reward putting an object into the knapsack.
37
+ \n Default: _1_
38
+
39
+ ### A: Optional[float]
40
+ \n A positive penalty value, enforcing that the maximal weight will not be
41
+ exceeded. If specified, the equation _A > B _max_(c)_ must hold. If not
42
+ specified, will be computed automatically as _A = 1 + B _max_(c)_.
43
+
44
+ ### linear_encoding: bool
45
+ \n If false, the number of qubits will be highly reduced, using the log trick
46
+ from section 2.4 of the paper linked above.
47
+ """
48
+
49
+ name: Literal["KIW"] = "KIW"
50
+ w: List[int]
51
+ c: List[float]
52
+ W: int
53
+ B: float = 1.0
54
+ A: Optional[float] = None
55
+ linear_encoding: bool = False