luna-quantum 1.1.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- luna_quantum/__init__.py +139 -0
- luna_quantum/__init__.pyi +98 -0
- luna_quantum/_core.cp312-win_amd64.pyd +0 -0
- luna_quantum/_core.pyi +4286 -0
- luna_quantum/_utility.py +148 -0
- luna_quantum/_utility.pyi +20 -0
- luna_quantum/algorithms/__init__.py +1 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -0
- luna_quantum/backends/__init__.py +1 -0
- luna_quantum/client/__init__.py +0 -0
- luna_quantum/client/controllers/__init__.py +4 -0
- luna_quantum/client/controllers/luna_http_client.py +37 -0
- luna_quantum/client/controllers/luna_platform_client.py +256 -0
- luna_quantum/client/controllers/luna_q.py +67 -0
- luna_quantum/client/controllers/luna_solve.py +129 -0
- luna_quantum/client/error/__init__.py +0 -0
- luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
- luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
- luna_quantum/client/error/luna_error.py +2 -0
- luna_quantum/client/error/luna_server_error.py +20 -0
- luna_quantum/client/error/timeout_error.py +12 -0
- luna_quantum/client/error/transformation_error.py +18 -0
- luna_quantum/client/error/utils/__init__.py +0 -0
- luna_quantum/client/error/utils/http_error_utils.py +112 -0
- luna_quantum/client/interfaces/__init__.py +4 -0
- luna_quantum/client/interfaces/clients/__init__.py +25 -0
- luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
- luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
- luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
- luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
- luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
- luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
- luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
- luna_quantum/client/interfaces/services/__init__.py +0 -0
- luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
- luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
- luna_quantum/client/interfaces/services/service_i.py +56 -0
- luna_quantum/client/rest_client/__init__.py +15 -0
- luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
- luna_quantum/client/rest_client/info_rest_client.py +74 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
- luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
- luna_quantum/client/rest_client/users_rest_client.py +35 -0
- luna_quantum/client/schemas/__init__.py +26 -0
- luna_quantum/client/schemas/circuit.py +48 -0
- luna_quantum/client/schemas/create/__init__.py +15 -0
- luna_quantum/client/schemas/create/circuit.py +30 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +22 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
- luna_quantum/client/schemas/create/qubo.py +19 -0
- luna_quantum/client/schemas/create/solve_job_create.py +43 -0
- luna_quantum/client/schemas/enums/__init__.py +0 -0
- luna_quantum/client/schemas/enums/call_style.py +13 -0
- luna_quantum/client/schemas/enums/circuit.py +42 -0
- luna_quantum/client/schemas/enums/model_format.py +11 -0
- luna_quantum/client/schemas/enums/problem.py +50 -0
- luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
- luna_quantum/client/schemas/enums/sense.py +8 -0
- luna_quantum/client/schemas/enums/status.py +40 -0
- luna_quantum/client/schemas/enums/timeframe.py +11 -0
- luna_quantum/client/schemas/error_message.py +14 -0
- luna_quantum/client/schemas/model_metadata.py +35 -0
- luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
- luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +50 -0
- luna_quantum/client/schemas/solver_info.py +11 -0
- luna_quantum/client/schemas/user.py +11 -0
- luna_quantum/client/schemas/wrappers/__init__.py +5 -0
- luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
- luna_quantum/client/utils/__init__.py +0 -0
- luna_quantum/client/utils/qpu_token_utils.py +147 -0
- luna_quantum/config.py +11 -0
- luna_quantum/decorators.py +248 -0
- luna_quantum/errors.py +34 -0
- luna_quantum/errors.pyi +287 -0
- luna_quantum/exceptions/__init__.py +0 -0
- luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
- luna_quantum/exceptions/luna_quantum_call_type_error.py +9 -0
- luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
- luna_quantum/factories/__init__.py +4 -0
- luna_quantum/factories/luna_solve_client_factory.py +100 -0
- luna_quantum/factories/usecase_factory.py +489 -0
- luna_quantum/py.typed +0 -0
- luna_quantum/solve/__init__.py +13 -0
- luna_quantum/solve/default_token.py +304 -0
- luna_quantum/solve/domain/__init__.py +0 -0
- luna_quantum/solve/domain/abstract/__init__.py +4 -0
- luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +56 -0
- luna_quantum/solve/domain/solve_job.py +230 -0
- luna_quantum/solve/errors/__init__.py +0 -0
- luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
- luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
- luna_quantum/solve/errors/solve_base_error.py +5 -0
- luna_quantum/solve/errors/token_missing_error.py +11 -0
- luna_quantum/solve/interfaces/__init__.py +0 -0
- luna_quantum/solve/interfaces/algorithm_i.py +49 -0
- luna_quantum/solve/interfaces/backend_i.py +28 -0
- luna_quantum/solve/interfaces/usecases/__init__.py +59 -0
- luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
- luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
- luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
- luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_by_id_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
- luna_quantum/solve/parameters/__init__.py +0 -0
- luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
- luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
- luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
- luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
- luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
- luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +10 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/__init__.py +29 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/config.py +58 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/flexqaoa.py +188 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/optimizers.py +53 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flexqaoa/pipeline.py +164 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +112 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
- luna_quantum/solve/parameters/backends/__init__.py +27 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aqarios_gpu.py +17 -0
- luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
- luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
- luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
- luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
- luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
- luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
- luna_quantum/solve/parameters/backends/cudaq/__init__.py +5 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_base.py +16 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_cpu.py +30 -0
- luna_quantum/solve/parameters/backends/cudaq/cudaq_gpu.py +32 -0
- luna_quantum/solve/parameters/backends/dwave.py +17 -0
- luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
- luna_quantum/solve/parameters/backends/fda.py +17 -0
- luna_quantum/solve/parameters/backends/ibm.py +138 -0
- luna_quantum/solve/parameters/backends/qctrl.py +103 -0
- luna_quantum/solve/parameters/backends/zib.py +17 -0
- luna_quantum/solve/parameters/constants.py +11 -0
- luna_quantum/solve/parameters/errors.py +30 -0
- luna_quantum/solve/parameters/mixins/__init__.py +0 -0
- luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
- luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
- luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
- luna_quantum/solve/use_cases/__init__.py +119 -0
- luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
- luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
- luna_quantum/solve/use_cases/base.py +7 -0
- luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
- luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
- luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
- luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
- luna_quantum/solve/use_cases/exact_cover.py +51 -0
- luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
- luna_quantum/solve/use_cases/graph_coloring.py +42 -0
- luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
- luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
- luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
- luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
- luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
- luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
- luna_quantum/solve/use_cases/linear_regression.py +60 -0
- luna_quantum/solve/use_cases/lmwcs.py +84 -0
- luna_quantum/solve/use_cases/longest_path.py +50 -0
- luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
- luna_quantum/solve/use_cases/max2sat.py +54 -0
- luna_quantum/solve/use_cases/max3sat.py +55 -0
- luna_quantum/solve/use_cases/max_clique.py +60 -0
- luna_quantum/solve/use_cases/max_cut.py +48 -0
- luna_quantum/solve/use_cases/max_independent_set.py +37 -0
- luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
- luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
- luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
- luna_quantum/solve/use_cases/number_partitioning.py +32 -0
- luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
- luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
- luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
- luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
- luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
- luna_quantum/solve/use_cases/sensor_placement.py +58 -0
- luna_quantum/solve/use_cases/set_cover.py +56 -0
- luna_quantum/solve/use_cases/set_packing.py +54 -0
- luna_quantum/solve/use_cases/set_partitioning.py +52 -0
- luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
- luna_quantum/solve/use_cases/subset_sum.py +37 -0
- luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
- luna_quantum/solve/use_cases/traffic_flow.py +35 -0
- luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
- luna_quantum/solve/use_cases/type_aliases.py +9 -0
- luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
- luna_quantum/solve/usecases/__init__.py +45 -0
- luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
- luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
- luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
- luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
- luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
- luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
- luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
- luna_quantum/solve/usecases/model_save_usecase.py +63 -0
- luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
- luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
- luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
- luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
- luna_quantum/solve/usecases/solve_job_get_by_id_usecase.py +44 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +105 -0
- luna_quantum/transformations.py +18 -0
- luna_quantum/transformations.pyi +371 -0
- luna_quantum/translator.py +23 -0
- luna_quantum/translator.pyi +869 -0
- luna_quantum/util/__init__.py +0 -0
- luna_quantum/util/active_waiting.py +79 -0
- luna_quantum/util/class_patcher.py +164 -0
- luna_quantum/util/debug_info.py +52 -0
- luna_quantum/util/log_utils.py +187 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +3 -0
- luna_quantum/utils.pyi +67 -0
- luna_quantum-1.1.0.dist-info/METADATA +36 -0
- luna_quantum-1.1.0.dist-info/RECORD +276 -0
- luna_quantum-1.1.0.dist-info/WHEEL +4 -0
- luna_quantum-1.1.0.dist-info/licenses/LICENSE +176 -0
- luna_quantum-1.1.0.dist-info/licenses/NOTICE +13 -0
luna_quantum/errors.pyi
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
class VariableOutOfRangeError(Exception):
|
|
2
|
+
"""Referenced variable is out of bounds for the environment.
|
|
3
|
+
|
|
4
|
+
Raised when a variable referenced in an expression is out of bounds for the
|
|
5
|
+
environment.
|
|
6
|
+
|
|
7
|
+
This error typically occurs when querying coefficients (linear, quadratic,
|
|
8
|
+
or higher-order) from an `Expression` using a `Variable` whose index does not
|
|
9
|
+
exist in the environment's internal registry.
|
|
10
|
+
|
|
11
|
+
This may happen if:
|
|
12
|
+
- A variable is used from a different environment
|
|
13
|
+
- A variable was removed or never registered properly
|
|
14
|
+
- A raw index or tuple refers to a non-existent variable ID
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __str__(self, /) -> str: ...
|
|
18
|
+
|
|
19
|
+
class VariableExistsError(Exception):
|
|
20
|
+
"""
|
|
21
|
+
Raised when trying to create a variable with a name that already exists.
|
|
22
|
+
|
|
23
|
+
Variable names must be unique within an `Environment`. Attempting to redefine
|
|
24
|
+
a variable with the same name will raise this exception.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __str__(self, /) -> str: ...
|
|
28
|
+
|
|
29
|
+
class VariableNotExistingError(Exception):
|
|
30
|
+
"""Raised when trying to get a variable with a name that does not exist."""
|
|
31
|
+
|
|
32
|
+
def __str__(self, /) -> str: ...
|
|
33
|
+
|
|
34
|
+
class VariableCreationError(Exception):
|
|
35
|
+
"""
|
|
36
|
+
Raised when an error occurs during the creation of a variable.
|
|
37
|
+
|
|
38
|
+
For example, binary and spin variables cannot be created with bounds.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __str__(self, /) -> str: ...
|
|
42
|
+
|
|
43
|
+
class VariablesFromDifferentEnvsError(Exception):
|
|
44
|
+
"""
|
|
45
|
+
Raised when multiple variables from different environments are used together.
|
|
46
|
+
|
|
47
|
+
All variables in an expression or constraint must belong to the same
|
|
48
|
+
`Environment`. Mixing across environments is disallowed to ensure consistency.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __str__(self, /) -> str: ...
|
|
52
|
+
|
|
53
|
+
class DifferentEnvsError(Exception):
|
|
54
|
+
"""
|
|
55
|
+
Raised when two incompatible environments are passed to a model or operation.
|
|
56
|
+
|
|
57
|
+
Unlike `VariablesFromDifferentEnvsError`, this error may occur at the model level
|
|
58
|
+
or in structural operations that require consistency across multiple environments.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __str__(self, /) -> str: ...
|
|
62
|
+
|
|
63
|
+
class NoActiveEnvironmentFoundError(Exception):
|
|
64
|
+
"""Variable or Expression created without an environment (or context).
|
|
65
|
+
|
|
66
|
+
Raised when a variable or expression is created without an active environment
|
|
67
|
+
context.
|
|
68
|
+
|
|
69
|
+
This typically happens when not using `with Environment(): ...` and no environment
|
|
70
|
+
was explicitly provided.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
def __str__(self, /) -> str: ...
|
|
74
|
+
|
|
75
|
+
class MultipleActiveEnvironmentsError(Exception):
|
|
76
|
+
"""
|
|
77
|
+
Raised when multiple environments are active simultaneously.
|
|
78
|
+
|
|
79
|
+
This is a logic error, since `aqmodels` only supports one active environment
|
|
80
|
+
at a time. This is enforced to maintain clarity and safety.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
def __str__(self, /) -> str: ...
|
|
84
|
+
|
|
85
|
+
class DecodeError(Exception):
|
|
86
|
+
"""
|
|
87
|
+
Raised when decoding or deserialization of binary data fails.
|
|
88
|
+
|
|
89
|
+
This can occur if the encoded data is corrupted, incompatible, or not generated
|
|
90
|
+
by `aqmodels.encode()`.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
def __str__(self, /) -> str: ...
|
|
94
|
+
|
|
95
|
+
class VariableNamesError(Exception):
|
|
96
|
+
"""The provided variable names are invalid.
|
|
97
|
+
|
|
98
|
+
Raised when the QuboTranslator tries to create a model from a QUBO matrix, but
|
|
99
|
+
the provided variable names are invalid.
|
|
100
|
+
|
|
101
|
+
If variable names are provided to the QuboTranslator, they have to be unique, and
|
|
102
|
+
the number of names has to match the number of variables in the QUBO matrix.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
def __str__(self, /) -> str: ...
|
|
106
|
+
|
|
107
|
+
class IllegalConstraintNameError(Exception):
|
|
108
|
+
"""Raised when a constraint is tried to be created with an illegal name."""
|
|
109
|
+
|
|
110
|
+
def __str__(self, /) -> str: ...
|
|
111
|
+
|
|
112
|
+
class TranslationError(Exception):
|
|
113
|
+
"""Raised when an error occurred during translation."""
|
|
114
|
+
|
|
115
|
+
def __str__(self, /) -> str: ...
|
|
116
|
+
|
|
117
|
+
class ModelNotQuadraticError(TranslationError):
|
|
118
|
+
"""
|
|
119
|
+
Raised when a model is expected to be quadratic but contains higher-order terms.
|
|
120
|
+
|
|
121
|
+
Some solvers or transformations require the model to have at most quadratic
|
|
122
|
+
expressions. This error signals that unsupported terms were detected.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
def __str__(self, /) -> str: ...
|
|
126
|
+
|
|
127
|
+
class ModelNotUnconstrainedError(TranslationError):
|
|
128
|
+
"""Operation requires an unconstrained model.
|
|
129
|
+
|
|
130
|
+
Raised when an operation requires an unconstrained model, but constraints are
|
|
131
|
+
present.
|
|
132
|
+
|
|
133
|
+
Some solution methods may only work on unconstrained models, such as when
|
|
134
|
+
transforming a symbolic model to a low-level format.
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
def __str__(self, /) -> str: ...
|
|
138
|
+
|
|
139
|
+
class ModelSenseNotMinimizeError(TranslationError):
|
|
140
|
+
"""Operation requires a model for minimization.
|
|
141
|
+
|
|
142
|
+
Raised when an operation requires a model with minimization sense, but has
|
|
143
|
+
maximization sense.
|
|
144
|
+
|
|
145
|
+
Some model formats only work with minimization sense. In this case, consider
|
|
146
|
+
setting the sense to `minimize` before the transformation, and multiplying the
|
|
147
|
+
objective by `-1` if necessary.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
def __str__(self, /) -> str: ...
|
|
151
|
+
|
|
152
|
+
class ModelVtypeError(TranslationError):
|
|
153
|
+
"""Operation has constraints on model's variable types.
|
|
154
|
+
|
|
155
|
+
Raised when an operation has certain constraints on a model's variable types that
|
|
156
|
+
are violated.
|
|
157
|
+
|
|
158
|
+
Some solution methods may only work on models where all variables have the same
|
|
159
|
+
type, or where only certain variable types are permitted.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
def __str__(self, /) -> str: ...
|
|
163
|
+
|
|
164
|
+
class SolutionTranslationError(Exception):
|
|
165
|
+
"""
|
|
166
|
+
Raised when something goes wrong during the translation of a solution.
|
|
167
|
+
|
|
168
|
+
This may happen during the translation to an AqSolution from a different solution
|
|
169
|
+
format, e.g., when the samples have different lengths or the variable types are not
|
|
170
|
+
consistent with the model the solution is created for.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
def __str__(self, /) -> str: ...
|
|
174
|
+
|
|
175
|
+
class SampleIncorrectLengthError(SolutionTranslationError):
|
|
176
|
+
"""
|
|
177
|
+
Raised when a sample length is different from the number of model variables.
|
|
178
|
+
|
|
179
|
+
When an external solution format is translated to an AqSolution, the number of
|
|
180
|
+
variable assignments in the solution's sample has to exactly match the number of
|
|
181
|
+
variables in the model environment that is passed to the translator.
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
def __str__(self, /) -> str: ...
|
|
185
|
+
|
|
186
|
+
class SampleUnexpectedVariableError(SolutionTranslationError):
|
|
187
|
+
"""Variable not present in environment.
|
|
188
|
+
|
|
189
|
+
Raised when a sample contains a variable with a name that is not present in the
|
|
190
|
+
environment.
|
|
191
|
+
|
|
192
|
+
When a sample is translated to an AqResult, the currently active environment has to
|
|
193
|
+
contain the same variables as the sample.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
def __str__(self, /) -> str: ...
|
|
197
|
+
|
|
198
|
+
class SampleIncompatibleVtypeError(SolutionTranslationError):
|
|
199
|
+
"""A sample's assignments have incompatible vtypes.
|
|
200
|
+
|
|
201
|
+
Raised when a sample's assignments have variable types incompatible with the
|
|
202
|
+
model's variable types.
|
|
203
|
+
|
|
204
|
+
When an external solution format is translated to an AqSolution, the variable
|
|
205
|
+
assignments are tried to be converted into the model's corresponding variable type.
|
|
206
|
+
This may fail when the assignment types are incompatible.
|
|
207
|
+
|
|
208
|
+
Note that conversions with precision loss or truncation are admitted, but
|
|
209
|
+
conversions of variables outside the permitted range will fail.
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
def __str__(self, /) -> str: ...
|
|
213
|
+
|
|
214
|
+
class ComputationError(Exception):
|
|
215
|
+
"""Raised when an error occured in an internal computation."""
|
|
216
|
+
|
|
217
|
+
def __str__(self, /) -> str: ...
|
|
218
|
+
|
|
219
|
+
class EvaluationError(Exception):
|
|
220
|
+
"""Raised when an error occured during evaluation of a model."""
|
|
221
|
+
|
|
222
|
+
def __str__(self, /) -> str: ...
|
|
223
|
+
|
|
224
|
+
class DuplicateConstraintNameError(Exception):
|
|
225
|
+
"""Raised when a duplicate constraint name is used."""
|
|
226
|
+
|
|
227
|
+
def __str__(self, /) -> str: ...
|
|
228
|
+
|
|
229
|
+
class CompilationError(RuntimeError):
|
|
230
|
+
"""Raised when an error occured during compilation of a model in the PassManager."""
|
|
231
|
+
|
|
232
|
+
def __str__(self, /) -> str: ...
|
|
233
|
+
|
|
234
|
+
class StartCannotBeInferredError(TypeError):
|
|
235
|
+
"""To be raised when the start value in the quicksum cannot be inferred."""
|
|
236
|
+
|
|
237
|
+
def __str__(self, /) -> str: ...
|
|
238
|
+
|
|
239
|
+
class NoConstraintForKeyError(IndexError):
|
|
240
|
+
"""Raised getting a constraint from the constraints that does not exist."""
|
|
241
|
+
|
|
242
|
+
def __str__(self, /) -> str: ...
|
|
243
|
+
|
|
244
|
+
class SampleColCreationError(IndexError):
|
|
245
|
+
"""Raised when an error occured during creation of a sample column."""
|
|
246
|
+
|
|
247
|
+
def __str__(self, /) -> str: ...
|
|
248
|
+
|
|
249
|
+
class EnvMismatchError(RuntimeError):
|
|
250
|
+
"""Raised when environments of provided expressions mismatch."""
|
|
251
|
+
|
|
252
|
+
def __str__(self, /) -> str: ...
|
|
253
|
+
|
|
254
|
+
class InternalPanicError(RuntimeError):
|
|
255
|
+
"""Raised when an internal and unrecoverable error occurred."""
|
|
256
|
+
|
|
257
|
+
def __str__(self, /) -> str: ...
|
|
258
|
+
|
|
259
|
+
__all__ = [
|
|
260
|
+
"ComputationError",
|
|
261
|
+
"ComputationError",
|
|
262
|
+
"DecodeError",
|
|
263
|
+
"DifferentEnvsError",
|
|
264
|
+
"DuplicateConstraintNameError",
|
|
265
|
+
"EvaluationError",
|
|
266
|
+
"IllegalConstraintNameError",
|
|
267
|
+
"InternalPanicError",
|
|
268
|
+
"ModelNotQuadraticError",
|
|
269
|
+
"ModelNotUnconstrainedError",
|
|
270
|
+
"ModelSenseNotMinimizeError",
|
|
271
|
+
"ModelVtypeError",
|
|
272
|
+
"MultipleActiveEnvironmentsError",
|
|
273
|
+
"NoActiveEnvironmentFoundError",
|
|
274
|
+
"NoConstraintForKeyError",
|
|
275
|
+
"SampleColCreationError",
|
|
276
|
+
"SampleIncompatibleVtypeError",
|
|
277
|
+
"SampleIncorrectLengthError",
|
|
278
|
+
"SampleUnexpectedVariableError",
|
|
279
|
+
"SolutionTranslationError",
|
|
280
|
+
"TranslationError",
|
|
281
|
+
"VariableCreationError",
|
|
282
|
+
"VariableExistsError",
|
|
283
|
+
"VariableNamesError",
|
|
284
|
+
"VariableNotExistingError",
|
|
285
|
+
"VariableOutOfRangeError",
|
|
286
|
+
"VariablesFromDifferentEnvsError",
|
|
287
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from luna_quantum.client.schemas.enums.call_style import CallStyle
|
|
2
|
+
from luna_quantum.exceptions.base_luna_quantum_error import BaseLunaQuantumError
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LunaQuantumCallStyleError(BaseLunaQuantumError):
|
|
6
|
+
"""Luna Quantum call style error."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, call_style: CallStyle) -> None:
|
|
9
|
+
super().__init__(f"The call style '{call_style}' is not supported.")
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from luna_quantum.exceptions.base_luna_quantum_error import BaseLunaQuantumError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PatchClassFieldExistsError(BaseLunaQuantumError, AttributeError):
|
|
5
|
+
"""Raised when a field is already present in a class."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, class_name: str, field_name: str) -> None:
|
|
8
|
+
super().__init__(
|
|
9
|
+
f"The class {class_name} already has a field named '{field_name}'"
|
|
10
|
+
)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
from logging import Logger
|
|
2
|
+
from typing import ClassVar
|
|
3
|
+
|
|
4
|
+
from luna_quantum.client.interfaces.services.luna_solve_i import ILunaSolve
|
|
5
|
+
from luna_quantum.util.log_utils import Logging
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LunaSolveClientFactory:
|
|
9
|
+
"""
|
|
10
|
+
Factory class for managing ILunaSolve client instances.
|
|
11
|
+
|
|
12
|
+
This class provides methods to retrieve and manage ILunaSolve client instances
|
|
13
|
+
based on class configurations and input specifications.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
_logger: Logger = Logging.get_logger(__name__)
|
|
17
|
+
_client_class: ClassVar[type[ILunaSolve]]
|
|
18
|
+
|
|
19
|
+
_client: ClassVar[ILunaSolve | None] = None
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def get_client(client: ILunaSolve | str | None) -> ILunaSolve:
|
|
23
|
+
"""
|
|
24
|
+
Get a client based on the input or create a default one.
|
|
25
|
+
|
|
26
|
+
This method retrieves an ILunaSolve client based on the provided input.
|
|
27
|
+
If a client is not given or if the input is invalid,
|
|
28
|
+
a default ILunaSolve client is instantiated and returned.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
client : Optional[Union[ILunaSolve, str]]
|
|
33
|
+
The input client. It can either be an instance of ILunaSolve, a string
|
|
34
|
+
representation of the client, or None.
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
ILunaSolve
|
|
39
|
+
An ILunaSolve client instance.
|
|
40
|
+
"""
|
|
41
|
+
if isinstance(client, ILunaSolve):
|
|
42
|
+
LunaSolveClientFactory._logger.debug(
|
|
43
|
+
"Client is already an instance of ILunaSolve"
|
|
44
|
+
)
|
|
45
|
+
return client
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
LunaSolveClientFactory._client
|
|
49
|
+
and isinstance(
|
|
50
|
+
LunaSolveClientFactory._client,
|
|
51
|
+
LunaSolveClientFactory.get_client_class(),
|
|
52
|
+
)
|
|
53
|
+
and LunaSolveClientFactory._client.is_same(client)
|
|
54
|
+
):
|
|
55
|
+
LunaSolveClientFactory._logger.debug(
|
|
56
|
+
"Cache hit. Last used default client is the same as the new one."
|
|
57
|
+
)
|
|
58
|
+
return LunaSolveClientFactory._client
|
|
59
|
+
LunaSolveClientFactory._logger.debug(
|
|
60
|
+
"Cache miss. No used default client or configuration changed. "
|
|
61
|
+
"Creating new client."
|
|
62
|
+
)
|
|
63
|
+
client = LunaSolveClientFactory.get_client_class()(client)
|
|
64
|
+
LunaSolveClientFactory._client = client
|
|
65
|
+
return client
|
|
66
|
+
|
|
67
|
+
@staticmethod
|
|
68
|
+
def get_client_class() -> type[ILunaSolve]:
|
|
69
|
+
"""
|
|
70
|
+
Return the class type for the client.
|
|
71
|
+
|
|
72
|
+
Retrieve the class type associated with the client from the client factory.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
Type[ILunaSolve]
|
|
77
|
+
The class type of the client.
|
|
78
|
+
"""
|
|
79
|
+
return LunaSolveClientFactory._client_class
|
|
80
|
+
|
|
81
|
+
@staticmethod
|
|
82
|
+
def set_client_class(client_class: type[ILunaSolve]) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Set the client class for the ClientFactory.
|
|
85
|
+
|
|
86
|
+
This method assigns a specific implementation class of ILunaSolve to the
|
|
87
|
+
ClientFactory for creating client instances. This allows the factory to use
|
|
88
|
+
the specified class when creating its objects.
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
client_class : Type[ILunaSolve]
|
|
93
|
+
The class implementing the ILunaSolve interface to be used by the factory.
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
None
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
LunaSolveClientFactory._client_class = client_class
|