luna-quantum 0.0.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of luna-quantum might be problematic. Click here for more details.

Files changed (160) hide show
  1. luna_quantum-0.0.16.dist-info/LICENSE +201 -0
  2. luna_quantum-0.0.16.dist-info/METADATA +46 -0
  3. luna_quantum-0.0.16.dist-info/RECORD +160 -0
  4. luna_quantum-0.0.16.dist-info/WHEEL +4 -0
  5. luna_sdk/__init__.py +2 -0
  6. luna_sdk/constants.py +1 -0
  7. luna_sdk/controllers/__init__.py +2 -0
  8. luna_sdk/controllers/custom_login_client.py +61 -0
  9. luna_sdk/controllers/luna_platform_client.py +62 -0
  10. luna_sdk/controllers/luna_q.py +36 -0
  11. luna_sdk/controllers/luna_solve.py +49 -0
  12. luna_sdk/controllers/luna_transform.py +41 -0
  13. luna_sdk/error/__init__.py +0 -0
  14. luna_sdk/error/http_error_utils.py +100 -0
  15. luna_sdk/exceptions/__init__.py +1 -0
  16. luna_sdk/exceptions/encryption_exception.py +6 -0
  17. luna_sdk/exceptions/luna_exception.py +7 -0
  18. luna_sdk/exceptions/luna_server_exception.py +18 -0
  19. luna_sdk/exceptions/timeout_exception.py +10 -0
  20. luna_sdk/exceptions/transformation.py +11 -0
  21. luna_sdk/interfaces/__init__.py +5 -0
  22. luna_sdk/interfaces/circuit_repo_i.py +62 -0
  23. luna_sdk/interfaces/clients/__init__.py +0 -0
  24. luna_sdk/interfaces/clients/client_i.py +10 -0
  25. luna_sdk/interfaces/clients/luna_q_i.py +39 -0
  26. luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
  27. luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
  28. luna_sdk/interfaces/cplex_repo_i.py +121 -0
  29. luna_sdk/interfaces/info_repo_i.py +40 -0
  30. luna_sdk/interfaces/lp_repo_i.py +106 -0
  31. luna_sdk/interfaces/optimization_repo_i.py +262 -0
  32. luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
  33. luna_sdk/interfaces/repository_i.py +14 -0
  34. luna_sdk/interfaces/solutions_repo_i.py +219 -0
  35. luna_sdk/py.typed +0 -0
  36. luna_sdk/repositories/__init__.py +4 -0
  37. luna_sdk/repositories/circuit_repo.py +104 -0
  38. luna_sdk/repositories/cplex_repo.py +118 -0
  39. luna_sdk/repositories/info_repo.py +45 -0
  40. luna_sdk/repositories/lp_repo.py +105 -0
  41. luna_sdk/repositories/optimization_repo.py +358 -0
  42. luna_sdk/repositories/qpu_token_repo.py +226 -0
  43. luna_sdk/repositories/solutions_repo.py +347 -0
  44. luna_sdk/schemas/__init__.py +4 -0
  45. luna_sdk/schemas/circuit.py +43 -0
  46. luna_sdk/schemas/create/__init__.py +3 -0
  47. luna_sdk/schemas/create/circuit.py +29 -0
  48. luna_sdk/schemas/create/optimization.py +22 -0
  49. luna_sdk/schemas/create/qpu_token.py +26 -0
  50. luna_sdk/schemas/create/qubo.py +19 -0
  51. luna_sdk/schemas/create/solution.py +15 -0
  52. luna_sdk/schemas/enums/__init__.py +0 -0
  53. luna_sdk/schemas/enums/circuit.py +14 -0
  54. luna_sdk/schemas/enums/optimization.py +10 -0
  55. luna_sdk/schemas/enums/problem.py +48 -0
  56. luna_sdk/schemas/enums/qpu_token_type.py +6 -0
  57. luna_sdk/schemas/enums/solution.py +8 -0
  58. luna_sdk/schemas/enums/status.py +10 -0
  59. luna_sdk/schemas/enums/timeframe.py +11 -0
  60. luna_sdk/schemas/error_message.py +12 -0
  61. luna_sdk/schemas/optimization.py +75 -0
  62. luna_sdk/schemas/optimization_formats/__init__.py +0 -0
  63. luna_sdk/schemas/optimization_formats/bqm.py +34 -0
  64. luna_sdk/schemas/optimization_formats/cqm.py +127 -0
  65. luna_sdk/schemas/optimization_formats/lp.py +9 -0
  66. luna_sdk/schemas/optimization_formats/qm.py +30 -0
  67. luna_sdk/schemas/pretty_base.py +49 -0
  68. luna_sdk/schemas/qpu_token.py +60 -0
  69. luna_sdk/schemas/representation.py +19 -0
  70. luna_sdk/schemas/rest/__init__.py +0 -0
  71. luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
  72. luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
  73. luna_sdk/schemas/solution.py +227 -0
  74. luna_sdk/schemas/solver_info.py +11 -0
  75. luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
  76. luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
  77. luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
  78. luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
  79. luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
  80. luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
  81. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
  82. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
  83. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
  84. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
  85. luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
  86. luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
  87. luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
  88. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
  89. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
  90. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
  91. luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
  92. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
  93. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
  94. luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
  95. luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
  96. luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
  97. luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
  98. luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
  99. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
  100. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
  101. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
  102. luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
  103. luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
  104. luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
  105. luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
  106. luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
  107. luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
  108. luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
  109. luna_sdk/schemas/transformations/__init__.py +2 -0
  110. luna_sdk/schemas/transformations/bqm.py +33 -0
  111. luna_sdk/schemas/transformations/matrix.py +12 -0
  112. luna_sdk/schemas/use_cases/__init__.py +54 -0
  113. luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
  114. luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
  115. luna_sdk/schemas/use_cases/base.py +5 -0
  116. luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
  117. luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
  118. luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
  119. luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
  120. luna_sdk/schemas/use_cases/exact_cover.py +50 -0
  121. luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
  122. luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
  123. luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
  124. luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
  125. luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
  126. luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
  127. luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
  128. luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
  129. luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
  130. luna_sdk/schemas/use_cases/linear_regression.py +59 -0
  131. luna_sdk/schemas/use_cases/lmwcs.py +80 -0
  132. luna_sdk/schemas/use_cases/longest_path.py +49 -0
  133. luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
  134. luna_sdk/schemas/use_cases/max2sat.py +51 -0
  135. luna_sdk/schemas/use_cases/max3sat.py +52 -0
  136. luna_sdk/schemas/use_cases/max_clique.py +59 -0
  137. luna_sdk/schemas/use_cases/max_cut.py +47 -0
  138. luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
  139. luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
  140. luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
  141. luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
  142. luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
  143. luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
  144. luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
  145. luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
  146. luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
  147. luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
  148. luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
  149. luna_sdk/schemas/use_cases/set_cover.py +55 -0
  150. luna_sdk/schemas/use_cases/set_packing.py +53 -0
  151. luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
  152. luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
  153. luna_sdk/schemas/use_cases/subset_sum.py +36 -0
  154. luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
  155. luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
  156. luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
  157. luna_sdk/schemas/use_cases/type_aliases.py +11 -0
  158. luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
  159. luna_sdk/utils/__init__.py +0 -0
  160. luna_sdk/utils/qpu_tokens.py +52 -0
@@ -0,0 +1,37 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import (
4
+ Decomposer,
5
+ FixedTemperatureSampler,
6
+ Loop,
7
+ Qpu,
8
+ )
9
+
10
+
11
+ class ParallelTemperingQpuParameters(BaseModel):
12
+ """
13
+ Parallel Tempering uses multiple optimization procedures per temperature. During the cooling process,
14
+ an exchange of replicas can take place between the parallel procedures, thus enabling higher energy mountains to be overcome.
15
+
16
+ Parameters
17
+ ----------
18
+ n_replicas: int
19
+ Number of replicas for the parallel tempering.
20
+ decomposer: Decomposer
21
+ Parameters for the decomposer.
22
+ qpu: Qpu
23
+ Parameters for the QPU.
24
+ fixed_temperature_sampler: FixedTemperatureSampler
25
+ Parameters for the fixed temperature sampler.
26
+ cpu_count_multiplier: int
27
+ Multiplier for the CPU count.
28
+ loop: Loop
29
+ Parameters for the main loop of the algorithm.
30
+ """
31
+
32
+ n_replicas: int = 4
33
+ decomposer: Decomposer = Decomposer()
34
+ qpu: Qpu = Qpu()
35
+ fixed_temperature_sampler: FixedTemperatureSampler = FixedTemperatureSampler()
36
+ cpu_count_multiplier: int = 5
37
+ loop: Loop = Loop()
@@ -0,0 +1,25 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import FixedTemperatureSampler
4
+
5
+
6
+ class PopulationAnnealingParameters(BaseModel):
7
+ """
8
+ Population Annealing uses a sequential Monte Carlo method to minimize the energy of a population.
9
+ The population consists of walkers that can explore their neighborhood during the cooling process.
10
+ Afterwards, walkers are removed and duplicated using bias to lower energy.
11
+ Eventually, a population collapse occurs where all walkers are in the lowest energy state.
12
+
13
+ Parameters
14
+ ----------
15
+ fixed_temperature_sampler: FixedTemperatureSampler
16
+ Parameters for the fixed temperature sampler.
17
+ max_iter: int
18
+ Maximum number of iterations. Default is 20.
19
+ max_time: int
20
+ Maximum time in seconds that the algorithm is allowed to run. Default is 2.
21
+ """
22
+
23
+ fixed_temperature_sampler: FixedTemperatureSampler = FixedTemperatureSampler()
24
+ max_iter: int = 20
25
+ max_time: int = 2
@@ -0,0 +1,35 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import (
4
+ Decomposer,
5
+ FixedTemperatureSampler,
6
+ Qpu,
7
+ )
8
+
9
+
10
+ class PopulationAnnealingQpuParameters(BaseModel):
11
+ """
12
+ Population Annealing uses a sequential Monte Carlo method to minimize the energy of a population.
13
+ The population consists of walkers that can explore their neighborhood during the cooling process.
14
+ Afterwards, walkers are removed and duplicated using bias to lower energy.
15
+ Eventually, a population collapse occurs where all walkers are in the lowest energy state.
16
+
17
+ Parameters
18
+ ----------
19
+ decomposer: Decomposer
20
+ Parameters for the decomposer, which selects variables for the graph search to stop.
21
+ qpu: Qpu
22
+ Parameters for the Quantum Processing Unit (QPU).
23
+ fixed_temperature_sampler: FixedTemperatureSampler
24
+ Parameters for the fixed temperature sampler.
25
+ max_iter: int
26
+ Maximum number of iterations.
27
+ max_time: int
28
+ Maximum time in seconds that the algorithm is allowed to run.
29
+ """
30
+
31
+ decomposer: Decomposer = Decomposer()
32
+ qpu: Qpu = Qpu()
33
+ fixed_temperature_sampler: FixedTemperatureSampler = FixedTemperatureSampler()
34
+ max_iter: int = 20
35
+ max_time: int = 2
@@ -0,0 +1,56 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, Field
4
+ from typing_extensions import Literal
5
+
6
+
7
+ class QAGAParameters(BaseModel):
8
+ """
9
+ Parameters for the Quantum Assisted Genetic Algorithm (QAGA).
10
+ QAGA combines the principles of genetic algorithms and quantum annealing to solve optimization problems.
11
+
12
+ Parameters
13
+ ----------
14
+ p_size: int
15
+ Size of the population.
16
+ p_inc_num: int
17
+ Number of individuals that are added to the population size after each iteration.
18
+ p_max: Optional[int]
19
+ Maximum size of the population.
20
+ pct_random_states: float
21
+ Percentage of random states that are added to the population after each iteration.
22
+ mut_rate: float
23
+ Mutation rate, i.e., probability to mutate an individual. Min: 0.0, Max: 1.0
24
+ rec_rate: int
25
+ Recombination rate, i.e. number of mates each individual is recombined with after each iteration
26
+ rec_method: Literal['cluster_moves', 'one_point_crossover', 'random_crossover']
27
+ The recombination method for the genetic algorithm.
28
+ select_method: Literal['simple', 'shared_energy']
29
+ Method used for the selection phase in the genetic algorithm.
30
+ target: Optional[float]
31
+ Energy level that the algorithm tries to reach. If `None`, the algorithm will run until any other stopping criterion is reached.
32
+ atol: float
33
+ Absolute tolerance used to compare the energies of the target and the individuals.
34
+ rtol: float
35
+ Relative tolerance used to compare the energies of the target and the individuals.
36
+ timeout: float
37
+ The total solving time after which the solver should be stopped. This total solving time includes preprocessing, network overhead when communicating with DWave's API, as well as the actual annealing time.
38
+ max_iter: Optional[int]
39
+ Maximum number of iterations after which the algorithm will stop.
40
+ """
41
+
42
+ p_size: int = 20
43
+ p_inc_num: int = 5
44
+ p_max: Optional[int] = 160
45
+ pct_random_states: float = 0.25
46
+ mut_rate: float = Field(default=0.5, ge=0.0, le=1.0)
47
+ rec_rate: int = 1
48
+ rec_method: Literal["cluster_moves", "one_point_crossover", "random_crossover"] = (
49
+ "random_crossover"
50
+ )
51
+ select_method: Literal["simple", "shared_energy"] = "simple"
52
+ target: Optional[float] = None
53
+ atol: float = 0.0
54
+ rtol: float = 0.0
55
+ timeout: float = 60.0
56
+ max_iter: Optional[int] = 100
@@ -0,0 +1,19 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import QBSOLVLike, Qpu
4
+
5
+
6
+ class QbSolvLikeQpuParameters(BaseModel):
7
+ """
8
+ QBSolv QPU splits the problem into parts and solves them using the Tabu Search algorithm. For this purpose, the DWaveSampler is used.
9
+
10
+ Parameters
11
+ ----------
12
+ qbsolv_like: QBSOLVLike
13
+ Parameters for the QBSOLV-like solver.
14
+ qpu: Qpu
15
+ QPU parameters
16
+ """
17
+
18
+ qbsolv_like: QBSOLVLike = QBSOLVLike()
19
+ qpu: Qpu = Qpu()
@@ -0,0 +1,22 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import QBSOLVLike, SimulatedAnnealing
4
+
5
+
6
+ class QbSolvLikeSimulatedAnnealingParameters(BaseModel):
7
+ """
8
+ QBSolv Like Simulated Annealing breaks down the problem and solves the parts individually using a classic solver that uses Simulated Annealing.
9
+ This particular implementation uses hybrid.SimulatedAnnealingSubproblemSampler
10
+ (https://docs.ocean.dwavesys.com/projects/hybrid/en/stable/reference/samplers.html#simulatedannealingsubproblemsampler)
11
+ as a sampler for the subproblems to achieve a QBSolv like behaviour.
12
+
13
+ Parameters
14
+ ----------
15
+ qbsolv_like: QBSOLVLike
16
+ Parameters for the QbSolveLike solver.
17
+ simulated_annealing: SimulatedAnnealing
18
+ Parameters for the Simulated Annealing.
19
+ """
20
+
21
+ qbsolv_like: QBSOLVLike = QBSOLVLike()
22
+ simulated_annealing: SimulatedAnnealing = SimulatedAnnealing()
@@ -0,0 +1,21 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import QBSOLVLike, Tabu
4
+
5
+
6
+ class QbSolvLikeTabuSearchParameters(BaseModel):
7
+ """
8
+ QBSolv Like Tabu Search breaks down the problem and solves the parts individually using a classic solver that uses Tabu Search.
9
+ This particular implementation uses hybrid.TabuSubproblemSampler (https://docs.ocean.dwavesys.com/projects/hybrid/en/stable/reference/samplers.html#tabusubproblemsampler)
10
+ as a sampler for the subproblems to achieve a QBSolv like behaviour.
11
+
12
+ Parameters
13
+ ----------
14
+ qbsolv_like: QBSOLVLike
15
+ Parameters for the QbSolveLike solver.
16
+ tabu_search: Tabu
17
+ Parameters for the Tabu Search.
18
+ """
19
+
20
+ qbsolv_like: QBSOLVLike = QBSOLVLike()
21
+ tabu_search: Tabu = Tabu()
@@ -0,0 +1,20 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import Embedding, SamplingParams
4
+
5
+
6
+ class QuantumAnnealingParameters(BaseModel):
7
+ """
8
+ Parameters for the Quantum Annealing solver.
9
+
10
+ Parameters
11
+ ----------
12
+ embedding: Embedding
13
+ Parameters for the auto embedding.
14
+ sampling_params: SamplingParams
15
+ Parameters for the sampling. See https://docs.dwavesys.com/docs/latest/c_solver_parameters.html
16
+ for more details.
17
+ """
18
+
19
+ embedding: Embedding = Embedding()
20
+ sampling_params: SamplingParams = SamplingParams()
@@ -0,0 +1,82 @@
1
+ from typing import Any, Dict, List, Optional
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class RRQuantumAnnealingSamplingParams(BaseModel):
7
+ """
8
+ Parameters
9
+ ----------
10
+ anneal_offsets: Optional[Any]
11
+ Anneal offsets for the sampling.
12
+ annealing_time: Optional[Any]
13
+ Annealing time for the sampling.
14
+ auto_scale: Optional[Any]
15
+ Whether to auto scale for the sampling.
16
+ flux_biases: Optional[Any]
17
+ Flux biases for the sampling.
18
+ flux_drift_compensation: bool
19
+ Whether to use flux drift compensation.
20
+ h_gain_schedule: Optional[Any]
21
+ H gain schedule for the sampling.
22
+ max_answers: Optional[int]
23
+ Maximum number of answers for the sampling. Min: 1
24
+ programming_thermalization: Optional[float]
25
+ Programming thermalization for the sampling. Has to be positive.
26
+ readout_thermalization: Optional[float]
27
+ Readout thermalization for the sampling. Has to be positive.
28
+ reduce_intersample_correlation: bool
29
+ Whether to reduce intersample correlation for the sampling.
30
+ """
31
+
32
+ anneal_offsets: Optional[Any] = None
33
+ annealing_time: Optional[Any] = None
34
+ auto_scale: Optional[Any] = None
35
+ flux_biases: Optional[Any] = None
36
+ flux_drift_compensation: bool = True
37
+ h_gain_schedule: Optional[Any] = None
38
+ max_answers: Optional[int] = Field(default=None, ge=1)
39
+ programming_thermalization: Optional[float] = Field(default=None, gt=0)
40
+ readout_thermalization: Optional[float] = Field(default=None, gt=0)
41
+ reduce_intersample_correlation: bool = False
42
+
43
+
44
+ class RepeatedReverseQuantumAnnealingParameters(BaseModel):
45
+ """
46
+ Repeated Reverse Quantum Annealing begins the annealing process from a previously initialized state and increases the temperature from there.
47
+ Afterwards, the temperature is decreased again until the solution is found.
48
+ This procedure is repeated several times with this particular solver. (for additional information see: D-Wave Reverse Annealing)
49
+
50
+ Parameters
51
+ ----------
52
+ sampling_params: RRQuantumAnnealingSamplingParams
53
+ Parameters for the RRQuantumAnnealingSamplingParams. See https://docs.dwavesys.com/docs/latest/c_solver_parameters.html for more details.
54
+ initial_states: Optional[List[Dict[str, int]]]
55
+ Initial states for the solver. For each list element `state`, one call to the sampler with the parameter `initial_state=state` will be made in the first iteration.
56
+ n_initial_states: int
57
+ Number of initial states to create when `initial_states` is None. If `initial_states` is not None, this parameter will be ignored. Min: 1
58
+ samples_per_state: int
59
+ How many samples to create per state in each iteration after the first. Min: 1
60
+ beta_schedule: List[float]
61
+ Beta schedule for the solver.
62
+ timeout: float
63
+ Timeout for the solver.
64
+ max_iter: int
65
+ Maximum number of iterations for the solver.
66
+ target: Optional[Any]
67
+ The target energy for the solving process.
68
+ check_trivial: bool
69
+ Whether to check for trivial variables. Checking for trivial variables means an overhead. On the other hand, when set to `False`, trivial variables, i.e., variables without interactions, will lead to a runtime error.
70
+ """
71
+
72
+ sampling_params: RRQuantumAnnealingSamplingParams = (
73
+ RRQuantumAnnealingSamplingParams()
74
+ )
75
+ initial_states: Optional[List[Dict[str, int]]] = None
76
+ n_initial_states: int = Field(default=1, ge=1)
77
+ samples_per_state: int = Field(default=1, ge=1)
78
+ beta_schedule: List[float] = [0.5, 3]
79
+ timeout: float = 300
80
+ max_iter: int = 10
81
+ target: Optional[Any] = None
82
+ check_trivial: bool = True
@@ -0,0 +1,89 @@
1
+ from typing import Any, List, Optional, Sequence
2
+
3
+ from pydantic import BaseModel, Field
4
+ from typing_extensions import Literal
5
+
6
+ from luna_sdk.schemas.solver_parameters.dwave import SimulatedAnnealing
7
+
8
+
9
+ class RRSimulatedAnnealing(SimulatedAnnealing):
10
+ """
11
+ Parameters
12
+ ----------
13
+ num_reads: Optional[int]
14
+ Number of reads. Each read is generated by one run of the simulated annealing
15
+ algorithm. If `num_reads` is not explicitly given, it is selected to match the
16
+ number of initial states given. If initial states are not provided, only one
17
+ read is performed.
18
+ num_sweeps: Optional[int]
19
+ Number of sweeps used in annealing.
20
+ beta_range: Union[List[float], Tuple[float, float], NoneType]
21
+ A 2-tuple defining the beginning and end of the beta schedule, where beta is the
22
+ inverse temperature. The schedule is applied linearly in beta. Default range is
23
+ set based on the total bias associated with each node.
24
+ beta_schedule_type: Literal['linear', 'geometric']
25
+ Beta schedule type, or how the beta values are interpolated between the given
26
+ 'beta_range'.
27
+ initial_states_generator: Literal['none', 'tile', 'random']
28
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
29
+ specified:
30
+ 'none:' if the number of initial states specified is smaller than `num_reads`,
31
+ raises an error.
32
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
33
+ truncates if greater.
34
+ 'random': expands the specified initial states with randomly generated states if
35
+ fewer than `num_reads` or truncates if greater.
36
+ num_sweeps_per_beta: int
37
+ Number of sweeps to perform at each `beta`. One sweep consists of a sequential
38
+ Metropolis update of all spins.
39
+ beta_schedule: Optional[Sequence[float]]
40
+ Sequence of `beta` values swept. Format must be compatible with
41
+ `numpy.array(beta_schedule, dtype=float)`. Values should be non-negative.
42
+ randomize_order: bool
43
+ When `True`, each spin update selects a variable uniformly at random. This
44
+ method is ergodic, obeys detailed balance and preserves symmetries of the model.
45
+ When `False`, updates proceed sequentially through the labeled variables on each
46
+ sweep so that all variables are updated once per sweep. This method:
47
+ * can be non-ergodic in special cases when used with
48
+ `proposal_acceptance_critera=='Metropolis'`.
49
+ * can introduce a dynamical bias as a function of variable order.
50
+ * has faster per spin update than the True method.
51
+ proposal_acceptance_criteria: Literal['Gibbs', 'Metropolis']
52
+ When 'Gibbs', each spin flip proposal is accepted according to the Gibbs
53
+ criteria. When 'Metropolis', each spin flip proposal is accepted according to
54
+ the Metropolis-Hastings criteria.
55
+ """
56
+
57
+ num_sweeps: Optional[int] = None
58
+ num_sweeps_per_beta: int = 1
59
+ beta_schedule: Optional[Sequence[float]] = None
60
+ randomize_order: bool = False
61
+ proposal_acceptance_criteria: Literal["Gibbs", "Metropolis"] = "Metropolis"
62
+
63
+
64
+ class RepeatedReverseSimulatedAnnealingParameters(BaseModel):
65
+ """
66
+ Parameters for the Repeated Reverse Simulated Annealing solver.
67
+
68
+ Parameters
69
+ ----------
70
+ simulated_annealing: RRSimulatedAnnealing
71
+ Simulated Annealing params in each iteration.
72
+ num_reads_per_iter: Optional[List[int]]
73
+ Number of reads in each iteration. Use `num_reads_per_iter[i]` in iteration `i`, and `num_reads_per_iter[-1]` once the list is exhausted. If the parameter is `None`, fall back to `simulated_annealing.num_reads`. Min length: 1.
74
+ initial_states: Optional[Any]
75
+ One or more samples, each defining an initial state for all the problem variables. Initial states are given one per read, but if fewer than additional values are generated as specified by `initial_states_generator`. See `~dimod.as_samples` for a description of 'samples-like.
76
+ timeout: float
77
+ Timeout for the solver.
78
+ max_iter: int
79
+ Maximum number of iterations for the solver.
80
+ target: Optional[Any]
81
+ The target energy for the solver.
82
+ """
83
+
84
+ simulated_annealing: RRSimulatedAnnealing = RRSimulatedAnnealing()
85
+ num_reads_per_iter: Optional[List[int]] = Field(default=None, min_length=1)
86
+ initial_states: Optional[Any] = None
87
+ timeout: float = 5.0
88
+ max_iter: int = 10
89
+ target: Optional[Any] = None
@@ -0,0 +1,61 @@
1
+ from typing import Any, Literal, Optional, Tuple
2
+
3
+ from pydantic import Field
4
+
5
+ from luna_sdk.schemas.solver_parameters.dwave.qaga import QAGAParameters
6
+
7
+
8
+ class SAGAParameters(QAGAParameters):
9
+ """
10
+ Parameters for the Simulated Annealing Assisted Genetic Algorithm (SAGA).
11
+ SAGA combines the principles of genetic algorithms and simulated annealing to solve optimization problems.
12
+
13
+ Parameters
14
+ ----------
15
+ p_size: int
16
+ Size of the population.
17
+ p_inc_num: int
18
+ Number of individuals that are added to the population size after each iteration.
19
+ p_max: Optional[int]
20
+ Maximum size of the population.
21
+ pct_random_states: float
22
+ Percentage of random states that are added to the population after each iteration.
23
+ mut_rate: float
24
+ Mutation rate, i.e., probability to mutate an individual. Min: 0.0, Max: 1.0
25
+ rec_rate: int
26
+ Recombination rate, i.e. number of mates each individual is recombined with after each iteration
27
+ rec_method: Literal['cluster_moves', 'one_point_crossover', 'random_crossover']
28
+ The recombination method for the genetic algorithm.
29
+ select_method: Literal['simple', 'shared_energy']
30
+ Method used for the selection phase in the genetic algorithm.
31
+ target: Optional[float]
32
+ Energy level that the algorithm tries to reach. If `None`, the algorithm will run until any other stopping criterion is reached.
33
+ atol: float
34
+ Absolute tolerance used to compare the energies of the target and the individuals.
35
+ rtol: float
36
+ Relative tolerance used to compare the energies of the target and the individuals.
37
+ timeout: float
38
+ The total solving time after which the solver should be stopped. This total solving time includes preprocessing, network overhead when communicating with DWave's API, as well as the actual annealing time.
39
+ max_iter: Optional[int]
40
+ Maximum number of iterations after which the algorithm will stop.
41
+ num_sweeps: int
42
+ The number of sweeps for simulated annealing.
43
+ num_sweeps_inc_factor: float
44
+ factor of increasement for `num_sweeps` after each iteration
45
+ num_sweeps_inc_max: Optional[int]
46
+ Maximum number of num_sweeps that may be reached when increasing the `num_sweeps` value.
47
+ beta_range_type: Literal['default', 'percent', 'fixed', 'inc']
48
+ Method that is used to compute the beta range.
49
+ default': the same as percent with values [50, 1]
50
+ 'percent': the percentage chance of flipping qubits from hot to cold temperature
51
+ 'fixed': a fixed temperature as a value
52
+ 'inc': the default or percentage beta range but with decreasing percentages from iteration to iteration
53
+ beta_range: Optional[Tuple[float, float]]
54
+ Explicit beta range that is used for beta_range_type 'fixed' and 'percent'.
55
+ """
56
+
57
+ num_sweeps: int = 10
58
+ num_sweeps_inc_factor: float = 1.2
59
+ num_sweeps_inc_max: Optional[int] = 7_000
60
+ beta_range_type: Literal["default", "percent", "fixed", "inc"] = "default"
61
+ beta_range: Optional[Tuple[float, float]] = None
@@ -0,0 +1,74 @@
1
+ from typing import Any, Optional, Sequence
2
+
3
+ from typing_extensions import Literal
4
+
5
+ from luna_sdk.schemas.solver_parameters.dwave import SimulatedAnnealing
6
+
7
+
8
+ class SimulatedAnnealingParameters(SimulatedAnnealing):
9
+ """
10
+ Simulated Annealing finds the solution to a problem using a annealing process.
11
+ Initially, random states are chosen in the solution landscape.
12
+ Afterwards, as the temperature decreases, states are chosen that are more energetically favorable.
13
+ At the end of the complete annealing process, the resulting states make up the solution.
14
+
15
+ Parameters
16
+ ----------
17
+ num_reads: Optional[int]
18
+ Number of reads. Each read is generated by one run of the simulated annealing
19
+ algorithm. If `num_reads` is not explicitly given, it is selected to match the
20
+ number of initial states given. If initial states are not provided, only one
21
+ read is performed.
22
+ num_sweeps: Optional[int]
23
+ Number of sweeps used in annealing.
24
+ beta_range: Union[List[float], Tuple[float, float], NoneType]
25
+ A 2-tuple defining the beginning and end of the beta schedule, where beta is the
26
+ inverse temperature. The schedule is applied linearly in beta. Default range is
27
+ set based on the total bias associated with each node.
28
+ beta_schedule_type: Literal['linear', 'geometric']
29
+ Beta schedule type, or how the beta values are interpolated between the given
30
+ 'beta_range'.
31
+ initial_states_generator: Literal['none', 'tile', 'random']
32
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
33
+ specified:
34
+ 'none:' if the number of initial states specified is smaller than `num_reads`,
35
+ raises an error.
36
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
37
+ truncates if greater.
38
+ 'random': expands the specified initial states with randomly generated states if
39
+ fewer than `num_reads` or truncates if greater.
40
+ num_sweeps_per_beta: int
41
+ Number of sweeps to perform at each `beta`. One sweep consists of a sequential
42
+ Metropolis update of all spins.
43
+ seed: Optional[int]
44
+ Seed to use for the PRNG. Specifying a particular seed with a constant set of
45
+ parameters produces identical results. If not provided, a random seed is chosen.
46
+ beta_schedule: Optional[Sequence[float]]
47
+ Sequence of `beta` values swept. Format must be compatible with
48
+ `numpy.array(beta_schedule, dtype=float)`. Values should be non-negative.
49
+ initial_states: Optional[Any]
50
+ One or more samples, each defining an initial state for all the problem
51
+ variables. Initial states are given one per read, but if fewer than additional
52
+ values are generated as specified by `initial_states_generator`. See
53
+ `~dimod.as_samples` for a description of 'samples-like.
54
+ randomize_order: bool
55
+ When `True`, each spin update selects a variable uniformly at random. This
56
+ method is ergodic, obeys detailed balance and preserves symmetries of the model.
57
+ When `False`, updates proceed sequentially through the labeled variables on each
58
+ sweep so that all variables are updated once per sweep. This method:
59
+ * can be non-ergodic in special cases when used with
60
+ `proposal_acceptance_critera=='Metropolis'`.
61
+ * can introduce a dynamical bias as a function of variable order.
62
+ * has faster per spin update than the True method.
63
+ proposal_acceptance_criteria: Literal['Gibbs', 'Metropolis']
64
+ When 'Gibbs', each spin flip proposal is accepted according to the Gibbs
65
+ criteria. When 'Metropolis', each spin flip proposal is accepted according to
66
+ the Metropolis-Hastings criteria.
67
+ """
68
+
69
+ num_sweeps_per_beta: int = 1
70
+ seed: Optional[int] = None
71
+ beta_schedule: Optional[Sequence[float]] = None
72
+ initial_states: Optional[Any] = None
73
+ randomize_order: bool = False
74
+ proposal_acceptance_criteria: Literal["Gibbs", "Metropolis"] = "Metropolis"
@@ -0,0 +1,72 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class TabuSearchParameters(BaseModel):
7
+ """
8
+ Tabu Search is a heuristic optimization method that works with the help of a tabu list.
9
+ Initially, random states are chosen in the solution landscape.
10
+ Afterwards, an iterative search for energetically better states in the neighborhood is started from these states.
11
+ According to a tabu strategy, states are added to the tabu list that are not allowed to be selected as successor states for a tabu duration.
12
+ The tabu search ends as soon as there are no better successor states in the neighborhood.
13
+ The resulting state is therefore the solution to the problem.
14
+
15
+ Parameters
16
+ ----------
17
+ num_reads: Optional[int]
18
+ Number of reads. Each read is generated by one run of the tabu algorithm. If
19
+ `num_reads` is not explicitly given, it is selected to match the number of
20
+ initial states given. If initial states are not provided, only one read is
21
+ performed.
22
+ tenure: Optional[int]
23
+ Tabu tenure, which is the length of the tabu list, or number of recently
24
+ explored solutions kept in memory. Default is a quarter of the number of problem
25
+ variables up to a maximum value of 20.
26
+ timeout: float
27
+ Maximum running time per read in milliseconds.
28
+ initial_states_generator: Literal['none', 'tile', 'random']
29
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
30
+ specified:
31
+ 'none': if the number of initial states specified is smaller than `num_reads`,
32
+ raises ``ValueError``.
33
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
34
+ truncates if greater.
35
+ 'random': expands the specified initial states with randomly generated states if
36
+ fewer than `num_reads` or truncates if greater.
37
+ initial_states: Optional[Any]
38
+ One or more samples, each defining an initial state for all the problem
39
+ variables. Initial states are given one per read, but if fewer than `num_reads`
40
+ initial states are defined, additional values are generated as specified by
41
+ `initial_states_generator`.
42
+ seed: Optional[int]
43
+ 32-bit unsigned integer seed to use for the PRNG. If the `timeout` parameter is
44
+ not None, results from the same seed may not be identical between runs due to
45
+ finite clock resolution.
46
+ num_restarts: int
47
+ Maximum number of tabu search restarts per read. Setting this value to zero
48
+ results in a simple tabu search.
49
+ energy_threshold: Optional[float]
50
+ Terminate when an energy lower than or equal to `energy_threshold` is found.
51
+ coefficient_z_first: Optional[int]
52
+ `max(bqm.num_variables*coefficient_z_first, lower_bound_z)` bounds the number of
53
+ variable updates considered in the first simple tabu search (STS). Variable
54
+ updates arising from the STS greedy-descent subroutine, invoked upon discovery
55
+ of new global optima, are excluded from the count. The coefficient defaults to
56
+ 10_000 for small problems (up to 500 variables) and 25_000 for larger problems.
57
+ coefficient_z_restart: Optional[int]
58
+ Controls the number of variable updates on restarted simple tabu search stages,
59
+ matching the description for `coefficient_z_first`. The coefficient defaults to
60
+ `coefficient_z_first/4`
61
+ lower_bound_z: Optional[int]
62
+ Sets a minimum number of variable updates on all simple tabu searches, see
63
+ `coefficient_z_first`. The bound defaults to 500_000.
64
+ """
65
+
66
+ initial_states: Optional[Any] = None
67
+ seed: Optional[int] = None
68
+ num_restarts: int = 1_000_000
69
+ energy_threshold: Optional[float] = None
70
+ coefficient_z_first: Optional[int] = None
71
+ coefficient_z_restart: Optional[int] = None
72
+ lower_bound_z: Optional[int] = None
@@ -0,0 +1,20 @@
1
+ """Solver Parameters"""
2
+
3
+ from luna_sdk.schemas.solver_parameters.fujitsu.digital_annealer_cpu import (
4
+ DigitalAnnealerCPUParameters,
5
+ )
6
+ from luna_sdk.schemas.solver_parameters.fujitsu.digital_annealer_v2 import (
7
+ DigitalAnnealerV2Parameters,
8
+ )
9
+ from luna_sdk.schemas.solver_parameters.fujitsu.digital_annealer_v3 import (
10
+ DigitalAnnealerV3Parameters,
11
+ )
12
+ from luna_sdk.schemas.solver_parameters.fujitsu.partial_config import (
13
+ BitArrayShape,
14
+ Category,
15
+ OneHot,
16
+ OneHotGroup,
17
+ PartialConfig,
18
+ Variable,
19
+ VarShapeSet,
20
+ )