luna-quantum 1.0.8rc2__cp314-cp314-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of luna-quantum might be problematic. Click here for more details.
- luna_quantum/__init__.py +121 -0
- luna_quantum/__init__.pyi +85 -0
- luna_quantum/_core.cpython-314-x86_64-linux-musl.so +0 -0
- luna_quantum/_core.pyi +4185 -0
- luna_quantum/algorithms/__init__.py +1 -0
- luna_quantum/aqm_overwrites/__init__.py +3 -0
- luna_quantum/aqm_overwrites/model.py +184 -0
- luna_quantum/backends/__init__.py +1 -0
- luna_quantum/client/__init__.py +0 -0
- luna_quantum/client/controllers/__init__.py +4 -0
- luna_quantum/client/controllers/luna_http_client.py +37 -0
- luna_quantum/client/controllers/luna_platform_client.py +256 -0
- luna_quantum/client/controllers/luna_q.py +67 -0
- luna_quantum/client/controllers/luna_solve.py +129 -0
- luna_quantum/client/error/__init__.py +0 -0
- luna_quantum/client/error/luna_api_key_invalid_error.py +10 -0
- luna_quantum/client/error/luna_api_key_missing_error.py +10 -0
- luna_quantum/client/error/luna_error.py +2 -0
- luna_quantum/client/error/luna_server_error.py +20 -0
- luna_quantum/client/error/timeout_error.py +12 -0
- luna_quantum/client/error/transformation_error.py +18 -0
- luna_quantum/client/error/utils/__init__.py +0 -0
- luna_quantum/client/error/utils/http_error_utils.py +112 -0
- luna_quantum/client/interfaces/__init__.py +4 -0
- luna_quantum/client/interfaces/clients/__init__.py +25 -0
- luna_quantum/client/interfaces/clients/circuit_rest_client_i.py +68 -0
- luna_quantum/client/interfaces/clients/info_rest_client_i.py +53 -0
- luna_quantum/client/interfaces/clients/model_rest_client_i.py +139 -0
- luna_quantum/client/interfaces/clients/qpu_token_rest_client_i.py +364 -0
- luna_quantum/client/interfaces/clients/rest_client_i.py +21 -0
- luna_quantum/client/interfaces/clients/solve_job_rest_client_i.py +201 -0
- luna_quantum/client/interfaces/clients/users_rest_client_i.py +29 -0
- luna_quantum/client/interfaces/services/__init__.py +0 -0
- luna_quantum/client/interfaces/services/luna_q_i.py +34 -0
- luna_quantum/client/interfaces/services/luna_solve_i.py +72 -0
- luna_quantum/client/interfaces/services/service_i.py +56 -0
- luna_quantum/client/rest_client/__init__.py +15 -0
- luna_quantum/client/rest_client/circuit_rest_client.py +107 -0
- luna_quantum/client/rest_client/info_rest_client.py +74 -0
- luna_quantum/client/rest_client/model_rest_client.py +216 -0
- luna_quantum/client/rest_client/qpu_token_rest_client.py +508 -0
- luna_quantum/client/rest_client/solve_job_rest_client.py +286 -0
- luna_quantum/client/rest_client/users_rest_client.py +35 -0
- luna_quantum/client/schemas/__init__.py +26 -0
- luna_quantum/client/schemas/circuit.py +48 -0
- luna_quantum/client/schemas/create/__init__.py +15 -0
- luna_quantum/client/schemas/create/circuit.py +30 -0
- luna_quantum/client/schemas/create/optimization.py +39 -0
- luna_quantum/client/schemas/create/qpu_token.py +22 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota.py +35 -0
- luna_quantum/client/schemas/create/qpu_token_time_quota_update.py +24 -0
- luna_quantum/client/schemas/create/qubo.py +19 -0
- luna_quantum/client/schemas/create/solve_job_create.py +43 -0
- luna_quantum/client/schemas/enums/__init__.py +0 -0
- luna_quantum/client/schemas/enums/call_style.py +13 -0
- luna_quantum/client/schemas/enums/circuit.py +42 -0
- luna_quantum/client/schemas/enums/model_format.py +11 -0
- luna_quantum/client/schemas/enums/problem.py +50 -0
- luna_quantum/client/schemas/enums/qpu_token_type.py +20 -0
- luna_quantum/client/schemas/enums/sense.py +8 -0
- luna_quantum/client/schemas/enums/status.py +40 -0
- luna_quantum/client/schemas/enums/timeframe.py +11 -0
- luna_quantum/client/schemas/error_message.py +14 -0
- luna_quantum/client/schemas/model_metadata.py +35 -0
- luna_quantum/client/schemas/qpu_token/__init__.py +0 -0
- luna_quantum/client/schemas/qpu_token/qpu_token.py +154 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_source.py +19 -0
- luna_quantum/client/schemas/qpu_token/qpu_token_time_quota.py +30 -0
- luna_quantum/client/schemas/qpu_token/token_provider.py +132 -0
- luna_quantum/client/schemas/representation.py +19 -0
- luna_quantum/client/schemas/solution.py +106 -0
- luna_quantum/client/schemas/solve_job.py +50 -0
- luna_quantum/client/schemas/solver_info.py +11 -0
- luna_quantum/client/schemas/user.py +11 -0
- luna_quantum/client/schemas/wrappers/__init__.py +5 -0
- luna_quantum/client/schemas/wrappers/datetime_wrapper.py +32 -0
- luna_quantum/client/utils/__init__.py +0 -0
- luna_quantum/client/utils/qpu_token_utils.py +147 -0
- luna_quantum/config.py +11 -0
- luna_quantum/decorators.py +248 -0
- luna_quantum/errors.py +34 -0
- luna_quantum/errors.pyi +287 -0
- luna_quantum/exceptions/__init__.py +0 -0
- luna_quantum/exceptions/base_luna_quantum_error.py +2 -0
- luna_quantum/exceptions/patch_class_field_exists_error.py +10 -0
- luna_quantum/factories/__init__.py +4 -0
- luna_quantum/factories/luna_solve_client_factory.py +100 -0
- luna_quantum/factories/usecase_factory.py +457 -0
- luna_quantum/py.typed +0 -0
- luna_quantum/solve/__init__.py +13 -0
- luna_quantum/solve/default_token.py +304 -0
- luna_quantum/solve/domain/__init__.py +0 -0
- luna_quantum/solve/domain/abstract/__init__.py +4 -0
- luna_quantum/solve/domain/abstract/luna_algorithm.py +205 -0
- luna_quantum/solve/domain/abstract/qpu_token_backend.py +34 -0
- luna_quantum/solve/domain/model_metadata.py +56 -0
- luna_quantum/solve/domain/solve_job.py +196 -0
- luna_quantum/solve/errors/__init__.py +0 -0
- luna_quantum/solve/errors/incompatible_backend_error.py +15 -0
- luna_quantum/solve/errors/model_metadata_missing_error.py +11 -0
- luna_quantum/solve/errors/solve_base_error.py +5 -0
- luna_quantum/solve/errors/token_missing_error.py +11 -0
- luna_quantum/solve/interfaces/__init__.py +0 -0
- luna_quantum/solve/interfaces/algorithm_i.py +49 -0
- luna_quantum/solve/interfaces/backend_i.py +28 -0
- luna_quantum/solve/interfaces/usecases/__init__.py +55 -0
- luna_quantum/solve/interfaces/usecases/model_delete_usecase_i.py +27 -0
- luna_quantum/solve/interfaces/usecases/model_fetch_metadata_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solutions_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_get_solve_jobs_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_id_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/model_load_by_metadata_usecase_i.py +37 -0
- luna_quantum/solve/interfaces/usecases/model_load_metadata_by_hash_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/model_save_usecase_i.py +36 -0
- luna_quantum/solve/interfaces/usecases/solve_job_cancel_usecase_i.py +33 -0
- luna_quantum/solve/interfaces/usecases/solve_job_create_usecase_i.py +44 -0
- luna_quantum/solve/interfaces/usecases/solve_job_delete_usecase_i.py +32 -0
- luna_quantum/solve/interfaces/usecases/solve_job_fetch_updates_usecase_i.py +38 -0
- luna_quantum/solve/interfaces/usecases/solve_job_get_result_usecase_i.py +63 -0
- luna_quantum/solve/parameters/__init__.py +0 -0
- luna_quantum/solve/parameters/algorithms/__init__.py +51 -0
- luna_quantum/solve/parameters/algorithms/base_params/__init__.py +24 -0
- luna_quantum/solve/parameters/algorithms/base_params/decomposer.py +57 -0
- luna_quantum/solve/parameters/algorithms/base_params/qaoa_circuit_params.py +95 -0
- luna_quantum/solve/parameters/algorithms/base_params/quantum_annealing_params.py +79 -0
- luna_quantum/solve/parameters/algorithms/base_params/scipy_optimizer.py +122 -0
- luna_quantum/solve/parameters/algorithms/base_params/simulated_annealing_params.py +106 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_kerberos_params.py +39 -0
- luna_quantum/solve/parameters/algorithms/base_params/tabu_search_params.py +129 -0
- luna_quantum/solve/parameters/algorithms/flexible_parameter_algorithm.py +59 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/__init__.py +4 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/qaga.py +131 -0
- luna_quantum/solve/parameters/algorithms/genetic_algorithms/saga.py +139 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujits_da_base.py +85 -0
- luna_quantum/solve/parameters/algorithms/lq_fda/fujitsu_da_v3c.py +155 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/__init__.py +3 -0
- luna_quantum/solve/parameters/algorithms/optimization_solvers/scip.py +51 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/__init__.py +19 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/kerberos.py +149 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_bqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/leap_hybrid_cqm.py +75 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/parallel_tempering_qpu.py +139 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/population_annealing_qpu.py +109 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/qbsolv_like_qpu.py +111 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/quantum_annealing.py +121 -0
- luna_quantum/solve/parameters/algorithms/quantum_annealing/repeated_reverse_quantum_annealing.py +174 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/__init__.py +6 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/__init__.py +26 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/config.py +80 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/flex_qaoa.py +226 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/optimizers.py +99 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/flex_qaoa/pipeline.py +87 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa.py +102 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/qaoa_fo.py +69 -0
- luna_quantum/solve/parameters/algorithms/quantum_gate/vqe.py +108 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/__init__.py +5 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/dialectic_search.py +136 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/qbsolv_like_tabu_search.py +117 -0
- luna_quantum/solve/parameters/algorithms/search_algorithms/tabu_search.py +126 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/__init__.py +13 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/parallel_tempering.py +131 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/population_annealing.py +95 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/qbsolv_like_simulated_annealing.py +141 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/repeated_reverse_simulated_annealing.py +172 -0
- luna_quantum/solve/parameters/algorithms/simulated_annealing/simulated_annealing.py +126 -0
- luna_quantum/solve/parameters/backends/__init__.py +22 -0
- luna_quantum/solve/parameters/backends/aqarios.py +17 -0
- luna_quantum/solve/parameters/backends/aws/__init__.py +11 -0
- luna_quantum/solve/parameters/backends/aws/aws.py +36 -0
- luna_quantum/solve/parameters/backends/aws/aws_backend_base.py +74 -0
- luna_quantum/solve/parameters/backends/aws/ionq.py +43 -0
- luna_quantum/solve/parameters/backends/aws/iqm.py +31 -0
- luna_quantum/solve/parameters/backends/aws/rigetti.py +31 -0
- luna_quantum/solve/parameters/backends/dwave.py +17 -0
- luna_quantum/solve/parameters/backends/dwave_qpu.py +166 -0
- luna_quantum/solve/parameters/backends/fda.py +17 -0
- luna_quantum/solve/parameters/backends/ibm.py +138 -0
- luna_quantum/solve/parameters/backends/qctrl.py +103 -0
- luna_quantum/solve/parameters/backends/zib.py +17 -0
- luna_quantum/solve/parameters/constants.py +11 -0
- luna_quantum/solve/parameters/mixins/__init__.py +0 -0
- luna_quantum/solve/parameters/mixins/fujitsu_common_params_mixin.py +239 -0
- luna_quantum/solve/parameters/mixins/fujitsu_v2_mixin.py +70 -0
- luna_quantum/solve/parameters/mixins/qbsolv_like_mixin.py +60 -0
- luna_quantum/solve/use_cases/__init__.py +119 -0
- luna_quantum/solve/use_cases/arbitrage_edge_based.py +50 -0
- luna_quantum/solve/use_cases/arbitrage_node_based.py +55 -0
- luna_quantum/solve/use_cases/base.py +7 -0
- luna_quantum/solve/use_cases/binary_integer_linear_programming.py +54 -0
- luna_quantum/solve/use_cases/binary_paint_shop_problem.py +37 -0
- luna_quantum/solve/use_cases/credit_scoring_feature_selection.py +40 -0
- luna_quantum/solve/use_cases/dynamic_portfolio_optimization.py +64 -0
- luna_quantum/solve/use_cases/exact_cover.py +51 -0
- luna_quantum/solve/use_cases/flight_gate_assignment.py +79 -0
- luna_quantum/solve/use_cases/graph_coloring.py +42 -0
- luna_quantum/solve/use_cases/graph_isomorphism.py +52 -0
- luna_quantum/solve/use_cases/graph_partitioning.py +46 -0
- luna_quantum/solve/use_cases/hamiltonian_cycle.py +49 -0
- luna_quantum/solve/use_cases/induced_subgraph_isomorphism.py +50 -0
- luna_quantum/solve/use_cases/job_shop_scheduling.py +44 -0
- luna_quantum/solve/use_cases/k_medoids_clustering.py +49 -0
- luna_quantum/solve/use_cases/knapsack_integer_weights.py +56 -0
- luna_quantum/solve/use_cases/linear_regression.py +60 -0
- luna_quantum/solve/use_cases/lmwcs.py +84 -0
- luna_quantum/solve/use_cases/longest_path.py +50 -0
- luna_quantum/solve/use_cases/market_graph_clustering.py +61 -0
- luna_quantum/solve/use_cases/max2sat.py +54 -0
- luna_quantum/solve/use_cases/max3sat.py +55 -0
- luna_quantum/solve/use_cases/max_clique.py +60 -0
- luna_quantum/solve/use_cases/max_cut.py +48 -0
- luna_quantum/solve/use_cases/max_independent_set.py +37 -0
- luna_quantum/solve/use_cases/minimal_maximal_matching.py +54 -0
- luna_quantum/solve/use_cases/minimal_spanning_tree.py +90 -0
- luna_quantum/solve/use_cases/minimum_vertex_cover.py +45 -0
- luna_quantum/solve/use_cases/number_partitioning.py +32 -0
- luna_quantum/solve/use_cases/portfolio_optimization.py +46 -0
- luna_quantum/solve/use_cases/portfolio_optimization_ib_tv.py +63 -0
- luna_quantum/solve/use_cases/quadratic_assignment.py +49 -0
- luna_quantum/solve/use_cases/quadratic_knapsack.py +48 -0
- luna_quantum/solve/use_cases/satellite_scheduling.py +73 -0
- luna_quantum/solve/use_cases/sensor_placement.py +58 -0
- luna_quantum/solve/use_cases/set_cover.py +56 -0
- luna_quantum/solve/use_cases/set_packing.py +54 -0
- luna_quantum/solve/use_cases/set_partitioning.py +52 -0
- luna_quantum/solve/use_cases/subgraph_isomorphism.py +55 -0
- luna_quantum/solve/use_cases/subset_sum.py +37 -0
- luna_quantum/solve/use_cases/support_vector_machine.py +64 -0
- luna_quantum/solve/use_cases/traffic_flow.py +35 -0
- luna_quantum/solve/use_cases/travelling_salesman_problem.py +53 -0
- luna_quantum/solve/use_cases/type_aliases.py +9 -0
- luna_quantum/solve/use_cases/weighted_max_cut.py +37 -0
- luna_quantum/solve/usecases/__init__.py +45 -0
- luna_quantum/solve/usecases/model_delete_usecase.py +49 -0
- luna_quantum/solve/usecases/model_fetch_metadata_usecase.py +50 -0
- luna_quantum/solve/usecases/model_get_solution_usecase.py +59 -0
- luna_quantum/solve/usecases/model_get_solve_jobs_usecase.py +62 -0
- luna_quantum/solve/usecases/model_load_by_id_usecase.py +47 -0
- luna_quantum/solve/usecases/model_load_by_metadata_usecase.py +52 -0
- luna_quantum/solve/usecases/model_load_metadata_by_hash_usecase.py +51 -0
- luna_quantum/solve/usecases/model_save_usecase.py +63 -0
- luna_quantum/solve/usecases/solve_job_cancel_usecase.py +51 -0
- luna_quantum/solve/usecases/solve_job_create_usecase.py +112 -0
- luna_quantum/solve/usecases/solve_job_delete_usecase.py +38 -0
- luna_quantum/solve/usecases/solve_job_fetch_updates_usecase.py +49 -0
- luna_quantum/solve/usecases/solve_job_get_result_usecase.py +95 -0
- luna_quantum/transformations.py +18 -0
- luna_quantum/transformations.pyi +371 -0
- luna_quantum/translator.py +23 -0
- luna_quantum/translator.pyi +869 -0
- luna_quantum/util/__init__.py +0 -0
- luna_quantum/util/active_waiting.py +79 -0
- luna_quantum/util/class_patcher.py +164 -0
- luna_quantum/util/debug_info.py +52 -0
- luna_quantum/util/log_utils.py +187 -0
- luna_quantum/util/pretty_base.py +67 -0
- luna_quantum/util/pydantic_utils.py +38 -0
- luna_quantum/utils.py +3 -0
- luna_quantum/utils.pyi +67 -0
- luna_quantum-1.0.8rc2.dist-info/METADATA +36 -0
- luna_quantum-1.0.8rc2.dist-info/RECORD +265 -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
- luna_quantum.libs/libgcc_s-02f3f192.so.1 +0 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated, Any, Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FujitsuCommonParamsMixin(BaseModel):
|
|
9
|
+
"""
|
|
10
|
+
Common parameters used across various quantum and classical optimization solvers.
|
|
11
|
+
|
|
12
|
+
This class encapsulates parameters for auto-tuning, scaling, and general
|
|
13
|
+
configuration options that are applicable to multiple solver types. It provides a
|
|
14
|
+
consistent interface for these common settings to simplify configuration and
|
|
15
|
+
enhance reusability.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
auto_tuning: Literal["NOTHING", "SCALING", "AUTO_SCALING", "SAMPLING",
|
|
20
|
+
"AUTO_SCALING_AND_SAMPLING", "SCALING_AND_SAMPLING"]
|
|
21
|
+
Controls automatic parameter adjustment strategies:
|
|
22
|
+
- "NOTHING": No auto-tuning (use parameters exactly as specified)
|
|
23
|
+
- "SCALING": Apply scaling_factor to model coefficients and parameters
|
|
24
|
+
- "AUTO_SCALING": Automatically determine optimal scaling factor based on bit
|
|
25
|
+
precision
|
|
26
|
+
- "SAMPLING": Automatically determine temperature parameters through sampling
|
|
27
|
+
- "AUTO_SCALING_AND_SAMPLING": Combine auto-scaling and sampling
|
|
28
|
+
- "SCALING_AND_SAMPLING": Apply explicit scaling and determine temperatures
|
|
29
|
+
Default is "NOTHING", giving full control to the user.
|
|
30
|
+
scaling_factor: Union[int, float]
|
|
31
|
+
Multiplicative factor applied to model coefficients, temperatures, and other
|
|
32
|
+
parameters.
|
|
33
|
+
Higher values can improve numerical precision but may lead to overflow.
|
|
34
|
+
Default is 1.0 (no scaling).
|
|
35
|
+
scaling_bit_precision: int
|
|
36
|
+
Maximum bit precision to use when scaling. Determines the maximum allowable
|
|
37
|
+
coefficient magnitude. Default is 64, using full double precision.
|
|
38
|
+
guidance_config: Union[PartialConfig, None]
|
|
39
|
+
Optional configuration for guiding the optimization process with prior
|
|
40
|
+
knowledge. Can specify initial values or constraints for variables. Default is
|
|
41
|
+
None.
|
|
42
|
+
random_seed: Union[int, None]
|
|
43
|
+
Seed for random number generation to ensure reproducible results.
|
|
44
|
+
Must be between 0 and 9,999. Default is None (random seed).
|
|
45
|
+
timeseries_max_bits: Union[int, None]
|
|
46
|
+
Maximum number of bits to use for timeseries representation.
|
|
47
|
+
Limits memory usage for large problems. Default is None (no limit).
|
|
48
|
+
solver_max_bits: int
|
|
49
|
+
Maximum problem size (in bits/variables) that the solver can handle.
|
|
50
|
+
Default is 2¹³ (8,192), suitable for most solvers.
|
|
51
|
+
var_shape_set: Optional[VarShapeSet]
|
|
52
|
+
This parameter should be an object of :class:`VarShapeSet` or ``None``
|
|
53
|
+
auto_fill_cold_bits: Optional[bool]
|
|
54
|
+
In case ``var_shape_set`` is defined and contains a 1-hot group,
|
|
55
|
+
and a hot bit is set to ``True`` and this parameter is also set to ``True``,
|
|
56
|
+
then all related cold bits are set to ``False``. Default is ``True``
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
class BitArrayShape(BaseModel):
|
|
60
|
+
"""BitArrayShape.
|
|
61
|
+
|
|
62
|
+
An object of the class :class:`BitArrayShape` represents an array structure as
|
|
63
|
+
part of a bit vector. It allows multidimensional indexed access to the bit
|
|
64
|
+
variables of a :class:`BinPol` polynomial. :class:`BitArrayShape` objects are
|
|
65
|
+
used inside :class:`VarShapeSet` objects, which organize index data of a
|
|
66
|
+
complete bit vector for a polynomial. Bit variables of such polynomials can
|
|
67
|
+
then be accessed by name and indices according to the shape specified in the
|
|
68
|
+
:class:`BitArrayShape` object.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
shape: List[int]
|
|
73
|
+
shape of the index; specify the length of each dimension
|
|
74
|
+
constant_bits: Optional[NDArray]
|
|
75
|
+
numpy array of type int8 with same shape as the previous parameter
|
|
76
|
+
containing 0 and 1 for constant bits and -1 variable bits
|
|
77
|
+
one_hot: OneHot
|
|
78
|
+
define variable as one_hot section
|
|
79
|
+
axis_names: Optional[List[str]]
|
|
80
|
+
Names for the axis.
|
|
81
|
+
index_offsets: Optional[List[int]]
|
|
82
|
+
index_offsets of the index, specify the index_offsets of each dimension
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
type: Literal["BitArrayShape"] = "BitArrayShape"
|
|
86
|
+
axis_names: list[str] | None = None
|
|
87
|
+
index_offsets: list[int] | None = None
|
|
88
|
+
name: str
|
|
89
|
+
one_hot: Literal["no_way", "one_way", "two_way"] = "no_way"
|
|
90
|
+
|
|
91
|
+
class Category(BaseModel):
|
|
92
|
+
"""Category.
|
|
93
|
+
|
|
94
|
+
An object of the class :class:`Category` represents an array structure as part
|
|
95
|
+
of a bit vector. It allows indexed access to the bit variables of a
|
|
96
|
+
:class:`BinPol` polynomial. :class:`Category`
|
|
97
|
+
objects are used inside :class:`VarShapeSet` objects, which organize index data
|
|
98
|
+
of a complete bit vector for a polynomial. Bit variables of such polynomials
|
|
99
|
+
can then be accessed by ``name`` and categorical indices according to the
|
|
100
|
+
``values`` specified in the :class:`BitArrayShape` object. A categorical index
|
|
101
|
+
can be any sequence of unique values.
|
|
102
|
+
|
|
103
|
+
Parameters
|
|
104
|
+
----------
|
|
105
|
+
name: str
|
|
106
|
+
name of the new index
|
|
107
|
+
values: List[Any]
|
|
108
|
+
list of unique values for this category
|
|
109
|
+
one_hot: OneHot
|
|
110
|
+
define variable as one_hot section
|
|
111
|
+
axis_names: List[str]
|
|
112
|
+
Names for the axis.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
type: Literal["Category"] = "Category"
|
|
116
|
+
values: list[Any] = Field(default_factory=list)
|
|
117
|
+
axis_names: list[str] | None = None
|
|
118
|
+
name: str
|
|
119
|
+
one_hot: Literal["no_way", "one_way", "two_way"] = "no_way"
|
|
120
|
+
|
|
121
|
+
class Variable(BaseModel):
|
|
122
|
+
"""Variable.
|
|
123
|
+
|
|
124
|
+
A ``Variable`` is a binary polynomial, that represents a numerical value
|
|
125
|
+
according to values of the underlying bits. The variable is defined by a value
|
|
126
|
+
range and a specific representation scheme that is realized in respective
|
|
127
|
+
inherited classes.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
name: str
|
|
132
|
+
name of the variable
|
|
133
|
+
start: float
|
|
134
|
+
first number in the list of values to be represented by the variable
|
|
135
|
+
stop: float
|
|
136
|
+
stop value for the list of numbers to be represented by the variable; stop
|
|
137
|
+
is omitted
|
|
138
|
+
step: float
|
|
139
|
+
increment for the list of numbers to be represented by the variable
|
|
140
|
+
shape: List[int]
|
|
141
|
+
shape of the index; specify the length of each dimension
|
|
142
|
+
constant_bits: Optional[NDArray]
|
|
143
|
+
numpy array of type int8 with same shape as the previous parameter
|
|
144
|
+
containing 0 and 1 for constant bits and -1 variable bits
|
|
145
|
+
one_hot: OneHot
|
|
146
|
+
define variable as one_hot section
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
type: Literal["Variable"] = "Variable"
|
|
150
|
+
start: float
|
|
151
|
+
stop: float
|
|
152
|
+
step: float
|
|
153
|
+
|
|
154
|
+
shape: list[int] | None = None
|
|
155
|
+
constant_bits: list[int] | None = None
|
|
156
|
+
|
|
157
|
+
name: str
|
|
158
|
+
one_hot: Literal["no_way", "one_way", "two_way"] = "no_way"
|
|
159
|
+
|
|
160
|
+
class VarShapeSet(BaseModel):
|
|
161
|
+
"""VarShapeSet.
|
|
162
|
+
|
|
163
|
+
:class:`dadk.BinPol.VarShapeSet` defines an indexing structure for the bits of
|
|
164
|
+
a BinPol polynomial. Plain BinPol polynomials are defined on a set of bits
|
|
165
|
+
indexed by a ``range(N)`` for some integer ``N``. The ``VarShapeSet`` lays
|
|
166
|
+
a sequence of disjoint named sections over this linear structure. Bits within a
|
|
167
|
+
section can be addressed by the defined name. With a ``BitArrayShape`` a
|
|
168
|
+
section can be defined as multidimensional array and single bits in the section
|
|
169
|
+
can be addressed by an appropriate tuple of indices. With a ``Variable``
|
|
170
|
+
definition the section represents a number encoded in certain bit schemes; in
|
|
171
|
+
this case it is possible to retrieve the represented value instead of reading
|
|
172
|
+
single bits.
|
|
173
|
+
|
|
174
|
+
Parameters
|
|
175
|
+
----------
|
|
176
|
+
var_defs: Union[BitArrayShape, Variable, Category]
|
|
177
|
+
one or more section definitions of type :class:`BitArrayShape`,
|
|
178
|
+
:class:`Variable` or :class:`Category`
|
|
179
|
+
one_hot_groups: Optional[List[OneHotGroup]]
|
|
180
|
+
optional list of special one_hot group definitions
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
var_defs: list[
|
|
184
|
+
Annotated[
|
|
185
|
+
FujitsuCommonParamsMixin.BitArrayShape
|
|
186
|
+
| FujitsuCommonParamsMixin.Variable
|
|
187
|
+
| FujitsuCommonParamsMixin.Category,
|
|
188
|
+
Field(discriminator="type"),
|
|
189
|
+
]
|
|
190
|
+
] = Field(default_factory=list)
|
|
191
|
+
one_hot_groups: list[Literal["no_way", "one_way", "two_way"]] | None = None
|
|
192
|
+
|
|
193
|
+
class PartialConfig:
|
|
194
|
+
"""Produces a dict that can be used for the annealing algorithm.
|
|
195
|
+
|
|
196
|
+
The start state for an annealing or parallel tempering model can be specified.
|
|
197
|
+
The used dictionary addresses bits with their flattened index. With the class
|
|
198
|
+
:class:`PartialConfig` those bits can be specified on the symbolic level of
|
|
199
|
+
:class:`BitArrayShape` or :class:`Variable` and the offsets in a
|
|
200
|
+
:class:`VarShapeSet` are calculated automatically. Flat indices can be used
|
|
201
|
+
directly, if they are known. For variables, indices are used directly and do
|
|
202
|
+
not need to be adjusted by a global index consideration from the
|
|
203
|
+
:class:`VarShapeSet`. After setting the start state accordingly, a string can
|
|
204
|
+
be created with the method ``as_json``. If one_hot or two_hot specifications
|
|
205
|
+
are given in :class:`VarShapeSet`, the dictionary generated in the methods
|
|
206
|
+
``get_dict`` or ``as_json`` is build up with respect to the set bit variables
|
|
207
|
+
and one-way or two-way rules.
|
|
208
|
+
|
|
209
|
+
The object is initialized by a :class:`VarShapeSet` object or None.
|
|
210
|
+
An initialization with None can be used for :class:`BinPol`.
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
var_shape_set: Optional[VarShapeSet]
|
|
215
|
+
This parameter should be an object of :class:`VarShapeSet` or ``None``
|
|
216
|
+
auto_fill_cold_bits: bool
|
|
217
|
+
In case ``var_shape_set`` is defined and contains a 1-hot group,
|
|
218
|
+
and a hot bit is set to ``True`` and this parameter is also set to ``True``,
|
|
219
|
+
then all related cold bits are set to ``False``. Default is ``True``
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
var_shape_set: FujitsuCommonParamsMixin.VarShapeSet | None = None
|
|
223
|
+
auto_fill_cold_bits: bool = True
|
|
224
|
+
|
|
225
|
+
auto_tuning: Literal[
|
|
226
|
+
"NOTHING",
|
|
227
|
+
"SCALING",
|
|
228
|
+
"AUTO_SCALING",
|
|
229
|
+
"SAMPLING",
|
|
230
|
+
"AUTO_SCALING_AND_SAMPLING",
|
|
231
|
+
"SCALING_AND_SAMPLING",
|
|
232
|
+
] = "NOTHING"
|
|
233
|
+
scaling_factor: int | float = 1.0
|
|
234
|
+
scaling_bit_precision: int = 64
|
|
235
|
+
random_seed: int | None = Field(default=None, ge=0, le=9_999)
|
|
236
|
+
timeseries_max_bits: int | None = None
|
|
237
|
+
solver_max_bits: int = 2**13
|
|
238
|
+
var_shape_set: VarShapeSet | None = None
|
|
239
|
+
auto_fill_cold_bits: bool | None = True
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FujitsuV2Mixin(BaseModel):
|
|
7
|
+
"""
|
|
8
|
+
FujitsuV2Mixin.
|
|
9
|
+
|
|
10
|
+
Parameters for V2 optimization algorithms, particularly relevant for
|
|
11
|
+
Digital Annealer implementations.
|
|
12
|
+
|
|
13
|
+
This class defines parameters controlling the annealing process, temperature
|
|
14
|
+
scheduling, and solution mode for V2 solvers. These parameters impact how
|
|
15
|
+
the algorithm traverses the energy landscape and converges to solutions.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
optimization_method: Literal["annealing", "parallel_tempering"]
|
|
20
|
+
Algorithm to use for optimization:
|
|
21
|
+
- "annealing": Standard simulated annealing with gradual cooling
|
|
22
|
+
- "parallel_tempering": Simultaneous runs at different temperatures with
|
|
23
|
+
periodic state exchanges, effective for complex energy landscapes
|
|
24
|
+
Default is "annealing".
|
|
25
|
+
temperature_start: float
|
|
26
|
+
Initial temperature for the annealing process. Higher values enable more
|
|
27
|
+
exploration initially. Default is 1000.0. Range: [0.0, 1e20].
|
|
28
|
+
temperature_end: float
|
|
29
|
+
Final temperature for the annealing process. Lower values enforce more
|
|
30
|
+
exploitation in final phases. Default is 1.0. Range: [0.0, 1e20].
|
|
31
|
+
temperature_mode: int
|
|
32
|
+
Cooling curve mode for temperature decay:
|
|
33
|
+
- 0: Exponential cooling - reduce by factor at fixed intervals
|
|
34
|
+
- 1: Inverse cooling - faster initial cooling, slower later
|
|
35
|
+
- 2: Inverse root cooling - another non-linear cooling schedule
|
|
36
|
+
Default is 0 (exponential).
|
|
37
|
+
temperature_interval: int
|
|
38
|
+
Number of iterations between temperature adjustments. Larger values
|
|
39
|
+
allow more exploration at each temperature. Default is 100. Range: [1, 1e20].
|
|
40
|
+
offset_increase_rate: float
|
|
41
|
+
Rate at which dynamic offset increases when no bit is selected.
|
|
42
|
+
Helps escape plateaus in the energy landscape. Default is 5.0.
|
|
43
|
+
Range: [0.0, 1e20].
|
|
44
|
+
solution_mode: Literal["QUICK", "COMPLETE"]
|
|
45
|
+
Determines solution reporting strategy:
|
|
46
|
+
- "QUICK": Return only the overall best solution (faster)
|
|
47
|
+
- "COMPLETE": Return best solutions from all runs (more diverse)
|
|
48
|
+
Default is "COMPLETE", providing more solution options.
|
|
49
|
+
flip_probabilities: Tuple[float, float]
|
|
50
|
+
Probabilities used for determining temperature parameters.
|
|
51
|
+
First value is probability of accepting worse solutions at start temperature,
|
|
52
|
+
second value is probability at end temperature. Default is (0.99, 0.01).
|
|
53
|
+
annealing_steps: Tuple[float, float]
|
|
54
|
+
Portion of annealing trajectory where end_progress_probability is reached.
|
|
55
|
+
Controls the annealing schedule shape. Default is (0.0, 0.5).
|
|
56
|
+
sampling_runs: int
|
|
57
|
+
Number of random walkers used for energy delta determination during
|
|
58
|
+
parameter estimation sampling. Default is 100.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
optimization_method: Literal["annealing", "parallel_tempering"] = "annealing"
|
|
62
|
+
temperature_start: float = Field(default=1_000.0, ge=0.0, le=1e20)
|
|
63
|
+
temperature_end: float = Field(default=1.0, ge=0.0, le=1e20)
|
|
64
|
+
temperature_mode: int = 0
|
|
65
|
+
temperature_interval: int = Field(default=100, ge=1, le=int(1e20))
|
|
66
|
+
offset_increase_rate: float = Field(default=5.0, ge=0.0, le=1e20)
|
|
67
|
+
solution_mode: Literal["QUICK", "COMPLETE"] = "COMPLETE"
|
|
68
|
+
flip_probabilities: tuple[float, float] = 0.99, 0.01
|
|
69
|
+
annealing_steps: tuple[float, float] = 0.0, 0.5
|
|
70
|
+
sampling_runs: int = 100
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
from luna_quantum.solve.parameters.constants import DEFAULT_ATOL, DEFAULT_RTOL
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class QBSolvLikeMixin(BaseModel):
|
|
7
|
+
"""
|
|
8
|
+
QBSolvLikeMixin.
|
|
9
|
+
|
|
10
|
+
Attributes
|
|
11
|
+
----------
|
|
12
|
+
decomposer_size: int
|
|
13
|
+
Size for the decomposer, which determines the maximum subproblem size to be
|
|
14
|
+
handled in each iteration. Larger values may produce better solutions but
|
|
15
|
+
increase computational complexity exponentially. Default is 50, which balances
|
|
16
|
+
solution quality with reasonable runtime.
|
|
17
|
+
rolling: bool
|
|
18
|
+
Whether to use rolling window decomposition for the solver. When enabled,
|
|
19
|
+
this allows for overlapping subproblems with shared variables, which can
|
|
20
|
+
improve solution quality by better handling interactions across subproblem
|
|
21
|
+
boundaries. Default is True.
|
|
22
|
+
rolling_history: float
|
|
23
|
+
Rolling history factor controlling how much of previous subproblem solutions
|
|
24
|
+
are considered when solving subsequent subproblems. Higher values incorporate
|
|
25
|
+
more historical information but may slow convergence to new solutions.
|
|
26
|
+
Default is 0.15 (15% retention).
|
|
27
|
+
max_iter: int | None
|
|
28
|
+
Maximum number of iterations (decomposition and solving cycles) to perform.
|
|
29
|
+
Higher values allow for more thorough optimization but increase runtime.
|
|
30
|
+
Default is 100.
|
|
31
|
+
max_time: int
|
|
32
|
+
Time in seconds after which the algorithm will stop, regardless of convergence
|
|
33
|
+
status. Provides a hard time limit for time-constrained applications.
|
|
34
|
+
Default is 5.
|
|
35
|
+
convergence: int
|
|
36
|
+
Number of iterations with unchanged output to terminate algorithm. Higher values
|
|
37
|
+
ensure more stable solutions but may increase computation time unnecessarily
|
|
38
|
+
if the algorithm has already found the best solution. Default is 3.
|
|
39
|
+
target: float | None
|
|
40
|
+
Energy level that the algorithm tries to reach. If this target energy is
|
|
41
|
+
achieved, the algorithm will terminate early. Default is None, meaning the
|
|
42
|
+
algorithm will run until other stopping criteria are met.
|
|
43
|
+
rtol: float
|
|
44
|
+
Relative tolerance for convergence. Used when comparing energy values between
|
|
45
|
+
iterations to determine if significant improvement has occurred. Default uses
|
|
46
|
+
DEFAULT_RTOL.
|
|
47
|
+
atol: float
|
|
48
|
+
Absolute tolerance for convergence. Used alongside rtol when comparing energy
|
|
49
|
+
values to determine if the algorithm has converged. Default uses DEFAULT_ATOL.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
decomposer_size: int = 50
|
|
53
|
+
rolling: bool = True
|
|
54
|
+
rolling_history: float = 0.15
|
|
55
|
+
max_iter: int | None = 100
|
|
56
|
+
max_time: int = 5
|
|
57
|
+
convergence: int = 3
|
|
58
|
+
target: float | None = None
|
|
59
|
+
rtol: float = DEFAULT_RTOL
|
|
60
|
+
atol: float = DEFAULT_ATOL
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from luna_quantum.solve.use_cases.arbitrage_edge_based import ArbitrageEdgeBased
|
|
2
|
+
from luna_quantum.solve.use_cases.arbitrage_node_based import ArbitrageNodeBased
|
|
3
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
4
|
+
from luna_quantum.solve.use_cases.binary_integer_linear_programming import (
|
|
5
|
+
BinaryIntegerLinearProgramming,
|
|
6
|
+
)
|
|
7
|
+
from luna_quantum.solve.use_cases.binary_paint_shop_problem import (
|
|
8
|
+
BinaryPaintShopProblem,
|
|
9
|
+
)
|
|
10
|
+
from luna_quantum.solve.use_cases.credit_scoring_feature_selection import (
|
|
11
|
+
CreditScoringFeatureSelection,
|
|
12
|
+
)
|
|
13
|
+
from luna_quantum.solve.use_cases.dynamic_portfolio_optimization import (
|
|
14
|
+
DynamicPortfolioOptimization,
|
|
15
|
+
)
|
|
16
|
+
from luna_quantum.solve.use_cases.exact_cover import ExactCover
|
|
17
|
+
from luna_quantum.solve.use_cases.flight_gate_assignment import FlightGateAssignment
|
|
18
|
+
from luna_quantum.solve.use_cases.graph_coloring import GraphColoring
|
|
19
|
+
from luna_quantum.solve.use_cases.graph_isomorphism import GraphIsomorphism
|
|
20
|
+
from luna_quantum.solve.use_cases.graph_partitioning import GraphPartitioning
|
|
21
|
+
from luna_quantum.solve.use_cases.hamiltonian_cycle import HamiltonianCycle
|
|
22
|
+
from luna_quantum.solve.use_cases.induced_subgraph_isomorphism import (
|
|
23
|
+
InducedSubGraphIsomorphism,
|
|
24
|
+
)
|
|
25
|
+
from luna_quantum.solve.use_cases.job_shop_scheduling import JobShopScheduling
|
|
26
|
+
from luna_quantum.solve.use_cases.k_medoids_clustering import KMedoidsClustering
|
|
27
|
+
from luna_quantum.solve.use_cases.knapsack_integer_weights import KnapsackIntegerWeights
|
|
28
|
+
from luna_quantum.solve.use_cases.linear_regression import LinearRegression
|
|
29
|
+
from luna_quantum.solve.use_cases.lmwcs import LabeledMaxWeightedCommonSubgraph
|
|
30
|
+
from luna_quantum.solve.use_cases.longest_path import LongestPath
|
|
31
|
+
from luna_quantum.solve.use_cases.market_graph_clustering import MarketGraphClustering
|
|
32
|
+
from luna_quantum.solve.use_cases.max2sat import Max2SAT
|
|
33
|
+
from luna_quantum.solve.use_cases.max3sat import Max3SAT
|
|
34
|
+
from luna_quantum.solve.use_cases.max_clique import MaxClique
|
|
35
|
+
from luna_quantum.solve.use_cases.max_cut import MaxCut
|
|
36
|
+
from luna_quantum.solve.use_cases.max_independent_set import MaxIndependentSet
|
|
37
|
+
from luna_quantum.solve.use_cases.minimal_maximal_matching import MinimalMaximalMatching
|
|
38
|
+
from luna_quantum.solve.use_cases.minimal_spanning_tree import MinimalSpanningTree
|
|
39
|
+
from luna_quantum.solve.use_cases.minimum_vertex_cover import MinimumVertexCover
|
|
40
|
+
from luna_quantum.solve.use_cases.number_partitioning import NumberPartitioning
|
|
41
|
+
from luna_quantum.solve.use_cases.portfolio_optimization import PortfolioOptimization
|
|
42
|
+
from luna_quantum.solve.use_cases.portfolio_optimization_ib_tv import (
|
|
43
|
+
PortfolioOptimizationInvestmentBandsTargetVolatility,
|
|
44
|
+
)
|
|
45
|
+
from luna_quantum.solve.use_cases.quadratic_assignment import QuadraticAssignment
|
|
46
|
+
from luna_quantum.solve.use_cases.quadratic_knapsack import QuadraticKnapsack
|
|
47
|
+
from luna_quantum.solve.use_cases.satellite_scheduling import SatelliteScheduling
|
|
48
|
+
from luna_quantum.solve.use_cases.sensor_placement import SensorPlacement
|
|
49
|
+
from luna_quantum.solve.use_cases.set_cover import SetCover
|
|
50
|
+
from luna_quantum.solve.use_cases.set_packing import SetPacking
|
|
51
|
+
from luna_quantum.solve.use_cases.set_partitioning import SetPartitioning
|
|
52
|
+
from luna_quantum.solve.use_cases.subgraph_isomorphism import SubGraphIsomorphism
|
|
53
|
+
from luna_quantum.solve.use_cases.subset_sum import SubsetSum
|
|
54
|
+
from luna_quantum.solve.use_cases.support_vector_machine import SupportVectorMachine
|
|
55
|
+
from luna_quantum.solve.use_cases.traffic_flow import TrafficFlow
|
|
56
|
+
from luna_quantum.solve.use_cases.travelling_salesman_problem import (
|
|
57
|
+
TravellingSalesmanProblem,
|
|
58
|
+
)
|
|
59
|
+
from luna_quantum.solve.use_cases.type_aliases import (
|
|
60
|
+
CalculusLiteral,
|
|
61
|
+
Clause,
|
|
62
|
+
NestedDictGraph,
|
|
63
|
+
NestedDictIntGraph,
|
|
64
|
+
Node,
|
|
65
|
+
)
|
|
66
|
+
from luna_quantum.solve.use_cases.weighted_max_cut import WeightedMaxCut
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
"ArbitrageEdgeBased",
|
|
70
|
+
"ArbitrageNodeBased",
|
|
71
|
+
"BinaryIntegerLinearProgramming",
|
|
72
|
+
"BinaryPaintShopProblem",
|
|
73
|
+
"CalculusLiteral",
|
|
74
|
+
"Clause",
|
|
75
|
+
"CreditScoringFeatureSelection",
|
|
76
|
+
"DynamicPortfolioOptimization",
|
|
77
|
+
"ExactCover",
|
|
78
|
+
"FlightGateAssignment",
|
|
79
|
+
"GraphColoring",
|
|
80
|
+
"GraphIsomorphism",
|
|
81
|
+
"GraphPartitioning",
|
|
82
|
+
"HamiltonianCycle",
|
|
83
|
+
"InducedSubGraphIsomorphism",
|
|
84
|
+
"JobShopScheduling",
|
|
85
|
+
"KMedoidsClustering",
|
|
86
|
+
"KnapsackIntegerWeights",
|
|
87
|
+
"LabeledMaxWeightedCommonSubgraph",
|
|
88
|
+
"LinearRegression",
|
|
89
|
+
"LongestPath",
|
|
90
|
+
"MarketGraphClustering",
|
|
91
|
+
"Max2SAT",
|
|
92
|
+
"Max3SAT",
|
|
93
|
+
"MaxClique",
|
|
94
|
+
"MaxCut",
|
|
95
|
+
"MaxIndependentSet",
|
|
96
|
+
"MinimalMaximalMatching",
|
|
97
|
+
"MinimalSpanningTree",
|
|
98
|
+
"MinimumVertexCover",
|
|
99
|
+
"NestedDictGraph",
|
|
100
|
+
"NestedDictIntGraph",
|
|
101
|
+
"Node",
|
|
102
|
+
"NumberPartitioning",
|
|
103
|
+
"PortfolioOptimization",
|
|
104
|
+
"PortfolioOptimizationInvestmentBandsTargetVolatility",
|
|
105
|
+
"QuadraticAssignment",
|
|
106
|
+
"QuadraticKnapsack",
|
|
107
|
+
"SatelliteScheduling",
|
|
108
|
+
"SensorPlacement",
|
|
109
|
+
"SetCover",
|
|
110
|
+
"SetPacking",
|
|
111
|
+
"SetPartitioning",
|
|
112
|
+
"SubGraphIsomorphism",
|
|
113
|
+
"SubsetSum",
|
|
114
|
+
"SupportVectorMachine",
|
|
115
|
+
"TrafficFlow",
|
|
116
|
+
"TravellingSalesmanProblem",
|
|
117
|
+
"UseCase",
|
|
118
|
+
"WeightedMaxCut",
|
|
119
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ArbitrageEdgeBased(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Arbitrage Edge Based.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
In economics and finance, arbitrage is the practice of taking advantage of a
|
|
18
|
+
difference in prices in two or more markets; striking a combination of matching
|
|
19
|
+
deals to capitalize on the difference.
|
|
20
|
+
The edge based Arbitrage problem tries to find the best cycle in a directed and
|
|
21
|
+
complete graph. In this graph, each node corresponds to an asset and each directed
|
|
22
|
+
edge is weighted with the corresponding conversion rate. It creates a QUBO with the
|
|
23
|
+
size _n_edges x n_edges_, which produces a solution vector where each binary
|
|
24
|
+
position maps to an edge.
|
|
25
|
+
|
|
26
|
+
Links
|
|
27
|
+
-----
|
|
28
|
+
|
|
29
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Arbitrage)
|
|
30
|
+
|
|
31
|
+
[Transformation](http://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Finding-Optimal-Arbitrage-Opportunities-Using-a-Quantum-Annealer.pdf)
|
|
32
|
+
|
|
33
|
+
Attributes
|
|
34
|
+
----------
|
|
35
|
+
### graph: Dict[str, Dict[str, Dict[str, float]]]
|
|
36
|
+
\n The input graph as described above in the form of nested dictionaries.
|
|
37
|
+
\n Example for three different currencies:
|
|
38
|
+
\n _{_
|
|
39
|
+
\n _0: {1: {'weight': 1.31904}, 2: {'weight': 6.72585}},_
|
|
40
|
+
\n _1: {0: {'weight': 0.75799}, 2: {'weight': 5.10327},_
|
|
41
|
+
\n _2: {0: {'weight': 0.14864}, 1: {'weight': 0.19586}}_
|
|
42
|
+
\n _}_
|
|
43
|
+
|
|
44
|
+
### penalty: Optional[float] = None
|
|
45
|
+
\n The penalty term for the QUBO matrix. Has to be greater than 0.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
name: Literal["AEB"] = "AEB"
|
|
49
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
50
|
+
penalty: float | None = None
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ArbitrageNodeBased(UseCase):
|
|
11
|
+
r"""
|
|
12
|
+
# Arbitrage Node Based.
|
|
13
|
+
|
|
14
|
+
Description
|
|
15
|
+
-----------
|
|
16
|
+
|
|
17
|
+
In economics and finance, arbitrage is the practice of taking advantage of a
|
|
18
|
+
difference in prices in two or more markets; striking a combination of matching
|
|
19
|
+
deals to capitalize on the difference.
|
|
20
|
+
The node based Arbitrage problem tries to find the best cycle in a directed and
|
|
21
|
+
complete graph. In this graph, each node corresponds to an asset and each directed
|
|
22
|
+
edge is weighted with the corresponding conversion rate.
|
|
23
|
+
The problem creates a QUBO with the size
|
|
24
|
+
_(n_nodes * cycle_length) x (n_nodes * cycle_length)_, which produces a solution
|
|
25
|
+
vector where each binary position maps to to a node and its position in the cycle.
|
|
26
|
+
|
|
27
|
+
Links
|
|
28
|
+
-----
|
|
29
|
+
|
|
30
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Arbitrage)
|
|
31
|
+
|
|
32
|
+
[Transformation](http://1qbit.com/files/white-papers/1QBit-White-Paper-%E2%80%93-Finding-Optimal-Arbitrage-Opportunities-Using-a-Quantum-Annealer.pdf)
|
|
33
|
+
|
|
34
|
+
Attributes
|
|
35
|
+
----------
|
|
36
|
+
### graph: Dict[str, Dict[str, Dict[str, float]]]
|
|
37
|
+
\n The input graph as described above in the form of nested dictionaries.
|
|
38
|
+
\n Example for three different currencies:\n
|
|
39
|
+
\n _{_
|
|
40
|
+
\n _0: {1: {'weight': 1.31904}, 2: {'weight': 6.72585}},_
|
|
41
|
+
\n _1: {0: {'weight': 0.75799}, 2: {'weight': 5.10327},_
|
|
42
|
+
\n _2: {0: {'weight': 0.14864}, 1: {'weight': 0.19586}}_
|
|
43
|
+
\n _}_
|
|
44
|
+
|
|
45
|
+
### penalty: Optional[float] = None
|
|
46
|
+
\n The penalty term for the QUBO matrix. Has to be greater than 0.
|
|
47
|
+
|
|
48
|
+
### K: Optional[int] = None
|
|
49
|
+
\n The maximum length of the arbitrage cycle.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
name: Literal["ANB"] = "ANB"
|
|
53
|
+
graph: dict[str, dict[str, dict[str, float]]] = Field(name="graph") # type: ignore[call-overload]
|
|
54
|
+
penalty: float | None = None
|
|
55
|
+
K: int | None = None
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Literal
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.use_cases.base import UseCase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BinaryIntegerLinearProgramming(UseCase):
|
|
9
|
+
r"""
|
|
10
|
+
# Binary Integer Linear Programming.
|
|
11
|
+
|
|
12
|
+
Description
|
|
13
|
+
-----------
|
|
14
|
+
|
|
15
|
+
For a binary decision vector _x_ and some vector _c_ of length _N_, the Binary
|
|
16
|
+
Integer Linear Programming problem maximizes _c * x_, given the constraint _Sx = b_
|
|
17
|
+
with _S_ being an _m x N_ matrix and _b_ a vector with _m_ components.
|
|
18
|
+
|
|
19
|
+
Q-Bit Interpretation
|
|
20
|
+
--------------------
|
|
21
|
+
|
|
22
|
+
The vector of qubits is simply the decision vector _x_.
|
|
23
|
+
|
|
24
|
+
Links
|
|
25
|
+
-----
|
|
26
|
+
|
|
27
|
+
[Wikipedia](https://en.wikipedia.org/wiki/Integer_programming)
|
|
28
|
+
|
|
29
|
+
[Transformation](https://arxiv.org/pdf/1302.5843.pdf)
|
|
30
|
+
|
|
31
|
+
Attributes
|
|
32
|
+
----------
|
|
33
|
+
### S: List[List[int]]
|
|
34
|
+
\n The _m x N_ matrix.
|
|
35
|
+
|
|
36
|
+
### b: List[int]
|
|
37
|
+
\n Vector with _m_ components.
|
|
38
|
+
|
|
39
|
+
### c: List[int]
|
|
40
|
+
\n Custom vector of length _N_.
|
|
41
|
+
|
|
42
|
+
### A: int
|
|
43
|
+
\n A constant enforcing, if possible, that _Sx = b_.
|
|
44
|
+
|
|
45
|
+
### B: int
|
|
46
|
+
\n A constant (_B << A_) helping maximize _c * x_.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
name: Literal["BIP"] = "BIP"
|
|
50
|
+
S: list[list[int]]
|
|
51
|
+
b: list[int]
|
|
52
|
+
c: list[int]
|
|
53
|
+
A: int = 10
|
|
54
|
+
B: int = 2
|