luna-quantum 0.0.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of luna-quantum might be problematic. Click here for more details.
- luna_quantum-0.0.16.dist-info/LICENSE +201 -0
- luna_quantum-0.0.16.dist-info/METADATA +46 -0
- luna_quantum-0.0.16.dist-info/RECORD +160 -0
- luna_quantum-0.0.16.dist-info/WHEEL +4 -0
- luna_sdk/__init__.py +2 -0
- luna_sdk/constants.py +1 -0
- luna_sdk/controllers/__init__.py +2 -0
- luna_sdk/controllers/custom_login_client.py +61 -0
- luna_sdk/controllers/luna_platform_client.py +62 -0
- luna_sdk/controllers/luna_q.py +36 -0
- luna_sdk/controllers/luna_solve.py +49 -0
- luna_sdk/controllers/luna_transform.py +41 -0
- luna_sdk/error/__init__.py +0 -0
- luna_sdk/error/http_error_utils.py +100 -0
- luna_sdk/exceptions/__init__.py +1 -0
- luna_sdk/exceptions/encryption_exception.py +6 -0
- luna_sdk/exceptions/luna_exception.py +7 -0
- luna_sdk/exceptions/luna_server_exception.py +18 -0
- luna_sdk/exceptions/timeout_exception.py +10 -0
- luna_sdk/exceptions/transformation.py +11 -0
- luna_sdk/interfaces/__init__.py +5 -0
- luna_sdk/interfaces/circuit_repo_i.py +62 -0
- luna_sdk/interfaces/clients/__init__.py +0 -0
- luna_sdk/interfaces/clients/client_i.py +10 -0
- luna_sdk/interfaces/clients/luna_q_i.py +39 -0
- luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
- luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
- luna_sdk/interfaces/cplex_repo_i.py +121 -0
- luna_sdk/interfaces/info_repo_i.py +40 -0
- luna_sdk/interfaces/lp_repo_i.py +106 -0
- luna_sdk/interfaces/optimization_repo_i.py +262 -0
- luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
- luna_sdk/interfaces/repository_i.py +14 -0
- luna_sdk/interfaces/solutions_repo_i.py +219 -0
- luna_sdk/py.typed +0 -0
- luna_sdk/repositories/__init__.py +4 -0
- luna_sdk/repositories/circuit_repo.py +104 -0
- luna_sdk/repositories/cplex_repo.py +118 -0
- luna_sdk/repositories/info_repo.py +45 -0
- luna_sdk/repositories/lp_repo.py +105 -0
- luna_sdk/repositories/optimization_repo.py +358 -0
- luna_sdk/repositories/qpu_token_repo.py +226 -0
- luna_sdk/repositories/solutions_repo.py +347 -0
- luna_sdk/schemas/__init__.py +4 -0
- luna_sdk/schemas/circuit.py +43 -0
- luna_sdk/schemas/create/__init__.py +3 -0
- luna_sdk/schemas/create/circuit.py +29 -0
- luna_sdk/schemas/create/optimization.py +22 -0
- luna_sdk/schemas/create/qpu_token.py +26 -0
- luna_sdk/schemas/create/qubo.py +19 -0
- luna_sdk/schemas/create/solution.py +15 -0
- luna_sdk/schemas/enums/__init__.py +0 -0
- luna_sdk/schemas/enums/circuit.py +14 -0
- luna_sdk/schemas/enums/optimization.py +10 -0
- luna_sdk/schemas/enums/problem.py +48 -0
- luna_sdk/schemas/enums/qpu_token_type.py +6 -0
- luna_sdk/schemas/enums/solution.py +8 -0
- luna_sdk/schemas/enums/status.py +10 -0
- luna_sdk/schemas/enums/timeframe.py +11 -0
- luna_sdk/schemas/error_message.py +12 -0
- luna_sdk/schemas/optimization.py +75 -0
- luna_sdk/schemas/optimization_formats/__init__.py +0 -0
- luna_sdk/schemas/optimization_formats/bqm.py +34 -0
- luna_sdk/schemas/optimization_formats/cqm.py +127 -0
- luna_sdk/schemas/optimization_formats/lp.py +9 -0
- luna_sdk/schemas/optimization_formats/qm.py +30 -0
- luna_sdk/schemas/pretty_base.py +49 -0
- luna_sdk/schemas/qpu_token.py +60 -0
- luna_sdk/schemas/representation.py +19 -0
- luna_sdk/schemas/rest/__init__.py +0 -0
- luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
- luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
- luna_sdk/schemas/solution.py +227 -0
- luna_sdk/schemas/solver_info.py +11 -0
- luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
- luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
- luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
- luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
- luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
- luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
- luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
- luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
- luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
- luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
- luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
- luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
- luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
- luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
- luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
- luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
- luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
- luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
- luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
- luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
- luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
- luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
- luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
- luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
- luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
- luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
- luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
- luna_sdk/schemas/transformations/__init__.py +2 -0
- luna_sdk/schemas/transformations/bqm.py +33 -0
- luna_sdk/schemas/transformations/matrix.py +12 -0
- luna_sdk/schemas/use_cases/__init__.py +54 -0
- luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
- luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
- luna_sdk/schemas/use_cases/base.py +5 -0
- luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
- luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
- luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
- luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
- luna_sdk/schemas/use_cases/exact_cover.py +50 -0
- luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
- luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
- luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
- luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
- luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
- luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
- luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
- luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
- luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
- luna_sdk/schemas/use_cases/linear_regression.py +59 -0
- luna_sdk/schemas/use_cases/lmwcs.py +80 -0
- luna_sdk/schemas/use_cases/longest_path.py +49 -0
- luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
- luna_sdk/schemas/use_cases/max2sat.py +51 -0
- luna_sdk/schemas/use_cases/max3sat.py +52 -0
- luna_sdk/schemas/use_cases/max_clique.py +59 -0
- luna_sdk/schemas/use_cases/max_cut.py +47 -0
- luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
- luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
- luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
- luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
- luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
- luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
- luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
- luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
- luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
- luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
- luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
- luna_sdk/schemas/use_cases/set_cover.py +55 -0
- luna_sdk/schemas/use_cases/set_packing.py +53 -0
- luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
- luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
- luna_sdk/schemas/use_cases/subset_sum.py +36 -0
- luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
- luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
- luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
- luna_sdk/schemas/use_cases/type_aliases.py +11 -0
- luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
- luna_sdk/utils/__init__.py +0 -0
- luna_sdk/utils/qpu_tokens.py +52 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import List, Literal
|
|
2
|
+
|
|
3
|
+
from luna_sdk.schemas.use_cases.base import UseCase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TrafficFlow(UseCase):
|
|
7
|
+
"""
|
|
8
|
+
# Traffic Flow Optimization
|
|
9
|
+
|
|
10
|
+
Description
|
|
11
|
+
-----------
|
|
12
|
+
|
|
13
|
+
The Traffic Flow Optimization problem tries to minimize the total time for a given
|
|
14
|
+
set of cars to travel between their individual sources and destinations. This is
|
|
15
|
+
achieved by minimizing the number of overlapping segments between assigned routes
|
|
16
|
+
for each car.
|
|
17
|
+
|
|
18
|
+
Links
|
|
19
|
+
-----
|
|
20
|
+
|
|
21
|
+
[Description and Transformation](https://www.frontiersin.org/articles/10.3389/fict.2017.00029/full)
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
|
|
26
|
+
### car_routes: List[List[List[int]]]
|
|
27
|
+
\n The route segments of each possible route for each car.
|
|
28
|
+
\n (e.g. for two cars, where car 1 can take either route 0, 1, 2 or route 0, 3,
|
|
29
|
+
4 and car 2 can take either route 3, 0, 5 or route 6, 7, 5:
|
|
30
|
+
\n _[[[0, 1, 2], [0, 3, 4]], [[3, 0, 5], [6, 7, 5]]]_
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
name: Literal["TFO"] = "TFO"
|
|
34
|
+
car_routes: List[List[List[int]]]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from typing import Dict, Literal, Optional
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from luna_sdk.schemas.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TravellingSalesmanProblem(UseCase):
|
|
9
|
+
"""
|
|
10
|
+
# Travelling Salesman
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
The Travelling Salesman problem, either for a directed or undirected graph, asks the
|
|
16
|
+
following: given a graph, where the edges are labeled with the distances between the
|
|
17
|
+
corresponding nodes, what is the shortest possible route that visits each node
|
|
18
|
+
exactly once and returns to the origin node?
|
|
19
|
+
|
|
20
|
+
Links
|
|
21
|
+
-----
|
|
22
|
+
|
|
23
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Travelling_salesman_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 travelling salesman 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 if _None_, will be calculated with the equation: _A = B * _max_weight_ + 1_
|
|
40
|
+
\n Default: _None_
|
|
41
|
+
|
|
42
|
+
### B: Optional[float]
|
|
43
|
+
\n Positive penalty value (_B * _max_weight_) < A_) which helps find the
|
|
44
|
+
shortest route.
|
|
45
|
+
\n Default: _1.0_
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["TSP"] = "TSP"
|
|
49
|
+
graph: Dict[str, Dict[str, Dict[str, float]]] = Field(name="graph") # type: ignore
|
|
50
|
+
directed: Optional[bool] = False
|
|
51
|
+
B: Optional[float] = 1.0
|
|
52
|
+
A: Optional[float] = None
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from typing import Dict, Tuple, Union
|
|
2
|
+
|
|
3
|
+
Node = Union[int, str]
|
|
4
|
+
|
|
5
|
+
NestedDictGraph = Dict[Node, Dict[Node, Dict[str, float]]]
|
|
6
|
+
|
|
7
|
+
NestedDictIntGraph = Dict[int, Dict[int, Dict[str, float]]]
|
|
8
|
+
|
|
9
|
+
CalculusLiteral = Tuple[int, bool]
|
|
10
|
+
|
|
11
|
+
Clause = Tuple[CalculusLiteral, ...]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from typing import Dict, Literal
|
|
2
|
+
|
|
3
|
+
from luna_sdk.schemas.use_cases.base import UseCase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class WeightedMaxCut(UseCase):
|
|
7
|
+
"""
|
|
8
|
+
# Weighted Maximum Cut
|
|
9
|
+
|
|
10
|
+
Description
|
|
11
|
+
-----------
|
|
12
|
+
|
|
13
|
+
The Weighted Maximum Cut problem tries to find a cut that maximizes the weight of
|
|
14
|
+
intersecting edges in an undirected weighted graph.
|
|
15
|
+
|
|
16
|
+
Links
|
|
17
|
+
-----
|
|
18
|
+
|
|
19
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Maximum_cut)
|
|
20
|
+
|
|
21
|
+
[Transformation](https://arxiv.org/pdf/2009.05008.pdf)
|
|
22
|
+
|
|
23
|
+
Attributes
|
|
24
|
+
----------
|
|
25
|
+
|
|
26
|
+
### graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
27
|
+
\n Problem graph for the weighted maximum cut problem in form of nested
|
|
28
|
+
dictionaries.
|
|
29
|
+
\n Every edge has to have an assigned weight.
|
|
30
|
+
\n (e.g. fully connected graph with 3 nodes and edge weights:
|
|
31
|
+
\n _{0: {1: {"weight": 1}, 2: {"weight": 1}}, 1: {0: {"weight": 1},
|
|
32
|
+
2: {"weight": 1}}, 2: {0: {"weight": 1}, 1: {"weight": 1}}}_ )
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
name: Literal["WMC"] = "WMC"
|
|
36
|
+
graph: Dict[int, Dict[int, Dict[str, float]]]
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from luna_sdk.schemas import QpuToken, QpuTokenSource
|
|
4
|
+
from luna_sdk.schemas.rest.qpu_token.token_provider import (
|
|
5
|
+
RestAPITokenProvider,
|
|
6
|
+
AWSQpuTokens,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def extract_qpu_tokens_from_env() -> RestAPITokenProvider:
|
|
11
|
+
ibm_token = os.environ.get("LUNA_IBM_TOKEN")
|
|
12
|
+
dwave_token = os.environ.get("LUNA_DWAVE_TOKEN")
|
|
13
|
+
qctrl_token = os.environ.get("LUNA_QCTRL_TOKEN")
|
|
14
|
+
fujitsu_token = os.environ.get("LUNA_FUJITSU_TOKEN")
|
|
15
|
+
aws_access_key = os.environ.get("LUNA_AWS_ACCESS_KEY")
|
|
16
|
+
aws_access_secret_key = os.environ.get("LUNA_AWS_SECRET_ACCESS_KEY")
|
|
17
|
+
return RestAPITokenProvider(
|
|
18
|
+
ibm=QpuToken(
|
|
19
|
+
source=QpuTokenSource.INLINE,
|
|
20
|
+
token=ibm_token,
|
|
21
|
+
)
|
|
22
|
+
if ibm_token
|
|
23
|
+
else None,
|
|
24
|
+
dwave=QpuToken(
|
|
25
|
+
source=QpuTokenSource.INLINE,
|
|
26
|
+
token=dwave_token,
|
|
27
|
+
)
|
|
28
|
+
if dwave_token
|
|
29
|
+
else None,
|
|
30
|
+
qctrl=QpuToken(
|
|
31
|
+
source=QpuTokenSource.INLINE,
|
|
32
|
+
token=qctrl_token,
|
|
33
|
+
)
|
|
34
|
+
if qctrl_token
|
|
35
|
+
else None,
|
|
36
|
+
fujitsu=QpuToken(
|
|
37
|
+
source=QpuTokenSource.INLINE,
|
|
38
|
+
token=fujitsu_token,
|
|
39
|
+
)
|
|
40
|
+
if fujitsu_token
|
|
41
|
+
else None,
|
|
42
|
+
aws=AWSQpuTokens(
|
|
43
|
+
aws_access_key=QpuToken(
|
|
44
|
+
source=QpuTokenSource.INLINE,
|
|
45
|
+
token=aws_access_key,
|
|
46
|
+
),
|
|
47
|
+
aws_secret_access_key=QpuToken(
|
|
48
|
+
source=QpuTokenSource.INLINE,
|
|
49
|
+
token=aws_access_secret_key,
|
|
50
|
+
),
|
|
51
|
+
),
|
|
52
|
+
)
|