luna-quantum 1.0.8rc2__cp314-cp314-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.
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.cp314-win_amd64.pyd +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,371 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Literal, overload
|
|
5
|
+
|
|
6
|
+
from . import Model, Sense, Solution, Timing, Vtype
|
|
7
|
+
|
|
8
|
+
class BasePass:
|
|
9
|
+
@property
|
|
10
|
+
def name(self) -> str:
|
|
11
|
+
"""Get the name of this pass."""
|
|
12
|
+
...
|
|
13
|
+
@property
|
|
14
|
+
def requires(self) -> list[str]:
|
|
15
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
16
|
+
...
|
|
17
|
+
|
|
18
|
+
class Pipeline(BasePass):
|
|
19
|
+
@overload
|
|
20
|
+
def __init__(self, passes: list[BasePass]) -> None: ...
|
|
21
|
+
@overload
|
|
22
|
+
def __init__(self, passes: list[BasePass], name: str) -> None: ...
|
|
23
|
+
def __init__(self, passes: list[BasePass], name: str | None = ...) -> None: ...
|
|
24
|
+
@property
|
|
25
|
+
def name(self) -> str:
|
|
26
|
+
"""Get the name of this pass."""
|
|
27
|
+
...
|
|
28
|
+
@property
|
|
29
|
+
def requires(self) -> list[str]:
|
|
30
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def satisfies(self) -> set[str]:
|
|
35
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
def add(self, new_pass: BasePass) -> None:
|
|
39
|
+
"""Add new pass to pipeline."""
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
def clear(self) -> None:
|
|
43
|
+
"""Clear pipeline."""
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def passes(self) -> list[BasePass]:
|
|
48
|
+
"""Get all passes that are part of the pipeline."""
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
def __len__(self) -> int: ...
|
|
52
|
+
|
|
53
|
+
class IfElsePass(BasePass):
|
|
54
|
+
@overload
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
requires: list[str],
|
|
58
|
+
condition: Callable[[AnalysisCache], bool],
|
|
59
|
+
then: Pipeline,
|
|
60
|
+
otherwise: Pipeline,
|
|
61
|
+
) -> None: ...
|
|
62
|
+
@overload
|
|
63
|
+
def __init__(
|
|
64
|
+
self,
|
|
65
|
+
requires: list[str],
|
|
66
|
+
condition: Callable[[AnalysisCache], bool],
|
|
67
|
+
then: Pipeline,
|
|
68
|
+
otherwise: Pipeline,
|
|
69
|
+
name: str,
|
|
70
|
+
) -> None: ...
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
requires: list[str],
|
|
74
|
+
condition: Callable[[AnalysisCache], bool],
|
|
75
|
+
then: Pipeline,
|
|
76
|
+
otherwise: Pipeline,
|
|
77
|
+
name: str | None = ...,
|
|
78
|
+
) -> None: ...
|
|
79
|
+
@property
|
|
80
|
+
def name(self) -> str:
|
|
81
|
+
"""Get the name of this pass."""
|
|
82
|
+
...
|
|
83
|
+
@property
|
|
84
|
+
def requires(self) -> list[str]:
|
|
85
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
86
|
+
...
|
|
87
|
+
|
|
88
|
+
class TransformationPass(BasePass):
|
|
89
|
+
@property
|
|
90
|
+
@abstractmethod
|
|
91
|
+
def name(self) -> str:
|
|
92
|
+
"""Get the name of this pass."""
|
|
93
|
+
...
|
|
94
|
+
@property
|
|
95
|
+
def requires(self) -> list[str]:
|
|
96
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
97
|
+
...
|
|
98
|
+
@property
|
|
99
|
+
def invalidates(self) -> list[str]:
|
|
100
|
+
"""Get a list of passes that are invalidated by this pass."""
|
|
101
|
+
...
|
|
102
|
+
@abstractmethod
|
|
103
|
+
def run(
|
|
104
|
+
self, model: Model, cache: AnalysisCache
|
|
105
|
+
) -> (
|
|
106
|
+
TransformationOutcome | tuple[Model, ActionType] | tuple[Model, ActionType, Any]
|
|
107
|
+
):
|
|
108
|
+
"""Run/Execute this transformation pass."""
|
|
109
|
+
...
|
|
110
|
+
@abstractmethod
|
|
111
|
+
def backwards(self, solution: Solution, cache: AnalysisCache) -> Solution:
|
|
112
|
+
"""Convert a solution back to fit this pass' input.
|
|
113
|
+
|
|
114
|
+
Convert a solution from a representation fitting this pass' output to
|
|
115
|
+
a solution representation fitting this pass' input.
|
|
116
|
+
"""
|
|
117
|
+
...
|
|
118
|
+
|
|
119
|
+
class TransformationOutcome:
|
|
120
|
+
"""Output object for transformation pass."""
|
|
121
|
+
|
|
122
|
+
model: Model
|
|
123
|
+
action: ActionType
|
|
124
|
+
analysis: ...
|
|
125
|
+
|
|
126
|
+
@overload
|
|
127
|
+
def __init__(self, model: Model, action: ActionType) -> None: ...
|
|
128
|
+
@overload
|
|
129
|
+
def __init__(self, model: Model, action: ActionType, analysis: object) -> None: ...
|
|
130
|
+
def __init__(
|
|
131
|
+
self, model: Model, action: ActionType, analysis: object | None = ...
|
|
132
|
+
) -> None: ...
|
|
133
|
+
@staticmethod
|
|
134
|
+
def nothing(model: Model) -> TransformationOutcome:
|
|
135
|
+
"""Easy nothing action return."""
|
|
136
|
+
...
|
|
137
|
+
|
|
138
|
+
class AnalysisCache:
|
|
139
|
+
@overload
|
|
140
|
+
def __getitem__( # type: ignore[reportOverlappingOverload]
|
|
141
|
+
self, key: Literal["max-bias"]
|
|
142
|
+
) -> MaxBias: ...
|
|
143
|
+
@overload
|
|
144
|
+
def __getitem__(self, key: str) -> ...: ...
|
|
145
|
+
def __getitem__(self, key: str) -> Any:
|
|
146
|
+
"""Get the analysis result for a specific analysis pass."""
|
|
147
|
+
...
|
|
148
|
+
|
|
149
|
+
class AnalysisPass(BasePass):
|
|
150
|
+
@property
|
|
151
|
+
@abstractmethod
|
|
152
|
+
def name(self) -> str:
|
|
153
|
+
"""Get the name of this pass."""
|
|
154
|
+
...
|
|
155
|
+
@property
|
|
156
|
+
def requires(self) -> list[str]:
|
|
157
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
158
|
+
...
|
|
159
|
+
@abstractmethod
|
|
160
|
+
def run(self, model: Model, cache: AnalysisCache) -> ...:
|
|
161
|
+
"""Run/Execute this analysis pass."""
|
|
162
|
+
...
|
|
163
|
+
|
|
164
|
+
class MetaAnalysisPass(BasePass):
|
|
165
|
+
@property
|
|
166
|
+
@abstractmethod
|
|
167
|
+
def name(self) -> str:
|
|
168
|
+
"""Get the name of this pass."""
|
|
169
|
+
...
|
|
170
|
+
@property
|
|
171
|
+
def requires(self) -> list[str]:
|
|
172
|
+
"""Get a list of required passes that need to be run before this pass."""
|
|
173
|
+
...
|
|
174
|
+
@abstractmethod
|
|
175
|
+
def run(self, passes: list[BasePass], cache: AnalysisCache) -> ...:
|
|
176
|
+
"""Run/Execute this analysis pass."""
|
|
177
|
+
...
|
|
178
|
+
|
|
179
|
+
class ActionType(Enum):
|
|
180
|
+
DidTransform = ...
|
|
181
|
+
"""Indicate that the pass did transform the model."""
|
|
182
|
+
DidAnalysis = ...
|
|
183
|
+
"""Indicate that the pass did analyse the model."""
|
|
184
|
+
DidAnalysisTransform = ...
|
|
185
|
+
"""Indicate that the pass did analyse and transfrom the model."""
|
|
186
|
+
DidNothing = ...
|
|
187
|
+
"""Indicate that the pass did NOT do anything."""
|
|
188
|
+
|
|
189
|
+
class ChangeSensePass(BasePass):
|
|
190
|
+
"""A transformation pass to change the model's Sense to a target Sense."""
|
|
191
|
+
|
|
192
|
+
def __init__(self, sense: Sense) -> None:
|
|
193
|
+
"""Transform the model's Sense to a target Sense.
|
|
194
|
+
|
|
195
|
+
Parameters
|
|
196
|
+
----------
|
|
197
|
+
sense : Sense
|
|
198
|
+
The target sense of the model after calling the `run` method on it.
|
|
199
|
+
"""
|
|
200
|
+
...
|
|
201
|
+
@property
|
|
202
|
+
def sense(self) -> Sense:
|
|
203
|
+
"""Get the specified target sense of this pass."""
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
class MaxBias:
|
|
207
|
+
"""An analysis pass result storing the max bias (coefficient) of a model."""
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def val(self) -> float:
|
|
211
|
+
"""Get the value of the maxium bias."""
|
|
212
|
+
...
|
|
213
|
+
|
|
214
|
+
class MaxBiasAnalysis(BasePass):
|
|
215
|
+
"""An analysis pass computing the maximum bias contained in the model."""
|
|
216
|
+
|
|
217
|
+
def __init__(self) -> None: ...
|
|
218
|
+
|
|
219
|
+
class BinarySpinPass(BasePass):
|
|
220
|
+
"""An transformation pass changing the binary/spin variables to spin/binary."""
|
|
221
|
+
|
|
222
|
+
def __init__(
|
|
223
|
+
self, vtype: Literal[Vtype.Binary, Vtype.Spin], prefix: str | None
|
|
224
|
+
) -> None: ...
|
|
225
|
+
@property
|
|
226
|
+
def vtype(self) -> Vtype:
|
|
227
|
+
"""Get the target vtype."""
|
|
228
|
+
...
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def prefix(self) -> str | None:
|
|
232
|
+
"""Get the naming prefix."""
|
|
233
|
+
...
|
|
234
|
+
|
|
235
|
+
class BinarySpinInfo:
|
|
236
|
+
@property
|
|
237
|
+
def old_vtype(self) -> Vtype:
|
|
238
|
+
"""Get the source vtype."""
|
|
239
|
+
...
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def new_vtype(self) -> Vtype:
|
|
243
|
+
"""Get the variable name mapping."""
|
|
244
|
+
...
|
|
245
|
+
|
|
246
|
+
class LogElement:
|
|
247
|
+
"""An element of the execution log of an intermediate representation (IR)."""
|
|
248
|
+
|
|
249
|
+
@property
|
|
250
|
+
def pass_name(self) -> str:
|
|
251
|
+
"""The name of the pass."""
|
|
252
|
+
...
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def timing(self) -> Timing:
|
|
256
|
+
"""Timing information for this log element."""
|
|
257
|
+
...
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def kind(self) -> ActionType | None:
|
|
261
|
+
"""Transformation type information for this log element, if available."""
|
|
262
|
+
...
|
|
263
|
+
|
|
264
|
+
# @property
|
|
265
|
+
# def components(self) -> list[LogElement] | None:
|
|
266
|
+
# """Components of this log-element."""
|
|
267
|
+
# ...
|
|
268
|
+
|
|
269
|
+
class IR:
|
|
270
|
+
"""The intermediate representation (IR) of a model after transformation.
|
|
271
|
+
|
|
272
|
+
The IR contains the resulting model after transformation (`ir.model`) as well
|
|
273
|
+
as the analysis cache (`ir.cache`) and an execution log (`ir.execution_log`).
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def model(self) -> Model:
|
|
278
|
+
"""Get the model stored in the IR."""
|
|
279
|
+
...
|
|
280
|
+
|
|
281
|
+
@property
|
|
282
|
+
def cache(self) -> AnalysisCache:
|
|
283
|
+
"""Get the analysis cache stored the IR."""
|
|
284
|
+
...
|
|
285
|
+
|
|
286
|
+
@property
|
|
287
|
+
def execution_log(self) -> list[LogElement]:
|
|
288
|
+
"""Get the analysis cache stored the IR."""
|
|
289
|
+
...
|
|
290
|
+
|
|
291
|
+
class PassManager:
|
|
292
|
+
"""Manage and execute a sequence of passes on a model.
|
|
293
|
+
|
|
294
|
+
The PassManager implements a compiler-style pass pattern, enabling both
|
|
295
|
+
general-purpose and algorithm-specific manipulations of optimization
|
|
296
|
+
models. Each pass is an atomic operation (for example, ChangeSensePass)
|
|
297
|
+
that transforms the model or its intermediate representation (IR). The
|
|
298
|
+
PassManager runs each pass in order and produces a rich IR that records
|
|
299
|
+
the transformations applied and supports back-transformations.
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
def __init__(
|
|
303
|
+
self, passes: list[BasePass | TransformationPass | AnalysisPass] | None = ...
|
|
304
|
+
) -> None:
|
|
305
|
+
"""Manage and execute a sequence of passes on a model.
|
|
306
|
+
|
|
307
|
+
The PassManager implements a compiler-style pass pattern, enabling both
|
|
308
|
+
general-purpose and algorithm-specific manipulations of optimization
|
|
309
|
+
models. Each pass is an atomic operation (for example, ChangeSensePass)
|
|
310
|
+
that transforms the model or its intermediate representation (IR). The
|
|
311
|
+
PassManager runs each pass in order and produces a rich IR that records
|
|
312
|
+
the transformations applied and supports back-transformations.
|
|
313
|
+
|
|
314
|
+
Parameters
|
|
315
|
+
----------
|
|
316
|
+
passes : list[TransformationPass | AnalysisPass] | None
|
|
317
|
+
An ordered sequence of Pass instances to apply. Each Pass must conform to
|
|
318
|
+
the `TransformationPass` or `AnalysisPass` interface, default None.
|
|
319
|
+
"""
|
|
320
|
+
...
|
|
321
|
+
|
|
322
|
+
def run(self, model: Model) -> IR:
|
|
323
|
+
"""Apply all configures passes.
|
|
324
|
+
|
|
325
|
+
Apply all configured passes to the given model and return the
|
|
326
|
+
resulting intermediate representation.
|
|
327
|
+
|
|
328
|
+
Parameters
|
|
329
|
+
----------
|
|
330
|
+
model : Model
|
|
331
|
+
The model to be transformed.
|
|
332
|
+
|
|
333
|
+
Returns
|
|
334
|
+
-------
|
|
335
|
+
IR
|
|
336
|
+
The intermediate representation of the model after transformation.
|
|
337
|
+
"""
|
|
338
|
+
...
|
|
339
|
+
|
|
340
|
+
def backwards(self, solution: Solution, ir: IR) -> Solution:
|
|
341
|
+
"""Apply the back transformation to the given solution.
|
|
342
|
+
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
solution : Solution
|
|
346
|
+
The solution to transform back to a representation fitting the original
|
|
347
|
+
(input) model of this `PassManager`.
|
|
348
|
+
ir : IR
|
|
349
|
+
The intermediate representation (IR) resulted from the `run` call.
|
|
350
|
+
|
|
351
|
+
Returns
|
|
352
|
+
-------
|
|
353
|
+
Solution
|
|
354
|
+
A solution object representing a solution to the original problem passed
|
|
355
|
+
to this `PassManager`'s run method.
|
|
356
|
+
"""
|
|
357
|
+
...
|
|
358
|
+
|
|
359
|
+
__all__ = [
|
|
360
|
+
"IR",
|
|
361
|
+
"ActionType",
|
|
362
|
+
"AnalysisCache",
|
|
363
|
+
"AnalysisPass",
|
|
364
|
+
"BasePass",
|
|
365
|
+
"ChangeSensePass",
|
|
366
|
+
"LogElement",
|
|
367
|
+
"MaxBias",
|
|
368
|
+
"MaxBiasAnalysis",
|
|
369
|
+
"PassManager",
|
|
370
|
+
"TransformationPass",
|
|
371
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Translator collection.
|
|
2
|
+
|
|
3
|
+
The `translator` module provides a collection of translators for converting between
|
|
4
|
+
various formats related to optimization problems and their solutions.
|
|
5
|
+
|
|
6
|
+
Translators are categorized into two main groups:
|
|
7
|
+
|
|
8
|
+
1. **Model Translators**: These handle conversions *to* and *from* the internal `Model`
|
|
9
|
+
representation. They enable interoperability between external formats
|
|
10
|
+
(e.g., QUBO, LP) and the standardized internal model format used within the system.
|
|
11
|
+
|
|
12
|
+
2. **Solution Translators**: These support conversion *from* external solution formats
|
|
13
|
+
into the internal `Solution` representation. This enables solutions generated by
|
|
14
|
+
different solvers or formats to be interpreted and processed consistently within
|
|
15
|
+
the system. Note that these translators do not support conversion *from* the internal
|
|
16
|
+
solution to external formats.
|
|
17
|
+
|
|
18
|
+
Each translator encapsulates the logic needed for bidirectional format conversion,
|
|
19
|
+
ensuring consistency and modularity when integrating with diverse optimization
|
|
20
|
+
frameworks and solvers.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from ._core.translator import * # type: ignore[reportMissingImports] # noqa: F403
|