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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.solve.interfaces.backend_i import IBackend
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IBM(IBackend):
|
|
9
|
+
"""IBM quantum backend configuration.
|
|
10
|
+
|
|
11
|
+
This class provides configuration options for IBM quantum backends, supporting
|
|
12
|
+
both local simulators and fake provider backends for quantum algorithm execution.
|
|
13
|
+
The configuration allows users to specify which type of backend to use without
|
|
14
|
+
requiring an IBM token for simulator-based execution.
|
|
15
|
+
|
|
16
|
+
The class supports two main backend types:
|
|
17
|
+
|
|
18
|
+
- Simulator backends: Execute quantum algorithms locally using simulators
|
|
19
|
+
- Fake provider backends: Use IBM's fake backends for testing and development
|
|
20
|
+
|
|
21
|
+
Attributes
|
|
22
|
+
----------
|
|
23
|
+
backend : SimulatorBackend | FakeProviderBackend
|
|
24
|
+
The backend configuration, defaults to AER simulator.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
class SimulatorBackend(BaseModel):
|
|
28
|
+
"""Qiskit Statevector Simulator.
|
|
29
|
+
|
|
30
|
+
Use a simulator as backend. The QAOA is executed completely on our server, and
|
|
31
|
+
no IBM token is required.
|
|
32
|
+
|
|
33
|
+
Attributes
|
|
34
|
+
----------
|
|
35
|
+
backend_name: Literal['aer', 'statevector']
|
|
36
|
+
Which simulator to use. Currently, `AerSimulator` from `qiskit_aer`
|
|
37
|
+
and the statevector simulator from `qiskit.primitives` are available.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
backend_type: Literal["simulator"] = "simulator"
|
|
41
|
+
backend_name: Literal["aer", "statevector"] = "aer"
|
|
42
|
+
|
|
43
|
+
class FakeProviderBackend(BaseModel):
|
|
44
|
+
"""Simulator with emulated QPU noise model.
|
|
45
|
+
|
|
46
|
+
The Qiskit fake provider runs a simulation with a noise model derived from
|
|
47
|
+
an actual QPU hardware implementation.
|
|
48
|
+
See [IBM documentation](
|
|
49
|
+
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime/fake-provider) for
|
|
50
|
+
available “fake” devices.
|
|
51
|
+
|
|
52
|
+
Use a V2 fake backend from `qiskit_ibm_runtime.fake_provider`. The QAOA is
|
|
53
|
+
executed entirely on our server, and no IBM token is required.
|
|
54
|
+
|
|
55
|
+
Attributes
|
|
56
|
+
----------
|
|
57
|
+
backend_name: str
|
|
58
|
+
Which backend to use
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
backend_type: Literal["fake_provider"] = "fake_provider"
|
|
62
|
+
backend_name: Literal[
|
|
63
|
+
"FakeAlgiers",
|
|
64
|
+
"FakeAlmadenV2",
|
|
65
|
+
"FakeArmonkV2",
|
|
66
|
+
"FakeAthensV2",
|
|
67
|
+
"FakeAuckland",
|
|
68
|
+
"FakeBelemV2",
|
|
69
|
+
"FakeBoeblingenV2",
|
|
70
|
+
"FakeBogotaV2",
|
|
71
|
+
"FakeBrisbane",
|
|
72
|
+
"FakeBrooklynV2",
|
|
73
|
+
"FakeBurlingtonV2",
|
|
74
|
+
"FakeCairoV2",
|
|
75
|
+
"FakeCambridgeV2",
|
|
76
|
+
"FakeCasablancaV2",
|
|
77
|
+
"FakeCusco",
|
|
78
|
+
"FakeEssexV2",
|
|
79
|
+
"FakeFez",
|
|
80
|
+
"FakeFractionalBackend",
|
|
81
|
+
"FakeGeneva",
|
|
82
|
+
"FakeGuadalupeV2",
|
|
83
|
+
"FakeHanoiV2",
|
|
84
|
+
"FakeJakartaV2",
|
|
85
|
+
"FakeJohannesburgV2",
|
|
86
|
+
"FakeKawasaki",
|
|
87
|
+
"FakeKolkataV2",
|
|
88
|
+
"FakeKyiv",
|
|
89
|
+
"FakeKyoto",
|
|
90
|
+
"FakeLagosV2",
|
|
91
|
+
"FakeLimaV2",
|
|
92
|
+
"FakeLondonV2",
|
|
93
|
+
"FakeManhattanV2",
|
|
94
|
+
"FakeManilaV2",
|
|
95
|
+
"FakeMarrakesh",
|
|
96
|
+
"FakeMelbourneV2",
|
|
97
|
+
"FakeMontrealV2",
|
|
98
|
+
"FakeMumbaiV2",
|
|
99
|
+
"FakeNairobiV2",
|
|
100
|
+
"FakeOsaka",
|
|
101
|
+
"FakeOslo",
|
|
102
|
+
"FakeOurenseV2",
|
|
103
|
+
"FakeParisV2",
|
|
104
|
+
"FakePeekskill",
|
|
105
|
+
"FakePerth",
|
|
106
|
+
"FakePrague",
|
|
107
|
+
"FakePoughkeepsieV2",
|
|
108
|
+
"FakeQuebec",
|
|
109
|
+
"FakeQuitoV2",
|
|
110
|
+
"FakeRochesterV2",
|
|
111
|
+
"FakeRomeV2",
|
|
112
|
+
"FakeSantiagoV2",
|
|
113
|
+
"FakeSherbrooke",
|
|
114
|
+
"FakeSingaporeV2",
|
|
115
|
+
"FakeSydneyV2",
|
|
116
|
+
"FakeTorino",
|
|
117
|
+
"FakeTorontoV2",
|
|
118
|
+
"FakeValenciaV2",
|
|
119
|
+
"FakeVigoV2",
|
|
120
|
+
"FakeWashingtonV2",
|
|
121
|
+
"FakeYorktownV2",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
backend: SimulatorBackend | FakeProviderBackend = Field(
|
|
125
|
+
default=SimulatorBackend(), discriminator="backend_type"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def provider(self) -> str:
|
|
130
|
+
"""
|
|
131
|
+
Retrieve the name of the provider.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
str
|
|
136
|
+
The name of the provider.
|
|
137
|
+
"""
|
|
138
|
+
return "ibm"
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
from luna_quantum.client.schemas import QpuToken, QpuTokenSource, TokenProvider
|
|
6
|
+
from luna_quantum.solve.domain.abstract import QpuTokenBackend
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Qctrl(QpuTokenBackend):
|
|
10
|
+
"""
|
|
11
|
+
Configuration parameters for Q-CTRL`s Fire Opal Backend.
|
|
12
|
+
|
|
13
|
+
QAOA (Quantum Approximate Optimization Algorithm) is a quantum algorithm designed
|
|
14
|
+
for combinatorial optimization problems. This implementation leverages Q-CTRL's
|
|
15
|
+
Fire Opal framework, which optimizes QAOA execution on quantum hardware to reduce
|
|
16
|
+
errors and improve solution quality.
|
|
17
|
+
|
|
18
|
+
Fire Opal's hardware-tailored optimizations enable solving larger problems with
|
|
19
|
+
better convergence in fewer iterations, reducing overall execution time on real
|
|
20
|
+
quantum devices.
|
|
21
|
+
|
|
22
|
+
Attributes
|
|
23
|
+
----------
|
|
24
|
+
organization_slug: str | None, default=None
|
|
25
|
+
Organization identifier from your Q-CTRL account. Required only if you belong
|
|
26
|
+
to multiple organizations. This can be retrieved from your Q-CTRL account
|
|
27
|
+
settings or dashboard.
|
|
28
|
+
|
|
29
|
+
backend_name: str | None, default=None
|
|
30
|
+
The IBM Quantum backend to use for computations:
|
|
31
|
+
- Specific backend: e.g., 'ibm_fez', 'ibm_marrakesh'
|
|
32
|
+
- 'least_busy': Automatically selects the least busy available backend
|
|
33
|
+
- 'basic_simulator': Uses the basic simulator (default if None)
|
|
34
|
+
Check your IBM Quantum account for available backends.
|
|
35
|
+
|
|
36
|
+
ibm_credentials: IBMQ | IBMCloud
|
|
37
|
+
The IBM backend credentials, i.e. how to access the IBM service. Q-Ctrl
|
|
38
|
+
currently supports two mehtods, via the old IBMQ pattern or the new IBMCloud
|
|
39
|
+
pattern. Default is Qctrl.IBMQ()
|
|
40
|
+
|
|
41
|
+
token: QpuToken | str | None, default=None
|
|
42
|
+
The Q-Ctrl API token.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Notes
|
|
46
|
+
-----
|
|
47
|
+
For detailed information about Fire Opal's QAOA solver and its capabilities,
|
|
48
|
+
see [Q-CTRL's documentation](
|
|
49
|
+
https://docs.q-ctrl.com/fire-opal/topics/fire-opals-qaoa-solver)
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
class IBMCloud(BaseModel):
|
|
53
|
+
"""
|
|
54
|
+
Configuration parameters for the IBM Cloud backend.
|
|
55
|
+
|
|
56
|
+
Attributes
|
|
57
|
+
----------
|
|
58
|
+
instance: str
|
|
59
|
+
The Qiskit runtime instance CRN (Cloud Resource Name).
|
|
60
|
+
|
|
61
|
+
token: Union[str, None, QpuToken], default=None
|
|
62
|
+
The IBM API token.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
instance: str = ""
|
|
66
|
+
|
|
67
|
+
token: str | QpuToken | None = Field(repr=False, exclude=True, default=None)
|
|
68
|
+
|
|
69
|
+
organization_slug: Any = None
|
|
70
|
+
backend_name: str | None = None
|
|
71
|
+
|
|
72
|
+
ibm_credentials: IBMCloud = Field(default=IBMCloud())
|
|
73
|
+
|
|
74
|
+
token: str | QpuToken | None = Field(repr=False, exclude=True, default=None)
|
|
75
|
+
|
|
76
|
+
def _get_token(self) -> TokenProvider | None:
|
|
77
|
+
if self.token is None or self.ibm_credentials.token is None:
|
|
78
|
+
return None
|
|
79
|
+
qctrl_token = (
|
|
80
|
+
self.token
|
|
81
|
+
if isinstance(self.token, QpuToken)
|
|
82
|
+
else QpuToken(source=QpuTokenSource.INLINE, token=self.token)
|
|
83
|
+
)
|
|
84
|
+
ibm_token = (
|
|
85
|
+
self.ibm_credentials.token
|
|
86
|
+
if isinstance(self.ibm_credentials.token, QpuToken)
|
|
87
|
+
else QpuToken(
|
|
88
|
+
source=QpuTokenSource.INLINE, token=self.ibm_credentials.token
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
return TokenProvider(qctrl=qctrl_token, ibm=ibm_token)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def provider(self) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Retrieve the name of the provider.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
str
|
|
101
|
+
The name of the provider.
|
|
102
|
+
"""
|
|
103
|
+
return "qctrl"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from luna_quantum.solve.interfaces.backend_i import IBackend
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ZIB(IBackend):
|
|
5
|
+
"""Configuration class for the ZIB backend."""
|
|
6
|
+
|
|
7
|
+
@property
|
|
8
|
+
def provider(self) -> str:
|
|
9
|
+
"""
|
|
10
|
+
Retrieve the name of the provider.
|
|
11
|
+
|
|
12
|
+
Returns
|
|
13
|
+
-------
|
|
14
|
+
str
|
|
15
|
+
The name of the provider.
|
|
16
|
+
"""
|
|
17
|
+
return "zib"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# The default absolute tolerance that should be used for `numpy.isclose(...)`
|
|
2
|
+
# calls. Equal to the default used in `numpy.isclose(..)`.
|
|
3
|
+
DEFAULT_ATOL: float = 1.0e-8
|
|
4
|
+
|
|
5
|
+
# The default relative tolerance that should be used for ``numpy.isclose(...)``
|
|
6
|
+
# calls. Equal to the default used in ``numpy.isclose(..)``.
|
|
7
|
+
DEFAULT_RTOL: float = 1.0e-5
|
|
8
|
+
|
|
9
|
+
# The default timeout used for solver run with a specified target.
|
|
10
|
+
# Number of seconds before routine halts. Default is 2592000 for dimod.qbsolv.
|
|
11
|
+
DEFAULT_TIMEOUT: int = 10
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from luna_quantum.solve.errors.solve_base_error import SolveBaseError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class QAOAParameterOptimizerError(SolveBaseError):
|
|
5
|
+
"""QAOA cirucit parameters mismatch with optimizer exception."""
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
optimizer: str,
|
|
10
|
+
params: str,
|
|
11
|
+
extra: str = "",
|
|
12
|
+
) -> None:
|
|
13
|
+
super().__init__(
|
|
14
|
+
f"Parameter Mismatch of '{optimizer}' and '{params}'"
|
|
15
|
+
+ ((": " + extra) if extra else ".")
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class InterpolateOptimizerError(SolveBaseError):
|
|
20
|
+
"""Interpolate optimizer error when final number of reps is too small."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, reps_end: int, reps_start: int) -> None:
|
|
23
|
+
super().__init__(f"{reps_end=} needs to be larger than {reps_start=}.")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class QAOAParameterRepsMismatchError(SolveBaseError):
|
|
27
|
+
"""QAOA circuit params mismatch the specified reps."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, params_reps: int, reps: int) -> None:
|
|
30
|
+
super().__init__(f"{params_reps=} needs to match {reps=}.")
|
|
File without changes
|
|
@@ -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
|